【问题标题】:How To Test for Android File Chooser Availability如何测试 Android 文件选择器的可用性
【发布时间】:2015-01-20 03:48:14
【问题描述】:

我正在尝试测试文件选择器的可用性。我假设如果没有可用的错误将返回,但是,事实并非如此。

这是我的代码:

public void doImport() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("file/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        try {
            startActivityForResult(Intent.createChooser(intent, "Select a File to Import"), IMPORT_RACES_CODE);
            } catch (android.content.ActivityNotFoundException ex) {
                // Potentially direct the user to the Market with a Dialog
                Utils.Error(this, "THERE WAS NO NAVIGATOR FOUND, Install a navigator!");
            } catch (Exception e) {
                Utils.Error(this, "Some other error occurred!");
        }
    }

不过,没有异常被发送回我的例程。操作系统似乎正在处理错误并生成一个对话框,说明“没有应用程序可以执行此操作。”

知道我在这里做错了什么吗?

谢谢!

【问题讨论】:

    标签: android-afilechooser


    【解决方案1】:

    其实在这个帖子里找到了答案:

    Android : Can I use this intent from a 3rd party application?

    查看响应者发布的“isIntentAvailable”例程。

    谢谢大家!

    【讨论】:

      猜你喜欢
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-11
      • 2018-07-29
      • 2014-11-12
      • 1970-01-01
      相关资源
      最近更新 更多