为 android 编写本机扩展,以显示来自 github 的“更好的选择器”。为了显示这个库中的组件,我编写了 Activity extends FragmentActivity 来获取 FragmentManager。我将 android-support-v4.jar 中的类包含到我的项目中 - 没有结果,我尝试使用带有 packagedDependencies 标记的 platform.xml 将此 jar 包含到 ane 中 - 没有结果。我无法完成这项工作。
我也尝试包含
jar -uf nativepickers.jar android
android-support-v4.jar 到我的 ane jar 中。它没有帮助。我的 android-arm 的 platform.xml :
<platform xmlns="http://ns.adobe.com/air/extension/15.0">
<packagedDependencies>
<packagedDependency>android-support-v4.jar</packagedDependency>
</packagedDependencies>
<packagedResources>
</packagedResources>
</platform>
ane 编译正常,没有错误,大小 od ane 文件增加 btu 仍然我从 logcat 收到此错误:
无法解析 Lcom/insolutions/nativepickers/OpenCalendarPickerActivity 的超类;(159) 类 'Lcom/insolutions/nativepickers/OpenCalendarPickerActivity;' 的链接 失败 找不到类 'com.insolutions.nativepickers.OpenCalendarPickerActivity',引用自方法 com.insolutions.nativepickers.OpenCalendarPicker.call
我的班级 OpenCalendarPickerActivity:
package com.insolutions.nativepickers;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.doomonafireball.betterpickers.calendardatepicker.CalendarDatePickerDialog;
import com.doomonafireball.betterpickers.calendardatepicker.CalendarDatePickerDialog.OnDateSetLi stener;
public class OpenCalendarPickerActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog.newInstance(new OnDateSetListener() {
@Override
public void onDateSet(CalendarDatePickerDialog dialog, int year,
int monthOfYear, int dayOfMonth) {
Intent result = new Intent();
result.putExtra("yearUTC", year);
result.putExtra("monthUTC", monthOfYear);
result.putExtra("dateUTC", dayOfMonth);
setResult(RESULT_OK, result);
finish();
}
}, 2014, 10, 20);
calendarDatePickerDialog.show(getSupportFragmentManager(), "tag");
}
我在我的 android ane 项目中包含 jar 是这样的:fa1.jpg
我用代码开始我的活动:
package com.insolutions.nativepickers;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
public class OpenCalendarPicker implements FREFunction {
static final int SELECT_DATE_RESULT = 10001; // The request code
@Override
public FREObject call(FREContext context, FREObject[] data) {
// TODO Auto-generated method stub
Context appContext = context.getActivity().getApplicationContext();
int yearUTC = 0,monthUTC=0,dateUTC = 0;
try
{
yearUTC = data[0].getAsInt();
monthUTC = data[1].getAsInt();
dateUTC = data[2].getAsInt();
}
catch (Exception e)
{
Log.e("nativepickers", "Motyla noga!");
}
Intent intent = new Intent(appContext, OpenCalendarPickerActivity.class);
intent.putExtra("yearUTC", yearUTC);
intent.putExtra("monthUTC", monthUTC);
intent.putExtra("dateUTC", dateUTC);
context.getActivity().startActivityForResult(intent, SELECT_DATE_RESULT);
return null;
}
}
我用这个命令编译 ANE:
/Applications/Adobe\ Flash\ Builder\4.7/eclipse/plugins/com.adobe.flash.compiler_4.7.0.349722/AIRSDK/bin/adt -package -target ane NativePickers.ane extension.xml -swc NativePickers.swc -platform Android-ARM -platformoptions platform-android.xml -C android .
还有我的 extension.xml 文件:
<extension xmlns="http://ns.adobe.com/air/extension/15.0">
<id>com.insolutions.nativepickers</id>
<versionNumber>1.0.0</versionNumber>
<platforms>
<platform name="Android-ARM">
<applicationDeployment>
<nativeLibrary>nativepickers.jar</nativeLibrary>
<initializer>com.insolutions.nativepickers.NativePickers</initializer>
</applicationDeployment>
</platform>
</platforms>
</extension>
有任何想法吗?