java - Check if incoming call was missed -
I have registered for a broadcast receiver incoming call event states and I'm sure the incoming call passes a missed call to want to be had as the challenged to reject calls I get to CallLog provider to receive calls the latest device and I compared it with CallLog.Calls.MISSED_TYPE. The problem is that the CallLog provider has been updated with the last call that was received by the device ... This is why I am using sleep on the receiver thread, which means my receiver waits for the CallLog provider It may be updated before these questions can be updated, as you can see below: I'm not happy with the solution to keep the thread on sleep, but I could not find anywhere else for this problem, yet, another solution. I think that I do this should be the way of a beater, I ask you on-receiving method of broadcast receiver, to learn about how to obtain the most recent incoming calls from CallLog best way. PS: My minimum goal is Android SDK 8. Thank you in advance
Private boolean isMissedCall (reference reference) {// preceded position on a global if (previousState = Null & amp; amp; ; PreviousState.equals (RINGING)) {// It is Dental !! Try {Thread.Sleep (2000); } Grip (Interrupted e) e.printStackTrace (); } String call type = android.provider.CallLog.Calls.TYPE; String call new = android.provir Call log. Call. NEW; String callcode = Android.provir Call log. Call.date; String [] strfold = {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)) & gt; 0) {return mCallCursor.getInt (mCallCursor.getColumnIndex (CALLTYPE)) == CallLog.Calls.MISSED_TYPE; } } } return false; }
I found which one might find my answer as well .
to find mention check a missed call
case has been idle TelephonyManager.CALL_STATE_IDLE: // Down - This is the end of the call. Depending on how the previous position (s) (lastState == TelephonyManager.CALL_STATE_RINGING) {// ring but no pickup- a miss OnMissedCall (reference, savedNumber, callStartTime); }
Comments
Post a Comment