android - fetching all the call details like number,call type etc after call disconnect and automatically post it with web services -
i have fetched call details through code.
private void getcalldetails() { stringbuffer sb = new stringbuffer(); if (activitycompat.checkselfpermission(getactivity(), manifest.permission.read_call_log) != packagemanager.permission_granted) { return; } cursor managedcursor = getactivity().getcontentresolver().query(calllog.calls.content_uri, null, null, null, calllog.calls.date + " desc limit 40"); int number = managedcursor.getcolumnindex(calllog.calls.number); int type = managedcursor.getcolumnindex(calllog.calls.type); int date = managedcursor.getcolumnindex(calllog.calls.date); int duration = managedcursor.getcolumnindex(calllog.calls.duration); // sb.append("call details :"); string finaldate[]; while (managedcursor.movetonext()) { string phnumber = managedcursor.getstring(number); string calltype = managedcursor.getstring(type); string calldate = managedcursor.getstring(date); date calldaytime = new date(long.valueof(calldate)); string durationn=managedcursor.getstring(duration); system.out.println("ph no....."+ phnumber); system.out.println("type....."+calltype); system.out.println("date....."+ calldate); system.out.println("duration....."+ calldaytime); system.out.println("call date time "+calldaytime); string calldatechange=calldaytime.tostring(); string callduration = managedcursor.getstring(duration); string dir = null; int dircode = integer.parseint(calltype); switch (dircode) { case calllog.calls.outgoing_type: dir = "outgoing"; break; case calllog.calls.incoming_type: dir = "incoming"; break; case calllog.calls.missed_type: dir = "missed"; break; } phnolist.add(phnumber); calldura.add(durationn); system.out.println("call duration is"+calldura); //caldatlist.add(calldate); calltimelist.add(calldatechange); /* forcallog.add("\nphone number:--- " + phnumber + " \ncall type:--- " + dir + " \ncall date:--- " + calldaytime + " \ncall duration in sec :--- " + callduration);*/ sb.append(phnumber +","+ dir + ","+ calldaytime + ","+ callduration); // sb.append("\n---------------------------------------------"); } system.out.println("myphone is::"+ phnolist.size()); system.out.println("calldate is::"+ caldatlist); system.out.println("calltimelist is::"+ calltimelist); managedcursor.close();
also have fetched time @ call disconnected.i able show popup @ time of call disconnect.now want fetch details of last call @ place call disconnect intent checked has been done through broadcast receiver , append details in web service.how can that.
if (intent.getaction().equals("android.intent.action.new_outgoing_call")) { savednumber = intent.getextras().getstring("android.intent.extra.phone_number"); toast.maketext(context,"the no. is"+savednumber,toast.length_long).show(); // onoutgoingcallstarted(context,"",callstarttime); } else { string statestr = intent.getextras().getstring(telephonymanager.extra_state); string number = intent.getextras().getstring(telephonymanager.extra_incoming_number); int state = 0; if(statestr.equals(telephonymanager.extra_state_idle)) { switch (state) { case telephonymanager.call_state_idle: log.d("testing", "outgoing call has been disconnect"); intent = new intent(context, mycustomdialog.class); intent.addflags(intent.flag_activity_new_task); intent.addflags(intent.flag_activity_single_top); context.startactivity(intent); system.out.println("call has been disconnect..............."); // toast.maketext(this, "call has been disconnect", toast.length_long).show(); break; } }
here fetching call disconnect action.at same time want send details through web service.
Comments
Post a Comment