无活动处理的意图&QUOT

无活动处理的意图&QUOT

本文介绍了Android上的AIR本机扩展安装新的APK版本抛出"无活动处理的意图"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的是安装(要求用户输入)新应用程序版本保存在SD卡为使用Adobe AIR本机扩展的.apk文件。

All I want is to install (ask user for) new application version stored on sdcard as .apk file using Adobe Air Native Extension.

下面是我的ANE功能code:

Here is my ANE function code:

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

不过,我总是得到无活动来处理意图的错误:

But I'm always getting "No activity found to handle Intent error":

无活动处理意向{行为= android.intent.action.VIEW DAT = /存储/ sdcard0 / testStorage /更新/ 1.1.apk典型值=应用/ vnd.adnroid.package归档FLG = 0x10000000处}

添加

File setupFile = new File(args[0].getAsString());
alert("Is exists?", Boolean.toString(setupFile .exists())); //output as true

据说该文件是真实的和args [0]路径是正确的。

Said that file is real and args[0] path is correct.

推荐答案

在谷歌的小时里,我发现问题是缺少文件://

After hours of google i found that the problem was in missing "file://"

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

现在一切工作正常!

这篇关于Android上的AIR本机扩展安装新的APK版本抛出&QUOT;无活动处理的意图&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:43