gpt4 book ai didi

android - gcm GoogleCloudMessaging 新实现

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:39 25 4
gpt4 key购买 nike

我尝试从 gcm.jar 更新以从 google-play-services.jar 获取 GCM。我使用与所示相同的代码 here .

我使用的是与更改客户端实现之前相同的服务器 (node-gcm)。

我得到了 registrationId,但是当我尝试发送通知时,没有调用 GcmBroadcastReceiver.onReceive。 (我在 list 文件中有它)

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;

/**
* Created with IntelliJ IDEA.
* User: Eran
* Date: 11/11/13
* Time: 00:43
* To change this template use File | Settings | File Templates.
*/
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("GcmBroadcastReceiver", intent.getDataString());
// 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);
}
}

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamerlabs.high5poker"
android:versionCode="3"
android:versionName="3.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"

>
</supports-screens>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.android.vending.BILLING" />

<permission android:name="com.gameralabs.high5poker.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.gameralabs.high5poker.permission.C2D_MESSAGE" />

<application
android:name="com.gameralabs.classes.HFApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:debuggable="true"
>

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />

<activity android:name="com.facebook.LoginActivity"/>
<activity
android:name="com.gameralabs.high5poker.HFSplashActivity"
android:screenOrientation="landscape"
android:noHistory="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name="com.gameralabs.high5poker.HFLoginActivity"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity
android:name="com.gameralabs.high5poker.HFLobbyActivity"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity
android:name="com.gameralabs.high5poker.HFGameActivity"
android:noHistory="true"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity android:name="com.gameralabs.high5poker.HFActivity"/>

<receiver
android:name="com.gameralabs.high5poker.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.gameralabs.high5poker" />
</intent-filter>
</receiver>
<service android:name="com.gameralabs.high5poker.GcmIntentService" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>

</manifest>

有什么帮助吗?

最佳答案

您忘记更改权限中的包名称。

<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

应该是

<permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE" />

关于android - gcm GoogleCloudMessaging 新实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19908290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com