2

Hey everyone I have been toying around with a native extension lately for Android and I need to add Google Cloud Messaging. I was able to get the Google Cloud Messaging app to work on its own. But now that I have integrated it into a native extension for Flash I have found an issue I can't resolve.

08-21 17:58:01.661: W/ActivityManager(180): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[air.GCMAppTest.debug] flg=0x10 cmp=air.GCMAppTest.debug/com.xxxxxxxxx.extensions.GCM.GCMIntentService (has extras) }: not found

This error comes up when the GCM Broadcast Receiver receives the

08-21 17:58:01.661: V/GCMBroadcastReceiver(7604): GCM IntentService class: com.gamecloudstudios.popsportsandroidane.extensions.GCM.GCMIntentService

The error is caused by the Flash Package Context being the default package. When I need the default package to be the package containing the GCMIntentService.

Has anyone been able to get the GCMIntentService to run in an Android Flash Native Extension? or any AndroidIntentService for that matter.

Jcup
  • 23
  • 1
  • 3

1 Answers1

4

You need to make sure you add the Intent Service to the manifest additions of your AIR application descriptor, not the Android manifest of your native code library. For example, the following code is what we use in our example application of our GCM native extension available here if you're interested.

There are a few things to note in there, especially the "air." prefix on some of the android names. But as long as you have all these additions, the actual implementation of the Android code should be fairly similar to the Google examples.

<android>
    <manifestAdditions><![CDATA[
        <manifest android:installLocation="auto">
            <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>

            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.GET_ACCOUNTS" />
            <uses-permission android:name="android.permission.WAKE_LOCK" />
            <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

            <!-- Only this application can receive the messages and registration result --> 
            <permission android:name="air.com.distriqt.test.debug.permission.C2D_MESSAGE" android:protectionLevel="signature" />
            <uses-permission android:name="air.com.distriqt.test.debug.permission.C2D_MESSAGE" />

            <application>
                <receiver android:enabled="true" android:exported="true" android:name="com.distriqt.extension.pushnotifications.PushNotificationsBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
                    <intent-filter>
                        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                        <category android:name="air.com.distriqt.test.debug" />
                    </intent-filter>
                </receiver>
                <service android:enabled="true" android:exported="true" android:name="com.distriqt.extension.pushnotifications.gcm.GCMIntentService" />

            </application>
        </manifest>

    ]]></manifestAdditions>
</android>
Michael
  • 3,776
  • 1
  • 16
  • 27
  • Thank you for your reply. I ended up finding it the next day but yes you have it. I had already added the intent service to the manifest, I just didn't have the correct path to it. Finding that was the issue. But I hope your answer helps many more people! – Jcup Sep 16 '12 at 01:48