Thursday, 15 July 2010

java - How to open activity after Missed call android? -



java - How to open activity after Missed call android? -

i have develop code of phone call on missed phone call number. in code confuse @ position set intent on new activity. open activity @ time of incoming call. @ time of miscall confuse. how can open activity after missed phone call .

code context c; boolean cut, flag = true; phonestatelistener listener; sharedpreferences prefs; static boolean ring = false; static boolean callreceived = false; public myphonestatelistener(context c) { // todo auto-generated constructor stub this.c = c; } @override public void oncallstatechanged(int state, string incomingnumber) { super.oncallstatechanged(state, incomingnumber); log.d("main", "incoming phone call receiver."); powermanager pm = (powermanager) c .getsystemservice(context.power_service); boolean isscreenon = pm.isscreenon(); if (state == telephonymanager.call_state_ringing) { log.d("flags", "flags: " + flag); if (flag) { cutting = true; flag = false; checkmisscall phone call = new checkmisscall(c); call.setname(incomingnumber); call.setnumber4sms(incomingnumber); call.setcontactphoto(); log.d("main", "state ringing"); prefs = preferencemanager.getdefaultsharedpreferences(c); if (!prefs.getboolean("main_state", false)) { return; } if (!isscreenon && checkmisscall.isrunning) { return; } else { log.d("main", "eeeeeeeeeeeeeeee: unlock hud"); intent in=new intent(c, unlock_hud.class); in.setflags( intent.flag_activity_previous_is_top); c.startservice(in); } } } else if (state == telephonymanager.call_state_offhook) { log.d("main", "offhook"); } else { if (cut && checkmisscall.isshown) { log.d("main", "cutted"); c.stopservice(new intent(c, unlock_hud.class)); flag = true; } } } }

here finish solution.

start new activity instead of toast message in below code.

happy coding..!!

public class incommingcallreceiver extends broadcastreceiver { static boolean ring=false; static boolean callreceived=false; @override public void onreceive(context mcontext, intent intent) { // current phone state string state = intent.getstringextra(telephonymanager.extra_state); if(state==null) return; // if phone state "rininging" if(state.equals(telephonymanager.extra_state_ringing)) { ring =true; // caller's phone number bundle bundle = intent.getextras(); callerphonenumber= bundle.getstring("incoming_number"); } // if incoming phone call received if(state.equals(telephonymanager.extra_state_offhook)) { callreceived=true; } // if phone idle if (state.equals(telephonymanager.extra_state_idle)) { // if phone ringing(ring=true) , not received(callreceived=false) , missed phone call if(ring==true&&callreceived==false) { toast.maketext(mcontext, "it missed phone call : "+callerphonenumber, toast.length_long).show(); } } }

java android performance

No comments:

Post a Comment