android - AIR Native Extension 无法启动服务 Intent Android GCM

标签 android actionscript-3 service air native

大家好,我最近一直在研究 Android 的 native 扩展,我需要添加 Google Cloud Messaging。我能够让 Google Cloud Messaging 应用程序独立运行。但现在我已将其集成到 Flash 的 native 扩展中,我发现了一个无法解决的问题。

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 扩展中运行吗?或任何与此相关的 AndroidIntentService。

最佳答案

您需要确保将 Intent Service 添加到 AIR 应用程序描述符的 list 添加项中,而不是 native 代码库的 Android list 中。例如,以下代码是我们在 GCM native 扩展 available here if you're interested 的示例应用程序中使用的代码.

其中有一些事情需要注意,尤其是“空气”。一些 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>

关于android - AIR Native Extension 无法启动服务 Intent Android GCM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12065255/

相关文章:

java - Android 多 dex 项目设置

android - Flutter:在应用程序关闭或在后台时运行 native Android 代码

android - ListView 适配器不能应用于 Modal 类

actionscript-3 - 查找数组中给定的匹配项

macos - Mac系统服务-应用程序 "(null)"

android - Android Q(10) 中带有 MediaRecorder 的 AccessibilityService 30 秒音频,而调用接收(应答)无法工作

android - 如何检查 API 级别 23 下的权限?

actionscript-3 - ActionScript 3.0 : Serialization of functions?

actionscript-3 - 位图作为按钮?

android - java.lang.IllegalStateException : Not allowed to start service Intent while trying to run RingtoneService 错误