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


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();
  3.         registerReceiver(smslistener, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
Parsed in 0.013 seconds, using GeSHi

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;
  3.         List<ActivityManager.RunningServiceInfo> list = am.getRunningServices(99);
  5.         for(RunningServiceInfo service:list)
  7.         {
  9.                 if(service.process.equals("com.myapp.rn")  && service.started==true)
  11.                 {
  13.                                 isrunning = true;
  15.                                 break;
  17.                 }
  19.         }
Parsed in 0.011 seconds, using GeSHi

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?

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


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests