How to know the call state in android -



How to know the call state in android -

i know phonestatelistener know, phone call type incoming, or ringing or picked etc.. 1 time phone call ends i.e 1 time phone reaches idle state, want know state of call, picked, missed or rejected

lets take, +91123456789 incoming call, after phone call ends, number stored in phone phone call log missed call,

is there way fetch recent state phone call log particular number +91123456789, possible?

here code can query phone call log missed call. basically, have trigger , create sure give phone call log time ( few seconds should it) write info otherwise if check phone call log not find recent call.

int missed_call_type = android.provider.calllog.calls.missed_type final string[] projection = null; final string selection = null; final string[] selectionargs = null; final string sortorder = android.provider.calllog.calls.date + " desc"; cursor cursor = null; try{ // cursor = context.getcontentresolver().query( // uri.parse("content://call_log/calls"), // projection, // selection, // selectionargs, // sortorder); cursor = getcontentresolver().query(calllog.calls.content_uri, null, calllog.calls.number + "=? ", yournumber, sortorder); while (cursor.movetonext()) { string calllogid = cursor.getstring(cursor.getcolumnindex(android.provider.calllog.calls._id)); string callnumber = cursor.getstring(cursor.getcolumnindex(android.provider.calllog.calls.number)); string calldate = cursor.getstring(cursor.getcolumnindex(android.provider.calllog.calls.date)); string calltype = cursor.getstring(cursor.getcolumnindex(android.provider.calllog.calls.type)); string iscallnew = cursor.getstring(cursor.getcolumnindex(android.provider.calllog.calls.new)); if(integer.parseint(calltype) == missed_call_type && integer.parseint(iscallnew) > 0){ if (_debug) log.v("missed phone call found: " + callnumber); break ; } } }catch(exception ex){ if (_debug) log.e("error: " + ex.tostring()); }finally{ cursor.close(); }

i hope find useful, in same way can other states.

do add together permission in manifest android.permission.read_contacts

android

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -