Use   *context.startService(new Intent(this,aService.class));*    to start
the service . It is because Broadcastreceiver class does not  extend  the
Context class  so we have to use  the context  provided in the onReceive
method.

Cheers
Tarun

On Tue, Mar 27, 2012 at 6:18 PM, jugni <jugni1sm...@gmail.com> wrote:

> write like context.startservice();
>
>
> On Sunday, 4 July 2010 23:29:34 UTC+5:30, Alex wrote:
>>
>> 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!!
>>
>>
>>
> On Sunday, 4 July 2010 23:29:34 UTC+5:30, Alex wrote:
>>
>> 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!!
>>
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to