Vote count:
0
i am developing an app i need to service run always but if i power off my device then service is stopped. I am using following code for always run in backgroun but after this my device is hang .
<receiver android:name="com.halosys.TvAnyTime.ServiceAutoStarter">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
above code used in manifest and below code use in onReceive method
public class ServiceAutoStarter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context, ServiceTemplate.class);
context.startService(myIntent);
}
}
asked 52 secs ago
Aucun commentaire:
Enregistrer un commentaire