gpt4 book ai didi

java - Android Air Native Extension 安装新的 apk 版本抛出 "no activity found to handle intent"

转载 作者:行者123 更新时间:2023-12-01 12:41:32 24 4
gpt4 key购买 nike

我想要的只是使用 Adob​​e Air Native Extension 安装(询问用户)以 .apk 文件形式存储在 SD 卡上的新应用程序版本。

这是我的 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;
}

这是我正在使用的 list :

 <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>

但我总是收到“找不到处理 Intent 错误的 Activity ”:

No Activity found to handle 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]路径是正确的。

最佳答案

经过几个小时的谷歌,我发现问题出在缺少“file://”

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + args[0].getAsString()), "application/vnd.android.package-archive");

现在一切正常!

关于java - Android Air Native Extension 安装新的 apk 版本抛出 "no activity found to handle intent",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25053598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com