Start service

by Alex » Thu, 08 Jul 2010 02:29:12 GMT


Sponsored Links
 Hi there,
I am trying to start a service from the BroadcastReceiver, but I keep
getting the startService line marked as an error (The constructor
Intent(alarmReceiver, Class<aService>) is undefined)

public class alarmReceiver extends BroadcastReceiver{

        NotificationManager notifMgr;

        private static final int NOTIFICATION_ID = 0;

        @Override
        public void onReceive(Context context, Intent intent) {

                startService(new Intent(this,aService.class));
        }
}

Any help is greatly appreciated.
Thanks!!


--



Start service

by Mark Murphy » Thu, 08 Jul 2010 03:10:18 GMT


 A BroadcastReceiver is not a Context and so does not have a
startService() method. Call startService() on the Context supplied to
the onReceive() method.



>


Sponsored Links


Other Threads

1. Gmail offline with Gears

Hi,

For those who have this new gmail Labs option available... does it
work in Android browser ?

--~--~---------~--~----~------------~-------~--~----~

2. Any way to reject a call programmatically

Is there any direct (or convoluted) way to reject an incoming call,
i.e. send it directly to voicemail. Meaning
(a) if a call is coming in and matches certain criteria
(b) send the call to VM, and stop the ringing. (programmatically)
I've got (a) under control but I dont know how to do (b).
Any ideas?
Thanks
Jay
--~--~---------~--~----~------------~-------~--~----~

3. How do you pass a Bundle to an activity on an instrumentation test case?

4. MediaPlayer seeking back

5. Should onSaveInstanceState call super?

6. Android or G1 is eating too much battery power?

7. Question about following the activitycreator script