2016-08-17 87 views
0

我正在使用BOOT_COMPLETED Intent启动我的服务。 但是,像5中的1次一样,BOOT_COMPLETED意图未发送,因此我的服务无法启动。我曾尝试使用WakefulBroadcastReceiver和其他的东西,但我不明白为什么它有时不发送。我的意思是设备正在工作,您可以通过adb等连接到它,这只是BOOT_COMPLETED不发送。有没有人知道发生了什么?BOOT_COMPLETED偶尔在启动时未发送

我在Android 4.4.4 Kitkat。我意识到停止状态问题,但是我已经使用Xposed来禁用它,它仍然不起作用,所以它应该是别的东西。

回答

-1

也许清单补充说:

<receiver android:name=".services.ShutdownReceiver"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     </intent-filter> 
</receiver> 

在创建类:

public class ShutdownReceiver extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     Intent i = new Intent(context, GPSService.class); 
     context.startService(i); 
    } 
}  
相关问题