【问题标题】:I want to know the phone number of call, deleted from the call logs我想知道通话的电话号码,已从通话记录中删除
【发布时间】:2016-08-02 06:02:39
【问题描述】:

只要通话记录发生变化,我就能收到通知,但我也需要 号码

这是我的代码:

public class MainActivity extends AppCompatActivity {    
    CallLogChangeObserverClass callLogChangeObserverClass = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        callLogChangeObserverClass = new CallLogChangeObserverClass(new Handler(), this);

        //Registering content observer
        getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI, true,
                callLogChangeObserverClass);

    }


    public class CallLogChangeObserverClass extends ContentObserver {
        public CallLogChangeObserverClass(Handler handler, Context ct) {
            super(handler);
            // TODO Auto-generated constructor stub
        }

        public void onChange(boolean selfChange) {
            Toast.makeText(getApplicationContext(), "Call Log Changed", Toast.LENGTH_LONG).show();
            //Read call Logs here
        }
    }

【问题讨论】:

    标签: android telephony calllog


    【解决方案1】:

    最后我得到了解决方案,但我不知道方法是否正确。这有效调用日志和联系人号码更改

    在 onChange 中

    execute a Query with contentResolver(), and put the data in a List
    then something is deleted again 
    execute a Query with contentResolver(),and assign it to tempList.
    now compare the List and tempList
    
    
    
    @Override
            public void onChange(boolean selfChange) {
                super.onChange(selfChange);    
     final int List = totalContacts();
    
    if (tempList < List) {
    something is deleted
    then remove the tempList from List you will get the deleted number
    
    }else if (tempList == List) {
    something is updated
    then remove the tempList from List you will get the deleted number
    }else {
           something is added(reverse the Lists)
    then remove the List from tempList you will get the deleted number
        }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      • 2012-10-27
      相关资源
      最近更新 更多