Hi

Below is my code. Maybe you find something interesting...

*manifest file:::*
<receiver android:enabled="true"
android:name=".broadcastreceiver.BootCompletedBroadcastReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"
/>
            </intent-filter>
        </receiver>

<service android:name=".service.MonitoringService">
            <intent-filter>
                <action android:name="your.package.name.MonitoringService"
/>
            </intent-filter>
        </service>

*Broadcast reciever*:::

@Override
    public void onReceive(Context context, Intent intent) {
            // Start service.
            Intent serviceIntent = new Intent(context,
MonitoringService.class);
            serviceIntent.putExtra(something, something);
            context.startService(serviceIntent);
    }

But remember! If you deploy app on running emulator don't expect to see your
"BootCompletedBroadcastReceiver" in action. First: deploy your app. Second:
close emulator. Third: run emulator with command: emulator -avd
your_emulator_name

2010/7/21 A N K ! T <[email protected]>

> .i write a app but it is not doing anything..code is given below if anybody
> can help.....
>
> *manifest file:::*
>   <application android:icon="@drawable/icon"
> android:label="@string/app_name">
>
>
>     <receiver android:name="myBR" >
>         <intent-filter>
>         <action
>         android:name="android.intent.action.BOOT_COMPLETED"/>
>         <category android:name="android.intent.category.HOME"/>
>          </intent-filter>
>         </receiver>
> <service android:name="myService">
>
> <action android:name="com.serceatboot.myService"/>
> </service>
> <activity android:name="myactivity"></activity>
> </application>
>     <uses-sdk android:minSdkVersion="4" />
>
> <uses-permission
> android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
>
> *
> Broadcast reciever*:::
>
> public class myBR extends BroadcastReceiver{
>     @Override
>     public void onReceive(Context context, Intent intent) {
>         // TODO Auto-generated method stub
>
>         Intent serviceIntent=new Intent();
>         serviceIntent.setAction("com.serviceatboot.myService");
>          intent.setClass(context,myService.class);
>          context.startService(serviceIntent);
>
>     }
>
> }
>
> *
> and service*:::public class myService extends Service{
>     @Override
>     public IBinder onBind(Intent intent) {
>         // TODO Auto-generated method stub
>         return null;
>     }
>     @Override
>     public void onCreate() {
>         // TODO Auto-generated method stub
>         super.onCreate();
>     Toast.makeText(this, "service created", Toast.LENGTH_SHORT).show();
>     }
>     @Override
>     public void onStart(Intent intent, int startId) {
>         // TODO Auto-generated method stub
>         super.onStart(intent, startId);
>         Toast.makeText(this, "service started", Toast.LENGTH_SHORT).show();
>          }
>    @Override
> public void onDestroy() {
>     // TODO Auto-generated method stub
>        Toast.makeText(this, "service Destroyed",
> Toast.LENGTH_SHORT).show();
>        super.onDestroy();
>
>    }
>
> }
>
>
> *please let me know if am doing anything wrong or missed something...*
> --
> Ankit
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 
===============================
Wojciech Topolski
[email protected]
===============================

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

Reply via email to