我想要的是使用Adobe Air Native Extension安装(询问用户)存储在SD卡上的新应用程序版本为.apk文件。
这是我的ANE功能代码:
@Override
//args[0] is the path to local stored apk (logs as /storage/sdcard0/testStorage/updates/1.1apk)
public FREObject call(FREContext _context, FREObject[] args) {
context = _context;
try {
Intent promptInstall = new Intent(Intent.ACTION_VIEW);
promptInstall.setDataAndType(Uri.parse(args[0].getAsString()), "application/vnd.android.package-archive");
promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.getActivity().startActivity(promptInstall);
alert("Okay", "start was!"); //using AlertDialog for debug purpose
} catch (Exception e) {
alert("Error!", e.getLocalizedMessage());
e.printStackTrace();
}
return null;
}
这是显而易见的我使用:
<android>
<manifestAdditions><![CDATA[<manifest android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<application android:hardwareAccelerated="true" />
<application android:debuggable="true"/>
<application>
<activity android:name="android.intent.action.VIEW">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch" />
</manifest>]]></manifestAdditions>
</android>
但我总是得到&#34;没有发现任何活动来处理意图错误&#34;:
找不到处理Intent的活动{act = android.intent.action.VIEW dat = / storage / sdcard0 / testStorage / updates / 1.1.apk typ = application / vnd.adnroid.package-archive flg = 0x10000000}
加
File setupFile = new File(args[0].getAsString());
alert("Is exists?", Boolean.toString(setupFile .exists())); //output as true
表示文件是真实的,args [0]路径是正确的。
答案 0 :(得分:1)
经过几个小时的谷歌我发现问题已经丢失&#34; file://&#34;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + args[0].getAsString()), "application/vnd.android.package-archive");
现在一切正常!