Service for incoming calls and sms

Put your problem here if it does not fit any of the other categories.

Service for incoming calls and sms

Postby Manfred » Wed Mar 11, 2009 8:47 am

Hi!

I have implemented a service which reacts on incoming calls and sms. After a while running, the service seems to be running (explained later why i know this) but it don´t react on incoming calls or sms? If i want then to stop the service, i get an error message (only that the application must be stopped).

I have 2 Buttons, one for start and one for stopping the service in an activity. This activity then starts the service. In the service in the method onStart() i start the listeners:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         smslistener = new SMSListener();
  2.  
  3.         registerReceiver(smslistener, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


In the activity i look if the service is running and disable or enable
the start and stop button:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         boolean isrunning = false;
  2.  
  3.         List<ActivityManager.RunningServiceInfo> list = am.getRunningServices(99);
  4.  
  5.         for(RunningServiceInfo service:list)
  6.  
  7.         {
  8.  
  9.                 if(service.process.equals("com.myapp.rn")  && service.started==true)
  10.  
  11.                 {
  12.  
  13.                                 isrunning = true;
  14.  
  15.                                 break;
  16.  
  17.                 }
  18.  
  19.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


When the service does not inform about incoming sms/calls and i start the activity, then the stop button is activated therefore i can say that the service is still running!? So may it is false to start the
listeners where i do? But what is the right way to implement a service which listens to incoming calls/sms??
Or what could be the problem that the service seems to be running, but it don´t react?



Thanks
Manfred
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Feb 10, 2009 2:13 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests