java - Check if incoming call was missed -
java - Check if incoming call was missed -
i have broadcast receiver registered incoming phone call event states , want sure idle incoming phone call missed phone call oposed rejected call. access calllog provider latest device phone call , compare it's type calllog.calls.missed_type. problem receiver before calllog provider updated lastly phone call received device... why i'm using thread.sleep on receiver, create receiver wait calllog provider update before queries it, can see below:
private boolean ismissedcall(context context){ //previous state global var if(previousstate != null && previousstate.equals(ringing)){ //this ugly!! seek { thread.sleep(2000); } grab (interruptedexception e) { e.printstacktrace(); } string calltype = android.provider.calllog.calls.type; string callnew = android.provider.calllog.calls.new; string calldate = android.provider.calllog.calls.date; string[] strfields = { calltype, callnew, calldate}; string strorder = calldate + " desc"; cursor mcallcursor = context.getcontentresolver().query(android.provider.calllog.calls.content_uri, strfields, null, null, strorder); if (mcallcursor.movetofirst()) { if(mcallcursor.getint(mcallcursor.getcolumnindex(callnew)) > 0) { homecoming mcallcursor.getint(mcallcursor.getcolumnindex(calltype)) == calllog.calls.missed_type; } } } homecoming false; }
i not happy solution of having set thread on sleep, didnt find anywhere, far, solution problem. sense there must beeter way so, inquire best ways know on how recent incoming phone call calllog, on onreceive method of bradcast receiver.
p.s: min target android sdk 8.
thanks in advance
i found blog post might reply question well.
to observe missed phone call check below part in mentioned post
case telephonymanager.call_state_idle: //went idle- end of call. type depends on previous state(s) if(laststate == telephonymanager.call_state_ringing){ //ring no pickup- miss onmissedcall(context, savednumber, callstarttime); }
java android calllog
Comments
Post a Comment