Two Listeners in Service (android) -


firstly,sorry english.and sorry large text.i tried describe in details.

a bit of story:

i new in android.i have programming background(some python, c++).i read book java, @ first.then read book android(just few pages =) )

so,the goal of program:

run in background(here used service) phonecalllistener. when there incoming call, use sensoreventlistener, , magical things.

how realized it: ...

public class mbackground extends service{  public int onstartcommand(intent intent, int flags, int startid){      phonestatelistener phonestatelistener = new phonestatelistener();     telephonymanager telephonymanager = (telephonymanager)             .getsystemservice(context.telephony_service);     telephonymanager.listen(phonestatelistener,phonestatelistener.listen_call_state); 

then try use here "public class phonecalllistener extends phonestatelistener{"

and methods of phonestatelistener

public void oncallstatechanged(int state, string incomingnumber){ things } 

here have problem: reason, compiler not public in definition class phonecalllistener...and then,how can use sensor listener in 1 of methods of phonestatelistener?

i tried find information in google. honestly.

i not know how use listeners correctly in situation.i found similar questions, there listeners used without class extends , abstract methods.

thanks reading!

in onstartcommand

phonestatelistener phonestatelistener = new phonestatelistener(); 

should

phonecalllistener phonestatelistener = new phonecalllistener();   

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -