本文介绍了AIR Android原生扩展 - 总是返回空设备ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我写了一个移动AIR应用程序原生Android扩展。我试图让设备ID,但结果总是回来空。我想不出什么我做错了。这里是原生扩展code(JAVA):

 进口android.app.Activity;
进口android.provider.Settings;
进口android.provider.Settings.Secure;进口android.content.Context;
进口android.content.Shared preferences;
进口android.telephony.TelephonyManager;进口com.adobe.fre.FREContext;
进口com.adobe.fre.FREFunction;
进口com.adobe.fre.FREObject;
进口com.adobe.fre.FREWrongThreadException;公共类DeviceIdGetter扩展活动实现FREFunction {
    @覆盖
    公共FREObject调用(FREContext背景下,FREObject [] passedArgs){
        FREObject结果= NULL;        TelephonyManager tManager =(TelephonyManager)getBaseContext()getSystemService(Context.TELEPHONY_SERVICE)。        尝试
        {
            结果= FREObject.newObject(tManager.getDeviceId());
        }
        赶上(FREWrongThreadException fwte)
        {
            尝试
            {
                结果= FREObject.newObject(错误);
            }
            赶上(FREWrongThreadException fwte2)
            {
            }
            fwte.printStackTrace();
        }        返回结果;
    }
}


解决方案

您使用sdk4.6?

FREObject.newObject 返回一个错误没有发现本地freobject 的实施,这项事业方面的get
我想你已经从复制的SDK的 FlashRuntimeExtensions.jar 文件夹到你的Java项目。

尝试添加的Adobe Flash Builder的 4.x版\\的SDK \\ 4.XX \\ lib目录\\机器人\\ FlashRuntimeExtensions.jar 进入你的jar路径。

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;
    }
}
解决方案

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.

这篇关于AIR Android原生扩展 - 总是返回空设备ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:32