からの通知を受け取ることができません私は時間と時間について研究していますが、多くの同様の質問が見つかりましたが、私の質問のための解決策はありません。アプリを完全に閉じた後、gcm
私はgcmからのデータを受け取っていない通常の強制終了によってアプリケーションを閉じると分かります。しかし、私はアプリを起動するまでgcmで通知を受け取ることができませんでした。アプリケーションがフォアグラウンドでもバックグラウンドでも実行している場合、gcmからデータを受け取ることができますが、強制的に閉じることでアプリケーションを終了すると通知が表示されませんでした。すべてのデータを受け取ることはありません。 。つまり、私はアクティブにしておく必要がありますが、私がそうした場合、通知をプッシュするためのデザインはもうgcmを使用する必要はありません。
は、ここに私のマニフェスト
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.khooteckwei.google" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.gcmtesting.google.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcmtesting.google.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
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>
</activity>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.gcmtesting.google" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
</application>
</manifest>
ここ
あるwakefulBroadcastReceiverアプリがアクティブであるときに、私はnotification.Isを表示するために使用する機能が含まれていなかった細かい作業
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
通知ですこの2ページに何か問題がありますか?
あなたのデバイスは、あなたが「滑り落ちる」ときに強制停止します。これは正常な動作ではありませんが、少なくともメーカーが不正をしてこれを行ったデバイスがいくつかあります。あなたのアプリを実行してみて、それを滑り落ちてから、設定>アプリでアプリのページを見てください。 「強制停止」ボタンが無効になっている場合は、「スライドを外す」と強制停止します。 – CommonsWare
返信用のThx。しかしボタンが有効になっているので、私はその問題だとは思わない。 – user3651999
あなたのアプリが* foreground *である場合にのみgcm通知を受け取ることができるということを明確にしていますか? –