2

I am writing a native Android extension for a mobile AIR application. I am trying to get the device id, but the result always comes back as null. I can't figure out what I am doing wrong. Here is the native extension code (java):

import android.app.Activity;
import android.provider.Settings;
import android.provider.Settings.Secure;

import android.content.Context;
import android.content.SharedPreferences;
import android.telephony.TelephonyManager;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
import com.adobe.fre.FREWrongThreadException;

public class DeviceIdGetter extends Activity implements FREFunction {
    @Override
    public FREObject call(FREContext context, FREObject[] passedArgs) {
        FREObject result = null;

        TelephonyManager tManager = (TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

        try
        {
            result = FREObject.newObject(tManager.getDeviceId());
        }
        catch (FREWrongThreadException fwte)
        {
            try
            {
                result = FREObject.newObject("error");
            }
            catch (FREWrongThreadException fwte2)
            {
            }
            fwte.printStackTrace();
        }

        return result;
    }
}
frankhermes
  • 4,720
  • 1
  • 22
  • 39
Seth
  • 1,353
  • 1
  • 8
  • 17

1 Answers1

1

Are you using sdk4.6?

The FREObject.newObject returns an error no implementation found for native freobject, this cause context get null. I think you have copied the FlashRuntimeExtensions.jar file from sdks folder to your java project.

Try to add Adobe Flash Builder 4.x\sdks\4.xx\lib\android\FlashRuntimeExtensions.jar into your jar path.

ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53
yimogod
  • 11
  • 2
  • I am using 4.6sdk and I am using the file you mentioned..Thanks. – Seth Mar 06 '12 at 22:48
  • I'm having the same exact issue. All the tutorials I found worked for me months ago, but now with the new SDK and everything I keep getting the null error on the context. Like this answer suggests, I've actually always used an external jar path, and i'm still getting the null error. What's interesting is i'm literally using the same library projects from when i did this in the past, and im still getting the errors. Did Anyone ever find any soltions to this?? – brybam Aug 13 '12 at 20:06