编辑:我能够弄明白并使GCM正常运行。 See my answer here
我能够从我的Android应用程序注册GCM,但我无法弄清楚如何使用BroadcastReceiver
来接收消息。如果我从服务器向手机发送消息,则应用程序崩溃并显示错误:
E/AndroidRuntime(6775): java.lang.RuntimeException: Unable to instantiate receive
com.embarcadero.mytestapp.GcmBroadcastReceiver: java.lang.ClassNotFoundException:
Didn't find class "com.embarcadero.mytestapp.GcmBroadcastReceiver" on path:
DexPathList[[zip file "/data/app/com.embarcadero.mytestapp-
1.apk"],nativeLibraryDirectories=[/data/app-lib/com.embarcadero.mytestapp-1,
/vendor/lib, /system/lib]]
有没有人有关于如何在Delphi中使用Android GCM的任何提示?
编辑:这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.embarcadero.mytestapp"
android:versionCode="1"
android:versionName="1.0.0">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="mytestapp"
android:installLocation="preferExternal"
android:debuggable="True"
android:largeHeap="False"
android:icon="@drawable/ic_launcher"
android:theme="@android:style/Theme.NoTitleBar">
<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.embarcadero.mytestapp" />
</intent-filter>
</receiver>
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="mytestapp"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="mytestapp" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->