另外,簡單的解決方案:
在ANE擴展的本地Java項目,包括 runtimeClasses.jar從AIR的lib文件夾(AIR \ LIB \機器人\ lib中),與FlashRuntimeExtension沿.jar。這使您可以訪問AIR的AndroidActivityWrapper類 。
由於runtimeClasses.jar一些接口被定義爲 保護,你需要讓他們到您的擴展訪問。所以, 創建com.adobe.air包命名空間中兩個接口:
ActivityResultCallback.java
package com.adobe.air;
import com.adobe.air.AndroidActivityWrapper;
public abstract interface ActivityResultCallback extends AndroidActivityWrapper.ActivityResultCallback
{
}
StateChangeCallback.java
package com.adobe.air;
import com.adobe.air.AndroidActivityWrapper;
public abstract interface StateChangeCallback extends AndroidActivityWrapper.StateChangeCallback
{
}
ExtensionContext。java
package com.company.extension;
import java.util.HashMap;
import java.util.Map;
import android.content.Intent;
import android.content.res.Configuration;
import com.adobe.air.ActivityResultCallback;
import com.adobe.air.AndroidActivityWrapper;
import com.adobe.air.AndroidActivityWrapper.ActivityState;
import com.adobe.air.StateChangeCallback;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
public class ExtensionContext extends FREContext implements ActivityResultCallback, StateChangeCallback
{
private AndroidActivityWrapper aaw;
public ExtensionContext() {
aaw = AndroidActivityWrapper.GetAndroidActivityWrapper();
aaw.addActivityResultListener(this);
aaw.addActivityStateChangeListner(this);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
}
@Override
public void onActivityStateChanged(ActivityState state) {
switch (state) {
case STARTED:
case RESTARTED:
case RESUMED:
case PAUSED:
case STOPPED:
case DESTROYED:
}
}
@Override
public void onConfigurationChanged(Configuration paramConfiguration)
{
}
@Override
public Map<String, FREFunction> getFunctions() {
Map<String, FREFunction> functionMap = new HashMap<String, FREFunction>();
return functionMap;
}
@Override
public void dispose() {
if (aaw!=null) {
aaw.removeActivityResultListener(this);
aaw.removeActivityStateChangeListner(this);
aaw = null;
}
}
}
無論如何,你可以詳細說明一些代碼示例?我有類似的問題。 – 2013-07-31 17:23:21