我正在为移动 AIR 应用程序编写原生 Android 扩展。我正在尝试获取设备 ID,但结果总是返回为空。我无法弄清楚我做错了什么。这是本机扩展代码(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;
}
}