2016-08-17 83 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); 
    } 
}  
相關問題