AIR native Android Extension - always returning null device id

元气小坏坏 提交于 2019-12-07 22:43:14

问题


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;
    }
}

回答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.



来源:https://stackoverflow.com/questions/9232859/air-native-android-extension-always-returning-null-device-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!