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;

        public void onReceive(Context context, Intent intent) {

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

Any help is greatly appreciated.


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. Emulator DNS/network there a posted fix?

I've read many postings about problems getting the Android emulator
DNS to work properly in certain situations. I have a simple app that
makes an HTTP connection to a server on the Internet. If I use an IP
address using the latest version of the emulator  it works fine. If I
use the domain name it throws a Host is
unresolved: exception. The identical code works fine on any actual

Has anyone figured out how to fix this situation? I've spent days
trying everything, from using proxy servers to setting up and running
a DNS server on my development machine.

This situation/experience is a shame, because the emulator seems like
such an impressive and well thought out collection of tools for
developing and testing apps. However, it is currently useless to me.

Is there anyone who can help?

A prior thread on the same issue--appears to be the same situation:

2. Android Supportted Screent Resolution

Hi ,

     We plan to use Android on our new board, which we didn't decide the
resolution yet,
     so i'm wondering which resolution Android support, i think it's related
to the kernel's frame buffer driver,
     but how about Android itself, is there any limitation about the screen



3. Sending Unicode characters in unit tests?

4. Orientation Change effect on Spinner control

5. web page not available

6. Who wants Multi-touch in all Android versions?

7. What does it take for a new device to be Android Compliant?