hi Mike,

Thanks for your reply. according to my scenario i cant delete all the
entries in the log. i just want to delete the currently received
number. i think this listNativeInbox() method is fine. it's just a
matter of calling in the correct place.

if i run a service like the below describe way

public class CallDelete extends Service {
        private String number;
        static Context con;
        static Handler handler = new Handler();

        @Override
        public IBinder onBind(Intent intent) {
                // TODO Auto-generated method stub
                return null;
        }

        @Override
        public void onStart(Intent intent, int startId) {
                // TODO Auto-generated method stub
                super.onStart(intent, startId);
                Bundle bundle = intent.getExtras();

                if (bundle != null) {
                        number = bundle.getString("Number");
                        listeneNativeInbox();
                }
        }

        protected void listeneNativeInbox() {

                Log.d("listeneNativeInbox bgfgfh", "listeneNativeInbox fhythg");
                con.getContentResolver().registerContentObserver(
                                CallLog.Calls.CONTENT_URI, true, new 
MyInboxListener(handler));

                Log.d("listeneNativeInbox", "listeneNativeInbox");

                // Uri Sms = Uri.parse("content://sms/inbox");

                // Cursor c = context.getContentResolver().query(
                // CallLog.Calls.CONTENT_URI, null, null, null, null);

        }

        class MyInboxListener extends ContentObserver {

                public MyInboxListener(Handler handler) {
                        super(handler);
                        // TODO Auto-generated constructor stub
                }

                @Override
                public boolean deliverSelfNotifications() {
                        // TODO Auto-generated method stub
                        return false;
                }

                @Override
                public void onChange(boolean selfChange) {
                        // TODO Auto-generated method stub
                        boolean b = false;
                        Log.d("Authoritysfdgfdgdgdfgdfgdf dgdfgfgf",
                                        "ON 
CHANGEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEee");
                        Uri books = 
Uri.parse("content://com.sabretch.colorEyeD/SABRE");
                        Log.d("Authority", books.getAuthority());
                        Cursor cursor = con.getContentResolver().query(books, 
null,
                                        "Mobile" + "='" + number + "'", null, 
"category " + "DESC");
                        if (cursor != null) {
                                if (cursor.moveToNext()) {
                                        b = true;
                                }
                        }
                        Message msg = new Message();
                        msg.obj = "xxxxxxxxxx";
                        handler.sendMessage(msg);
                        Cursor cur = con.getContentResolver().query(
                                        CallLog.Calls.CONTENT_URI, null, null, 
null,
                                        CallLog.Calls._ID + " DESC");

                        cur.moveToNext();
                        long threadIdIn = cur
                                        
.getLong(cur.getColumnIndex(CallLog.Calls._ID));

                        /*
                         * Uri uri = 
ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI,
                         * threadIdIn);
                         */
                        if (b) {
                                ContentValues values = new ContentValues();
                                values.put(CallLog.Calls.NUMBER, "4444444444");
                                values.put(CallLog.Calls.CACHED_NAME, 
"Unknown");
                                // values.put(CallLog.Calls.TYPE, 
CallLog.Calls.INCOMING_TYPE);
                                // long time = System.currentTimeMillis() - 
5000000;
                                // values.put(CallLog.Calls.DATE, time);

                                // int x = 
context.getContentResolver().delete(uri, null, null);
                                try {
                                        int x = con.getContentResolver().update(
                                                        
CallLog.Calls.CONTENT_URI, values,
                                                        CallLog.Calls._ID + 
"='" + threadIdIn + "'", null);
                                        Log.d("FFFFFFFFFASSDSSDESD", 
Integer.toString(x));
                                        // = true;
                                } catch (Exception e) {
                                        // TODO: handle exception
                                        int x = con.getContentResolver().update(
                                                        
CallLog.Calls.CONTENT_URI, values,
                                                        CallLog.Calls._ID + 
"='" + 0 + "'", null);
                                        // = true;

                                        Log.d("EXITv ttttt Successfully", "EXIT 
Successfully");
                                        /*
                                         * 
finishActivity(Constants.DRAW_ACTIVITY); finish();
                                         */
                                        // finish();
                                        // 
finishActivity(Constants.DRAW_ACTIVITY);
                                        // finish();
                                        System.exit(0);
                                        // Process.killProcess(Process.myTid());
                                        Log.d("EXITv ttttt Successfully", "EXIT 
Successfully");
                                }
                        }

                        Log.d("EXIT Successfully", "EXIT Successfully");
                        /*
                         * finishActivity(Constants.DRAW_ACTIVITY); finish();
                         */
                        // finish();
                        // finishActivity(Constants.DRAW_ACTIVITY);
                        // Process.killProcess(Process.myTid());
                        // finish();
                        System.exit(0);
                        Log.d("EXIT Successfully", "EXIT Successfully");
                        // System.exit(0);
                        // }
                }
        }
}

and if i start the service in the IDEL state like this

Intent i = new Intent(context,CallDelete.class);
                                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                i.putExtra("Number", phonenbr);
                                context.startService(i);

will this work???

my concern is though i'm able to start the service will it be able to
run the service despite quitting the application???

regards,
Donald

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to