hi guys,

i have a BroadCastReceiver which will listen to incoming calls. and
once the call is finish or users ignores the call i'm deleting the
number from the CallLog. i have tested this with HTC TATTOO and it
works fine there.

but when i tested this with Motorola MilesTone i'm getting a exception

this is the Exception

06-21 13:34:02.365: ERROR/DatabaseUtils(1337): Writing exception to
parcel
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):
java.lang.UnsupportedOperationException: Cannot delete that URL:
content://call_log/calls/442
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):     at
com.android.providers.contacts.CallLogProvider.delete(CallLogProvider.java:
197)
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):     at
android.content.ContentProvider$Transport.delete(ContentProvider.java:
174)
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):     at
android.content.ContentProviderNative.onTransact(ContentProviderNative.java:
180)
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):     at
android.os.Binder.execTransact(Binder.java:287)
06-21 13:34:02.365: ERROR/DatabaseUtils(1337):     at
dalvik.system.NativeStart.run(Native Method)



06-21 13:34:02.381: ERROR/AndroidRuntime(1593): Uncaught handler:
thread main exiting due to uncaught exception
06-21 13:34:02.459: ERROR/AndroidRuntime(1593):
java.lang.UnsupportedOperationException: Cannot delete that URL:
content://call_log/calls/442

this is my code

public class CallListener extends BroadcastReceiver {
        private Context context;
        String phonenbr;
        TelephonyManager telManager;
        Handler handler = new Handler();

        @Override
        public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                this.context = context;
                        telManager = (TelephonyManager) context
                                        
.getSystemService(Context.TELEPHONY_SERVICE);
                        telManager.listen(new StateListener(),
                                        PhoneStateListener.LISTEN_CALL_STATE);

        }

        class StateListener extends PhoneStateListener {
                @Override
                public void onCallStateChanged(int state, String 
incomingNumber) {
                        // TODO Auto-generated method stub
                        // super.onCallStateChanged(state, incomingNumber);
                        switch (state) {
                        case TelephonyManager.CALL_STATE_RINGING:
                                break;
                        case TelephonyManager.CALL_STATE_IDLE:

                                listeneNativeInbox();
                                break;
                        case TelephonyManager.CALL_STATE_OFFHOOK:

                                break;
                        }
                }
        }
protected void listeneNativeInbox() {

                context.getContentResolver().registerContentObserver(
                                CallLog.Calls.CONTENT_URI, true, new 
MyInboxListener(handler));

                // 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;
                        Uri books = 
Uri.parse("content://com.sabretch.colorEyeD/SABRE");
                        Log.d("Authority", books.getAuthority());
                        Cursor cursor = 
context.getContentResolver().query(books, null,
                                        "Mobile" + "='" + phonenbr + "'", null,
                                        "category " + "DESC");
                        if (cursor != null) {
                                if (cursor.moveToNext()) {
                                        b = true;
                                }
                        }
                        Message msg = new Message();
                        msg.obj = "xxxxxxxxxx";
                        handler.sendMessage(msg);
                        Cursor cur = context.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) {
                                int x = 
context.getContentResolver().delete(uri, null, null);
                                Log.d("FFFFFFFFFASSDSSDESD", 
Integer.toString(x));
                        }
                        System.exit(0);
                        // }
                }
        }
}

so do you have any idea about this??
NOTE:- works correctly in HTC tattoo but not in Motorola Milestone

regards,
Mike

-- 
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