0

EDIT: I was able to figure it out and make the GCM work. See my answer here.

I was able to register with GCM from my android application, but I can't figure out how to use the BroadcastReceiver to receive the messages. If I send a message from the server to my phone, the application crashes with the error:

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]]

Does anyone have any tips on how to use android GCM with Delphi?

Edit: Here is my manifest:

<?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) -->
Community
  • 1
  • 1
ioan ghip
  • 1,202
  • 2
  • 16
  • 27
  • Why don't you try to create a service that extends from GCMIntentService, manipulate the message received from there, and add to the manifest the Service tag of the GCMIntentService. – Carlos Tirado Jan 15 '14 at 00:07
  • @CarlosT GCMIntentService is not available in Delphi (yet) but BroadcastReceiver is. – ioan ghip Jan 15 '14 at 17:14

0 Answers0