This is my temporary solution but i want to be able to listen the phone event even when the application is closed ( until the user will ask to stop the this service)
On Apr 28, 4:44 pm, Anurag Singh <anusingh...@gmail.com> wrote: > Why dont you put your code in OnDestry. > > like > > OnDestroy() { > > telephonyManager.listen(phoneListener, > PhoneStateListener.LISTEN_NONE); > } > > - Anurag Singh > > > > On Wed, Apr 28, 2010 at 7:07 PM, zohar lerman <lirazo...@gmail.com> wrote: > > Hi, > > > I am writing an application that listens to phone calls and perform > > some tasks when phone call arrives. > > The Application contains one activity which includes 2 buttons ‘Start’ > > and ‘Stop’ (where starts register the listener and stops unregister it > > – see code below). > > > The problem starts when the application is closed ( onDestroy is > > called ). > > If the user pressed on the start button and exit from the application > > the listener still working (which is the expected behavior) but from > > now it is impossible to unregister the listener since launching new > > instance of the application create new instance of phoneListener. > > > My question is: > > 1. Is there better way to implement my requirement? > > 2. Can I save the phoneListener object and reload It on > > application creation? > > 3. Any other idea? > > > Thanks > > > ((Button) findViewById(R.id.Start)).setOnClickListener(new > > View.OnClickListener() { > > public void onClick(View v) { > > telephonyManager.listen(phoneListener, > > PhoneStateListener.LISTEN_CALL_STATE); > > } > > }); > > > ((Button) findViewById(R.id.Stop)).setOnClickListener(new > > View.OnClickListener() { > > public void onClick(View v) { > > telephonyManager.listen(phoneListener, > > PhoneStateListener.LISTEN_NONE); > > } > > }); > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en