2

大家好,我最近一直在玩弄 Android 的原生扩展,我需要添加 Google Cloud Messaging。我能够让 Google Cloud Messaging 应用程序自行运行。但是现在我已经将它集成到 Flash 的本机扩展中,我发现了一个我无法解决的问题。

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

当 GCM 广播接收器接收到

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

该错误是由 Flash Package Context 是默认包引起的。当我需要默认包是包含 GCMIntentService 的包时。

有没有人能够让 GCMIntentService 在 Android Flash Native Extension 中运行?或任何 AndroidIntentService 。

4

1 回答 1

4

您需要确保将 Intent Service 添加到 AIR 应用程序描述符的清单添加中,而不是本机代码库的 Android 清单中。例如,以下代码是我们在 GCM 原生扩展的示例应用程序中使用的代码,如果您有兴趣,请点击此处

里面有几件事要注意,尤其是“空气”。一些android名称的前缀。但只要您拥有所有这些附加功能,Android 代码的实际实现应该与 Google 示例非常相似。

<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>
于 2012-08-22T23:38:54.157 回答