Java 在Android AIR应用程序中设置广播接收器
我正在使用AdobeAIR编写一个应用程序,并试图使用本机扩展将其部署到Android上。该应用程序需要能够利用谷歌的C2DM服务,相当于苹果的推送通知服务。这需要设置一个BroadcastReceiver,以便从Google接收设备注册。我能够在一个独立的原生Android应用程序no AIR中很好地实现这一点,但似乎无法在AIR应用程序中实现这一点。我想我一定是把清单XML设置错了,但我看不出是怎么回事 以下是AIR应用程序中清单文件中XML的相关部分:Java 在Android AIR应用程序中设置广播接收器,java,android,actionscript,air,air-native-extension,Java,Android,Actionscript,Air,Air Native Extension,我正在使用AdobeAIR编写一个应用程序,并试图使用本机扩展将其部署到Android上。该应用程序需要能够利用谷歌的C2DM服务,相当于苹果的推送通知服务。这需要设置一个BroadcastReceiver,以便从Google接收设备注册。我能够在一个独立的原生Android应用程序no AIR中很好地实现这一点,但似乎无法在AIR应用程序中实现这一点。我想我一定是把清单XML设置错了,但我看不出是怎么回事 以下是AIR应用程序中清单文件中XML的相关部分: <android>
<android>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<permission android:protectionLevel="signature" android:name="com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:enabled="true">
<receiver android:name="com.example.znotification.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</intent-filter>
</receiver>
</application>
</manifest>
]]></manifestAdditions>
</android>
通常,应该如何在AIR应用程序的清单XML中设置BroadcastReceiver?具体来说,在XML中,您如何告诉应用程序在接收到给定广播时运行正确的BroadcastReceiver?显然,我所做的是不正确的…你就快到了。我想你只是把AIR组件的android名称稍微弄错了。尝试下面的方法,注意一些类的air前缀
<android>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<permission android:protectionLevel="signature" android:name="air.com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="air.com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:enabled="true">
<receiver android:name="com.example.znotification.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="air.com.example.znotification" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="air.com.example.znotification" />
</intent-filter>
</receiver>
</application>
</manifest>
]]></manifestAdditions>
你快到了。我想你只是把AIR组件的android名称稍微弄错了。尝试下面的方法,注意一些类的air前缀
<android>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<permission android:protectionLevel="signature" android:name="air.com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="air.com.example.znotification.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:enabled="true">
<receiver android:name="com.example.znotification.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="air.com.example.znotification" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="air.com.example.znotification" />
</intent-filter>
</receiver>
</application>
</manifest>
]]></manifestAdditions>