java – Adob​​e AIR 3.1 Android的Native Extension – 在ActionScript中的null扩展上下文

前端之家收集整理的这篇文章主要介绍了java – Adob​​e AIR 3.1 Android的Native Extension – 在ActionScript中的null扩展上下文前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Android平台的Native Extension,我被卡住了

针对Android 2.1 …在Google Nexus One上进行测试(2.3.6)

此行返回NULL

this.context = ExtensionContext.createExtensionContext("com.company.ane.LocationManager","");

这是扩展描述符文件

<extension xmlns="http://ns.adobe.com/air/extension/3.1">
<id>com.company.ane.LocationManager</id>
<versionNumber>0.0.1</versionNumber>
<platforms>
<platform name="iPhone-ARM">
  <applicationDeployment>
    <nativeLibrary>libANELocationManager.a</nativeLibrary>
    <initializer>ExtInitializer</initializer>
    <finalizer>ExtFinalizer</finalizer>
  </applicationDeployment>
</platform>
<platform name="Android-ARM">
<applicationDeployment>         
   <nativeLibrary>libANELocationManager.jar</nativeLibrary>
     <initializer>com.company.ane.android.ANELocationManager</initializer>
</applicationDeployment> 
       </platform></platforms></extension>

这是我的包命令:

adt -package -target ane ./../../app/libs/locationmanager.ane ./../extension.xml -swc ane_location_manager.swc -platform iPhone-ARM library.swf libANELocationManager.a -platform Android-ARM library.swf libANELocationManager.jar

在这个阶段扩展真的很简单…我只是想把字符串值返回到我的应用程序…

package com.company.ane.android;

import java.util.HashMap;
import java.util.Map;

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

import android.location.LocationListener;
import android.location.LocationManager;

public class ANELocationManagerContext extends FREContext {

public LocationManager locationManager;
public LocationListener locationListener;

@Override
public void dispose() {
    // TODO Auto-generated method stub

}

@Override
public Map<String,FREFunction> getFunctions() {

    Map<String,FREFunction> functionMap = new HashMap<String,FREFunction>();

    functionMap.put("ExtensionTest",new ExtensionTest());

    return functionMap;
}

    }


 package com.company.ane.android;

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

public class ExtensionTest implements FREFunction {

@Override
public FREObject call(FREContext context,FREObject[] args) {

    FREObject result = null;
    //ANELocationManagerContext ctx = (ANELocationManagerContext) context;


    try 
    {
        result  = FREObject.newObject("It works!");  

    }
    catch (FREWrongThreadException fwte)
    {
        fwte.printStackTrace();
    }

    return result;
}

 }


package com.company.ane.android;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREExtension;

public class ANELocationManager implements FREExtension {

@Override
public FREContext createContext(String contextType) {

    return new ANELocationManagerContext();
}

@Override
public void dispose() {
    // TODO Auto-generated method stub

}

@Override
public void initialize() {
    // TODO Auto-generated method stub

}

}

解决方法

我有完全一样的问题.
我的ANE在iOS上运行正常,在模拟器上使用默认的lib,但在实际的Android设备(Android-ARM平台)上没有工作.

而ExtensionContext.createExtensionContext()返回null.

原来这个问题是工具版本问题,Java编译器版本.我正在使用最新的AIR(3.8),JDK(1.7.25),Android SDK(22.0.5)等.它没有起作用.

但是在将目标1.6添加到javac调用之后,它运行良好.

原文链接:https://www.f2er.com/java/121897.html

猜你在找的Java相关文章