1

わかりました、始めに、私はこの問題を解決しようとして4時間ここに座っていましたが、役に立ちませんでした.

ブロードキャストを実行するために PendingIntent を使用していますが、PendingIntent は起動しません。

私のマニフェストの受信者宣言は次のとおりです。 <receiver android:process=":remote" android:name=".AlarmReceiver"/>

AlarmReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i(MainActivity.TAG, "FIRED!");
}

AlarmService.java

@Override
public void onCreate() {
    Log.i(MainActivity.TAG, "Service starting!");
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, AlarmReceiver.class), 0);
    try {
        pendingIntent.send();
    } catch (PendingIntent.CanceledException e) {
        Log.e(MainActivity.TAG, "FAIL!", e);
    }
}

私のlogcatでは、取得していますが、またはService starting!取得していません。コードは単純に見えますが、機能しません。このコードが機能しない理由はありますか?FIRED!FAIL!

PSを削除android:processすると機能しますが、ブロードキャストを別のプロセスで実行する必要があります。

4

0 に答える 0