2016-11-30 6 views
0

リブート後に保留中のインテントを継続するためにブロードキャストサービスを使用するアプリケーションがありますが、それが正常に動作しません。私の電話機を再起動すると、MyAppsName has stopped workingというポップアップ通知が表示されます。そして私が作ったログは現れません。Android:ブートブロードキャストがリブート後に機能しない

のmanifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.idkbro.pashchallenge"> 

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 
<action android:name="android.intent.action.QUICKBOOT_POWERON" /> 

<application 

    android:allowBackup="true" 
    android:name=".BaseApplication" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 


    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 



    <receiver android:name=".AlertReceiver"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 
      <category android:name="android.intent.category.HOME" /> 
     </intent-filter> 
    </receiver> 

    <receiver 
     android:name=".BootReceiver" 
     android:enabled="true" 
     android:permission="android.permission.RECEIVE_BOOT_COMPLETED" > 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </receiver> 

    <service 
     android:name=".NotificationService" 
     android:exported="true"></service> 

</application> 

BootReceiver:

if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")){ 
    Log.i("Xu", "Boot receiver is working"); 
} 

をそして権限とカテゴリの意図を削除します。

@Override 
public void onReceive(Context context, Intent intent) { 

    Log.i("Xu", "Boot receiver is working"); 
} 
+0

マニフェストで使用許可が2回宣言されているのはなぜですか?この 'android.intent.action.QUICKBOOT_POWERON'は何ですか?これはHTCにありますか? – t0mm13b

+0

2つの異なる分野でそれらを使用した異なる例を見てきました。しかし、私はそれが動作していない理由は考えていません –

+1

実際のブートレシーバクラスの[MCVE]の例を囲みます。ブロードキャストレシーバクラスのパッケージ全体が 'com.idkbro.pashchallenge.BootReceiver'であることを確認できますか? – t0mm13b

答えて

-1

ただ、受信機のクラスでこれを追加マニフェストのReciverタグからのフィルタ:

<receiver 
     android:name=".BootReceiver" 
     android:enabled="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 

     </intent-filter> 
    </receiver> 
+0

ありがとう、私は同じ結果を得ています。 'java.lang.SecurityException:Permission Denial:pid = 13157、uid = 2000からandroid.intent.action.BOOT_COMPLETEDブロードキャストを送信できませんでした。android.os.Parcel.readExceptionの (Parcel.java:1683) ' –

+0

OPに許可を削除するよう助言したのはなぜですか?/facepalm – t0mm13b

関連する問題