I want to start my application when phone startup
I just follow tutorial from here but it doesn't work in my device. Please see my method:
public class MyStartUpReciever extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent ii = new Intent();
ii.setAction("com.sat.servicetrack");
context.startService(ii);
}
}
and this is my manifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ServiceTrack"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".MyStartupReciever">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<service android:enabled="true" android:name=".MyService" >
<intent-filter>
<action android:name="com.sat.servicetrack" />
</intent-filter>
</service>
</application>
Am I missing anything?
and next you should implements BootService class extended Service
You are not calling the Service.
Code like this.
Click Here to know how to start service from broadcast receiver
I've done something similiar, but I was starting activity. Here is how I done it:
In Manifest:
In Java code:
Your code seems to be correct, but try using PendingIntent ;) Hope it helps you
try like this....
in manifest file...