Note that there are some explanatory texts on larger screens.

plurals
  1. POGCM air extension
    text
    copied!<p>I'm building an air extension and the very first method to call on my extention is to check if </p> <pre><code>GCMRegistrar.checkDevice($context.getActivity()); GCMRegistrar.checkManifest($context.getActivity()); </code></pre> <p>are supported and set, so wrote: CheckGcm.java</p> <pre><code>package com.doitflash.air.extensions.gcm; import com.adobe.fre.FREContext; import com.adobe.fre.FREFunction; import com.adobe.fre.FREInvalidObjectException; import com.adobe.fre.FREObject; import com.adobe.fre.FRETypeMismatchException; import com.adobe.fre.FREWrongThreadException; import com.google.android.gcm.GCMConstants; import com.google.android.gcm.GCMRegistrar; public class CheckGcm implements FREFunction { private String _result; public FREObject call(FREContext $context, FREObject[] $params) { //$context.dispatchStatusEventAsync("variable", "value"); try { GCMRegistrar.checkDevice($context.getActivity()); GCMRegistrar.checkManifest($context.getActivity()); _result = "true"; } catch(Exception err) { _result = "false"; } return as3ConvertValue(_result); } private FREObject as3ConvertValue(String $value) { try { return FREObject.newObject($value); } catch (FREWrongThreadException e) { return null; } } } </code></pre> <p>and I setup the android manifest like this:</p> <pre><code>&lt;manifestAdditions&gt;&lt;![CDATA[&lt;manifest android:installLocation="auto"&gt; &lt;permission android:name="air.air.com.doitflash.SampleApp.permission.C2D_MESSAGE" android:protectionLevel="signature" /&gt; &lt;uses-permission android:name="air.air.com.doitflash.SampleApp.permission.C2D_MESSAGE" /&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; &lt;application&gt; &lt;activity&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;receiver android:enabled="true" android:exported="true" android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" &gt; &lt;intent-filter&gt; &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt; &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt; &lt;category android:name="air.air.com.doitflash.SampleApp" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:enabled="true" android:exported="true" android:name="com.doitflash.air.extensions.gcm.GCMIntentService" /&gt; &lt;/application&gt; &lt;/manifest&gt;]]&gt;&lt;/manifestAdditions&gt; </code></pre> <p>I have also setup GCMIntentService:</p> <pre><code>package com.doitflash.air.extensions.gcm; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.util.Log; import android.widget.Toast; import com.google.android.gcm.GCMBaseIntentService; public class GCMIntentService extends GCMBaseIntentService { private static final String TAG = "===GCMIntentService==="; public GCMIntentService() { super("000000"); // senderID } @Override protected void onRegistered(Context arg0, String registrationId) { } @Override protected void onUnregistered(Context arg0, String arg1) { } @Override protected void onMessage(Context arg0, Intent arg1) { //Log.i(TAG, "notification title = " + arg1.getStringExtra("title")); //Log.i(TAG, "notification message = " + arg1.getStringExtra("msg")); //Log.i(TAG, "notification type = " + arg1.getStringExtra("type")); //Log.i(TAG, "notification id= " + arg1.getStringExtra("id")); } @Override protected void onError(Context arg0, String errorId) { } @Override protected boolean onRecoverableError(Context context, String errorId) { return super.onRecoverableError(context, errorId); } } </code></pre> <p>everything looks fine in my eyes but when I try tracing the check method in my air project, it returns null! so I know there must be something wrong with:</p> <pre><code>GCMRegistrar.checkDevice($context.getActivity()); GCMRegistrar.checkManifest($context.getActivity()); </code></pre> <p>because when I remove these two lines, the trace in air returns true. just before starting to build the air extension, I built a sample GCM in java and everything was working perfectly but I don't seem to understand why the air version does not work. any ideas?</p> <p>UPDATE: I used eclipse logcat to see what is happening on my phone and this may be some hints:</p> <pre><code>Could not find method com.google.android.gcm.GCMRegistrar.checkDevice, referenced from method com.doitflash.air.extensions.gcm.CheckGcm.call unable to resolve static method 284: Lcom/google/android/gcm/GCMRegistrar;.checkDevice (Landroid/content/Context;)V </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload