public class MyBroadcastReceive extends BroadcastReceiver {
static final String action_boot="android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context ctx, Intent intent) {
Log.d("BootReceiver", "system boot completed");
if (intent.getAction().equals(action_boot)){
//start service
try {
Intent s=new Intent(ctx,WatchDogService.class);
ctx.startService(s);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
AndroidManifest.xml裡權限也加了 可是一開機就顯示”很抱歉 程序***已停止運行“ 但是正常運行程序不會報錯
問題解決了 是我自己在AndroidManifest.xml裡面receive的包名寫錯了