java - Start service on boot: why it doens't work? -
i start service when phone boot not work , not understand why. in package created class
import android.content.broadcastreceiver; import android.content.context; import android.content.intent; public class bootphone extends broadcastreceiver{ intent intent; @override public void onreceive(context context, intent intent) { // todo auto-generated method stub intent = new intent(context, service.class); context.startservice(intent); } } my service.class is
public class service extends service{ notify notify; @override public ibinder onbind(intent arg0) { // todo auto-generated method stub return null; } @override public void oncreate() { // todo auto-generated method stub super.oncreate(); notify = new notify(this); } } in manifest put
<service android:name="servicer"></service> <receiver android:name="bootphone" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="android.intent.action.boot_completed"/> </intent-filter> </receiver> but, why does'n work? problem/error?
you have declare user permission in manifest
<uses-permission android:name="android.permission.receive_boot_completed" />
Comments
Post a Comment