【问题标题】:Android, choose my app from app chooser when click on json fileAndroid,单击 json 文件时从应用选择器中选择我的应用
【发布时间】:2019-03-21 11:35:42
【问题描述】:

我想做什么:我在文件管理器中有 json 文件,我想点击他,然后必须在列表中显示应用程序选择器和我的应用程序才能使用。我想在 MyApp 中打开 json 文件并获取数据。

Json 没有默认应用来处理他。

实际上,我使用共享。我使用长按使工具可见并使用共享 -> MyApp。

AndroidManifest.xml

    <activity android:name=".MyClassToDealWithJson">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/json" />
        </intent-filter>
    </activity>

MyClassToDealWithJson.class

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    uri = intent.getParcelableExtra(intent.EXTRA_STREAM);

    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("*/*".equals(type)) {
            //dealing with json
        }

很难找到样本,或者我没有用正确的词搜索 :) 感谢您的帮助!

【问题讨论】:

  • 我希望文件管理器使用ACTION_VIEW,而不是ACTION_SEND
  • 对于共享 ACTION_VIEW 不起作用,只有 ACTION_SEND 可以正常工作。

标签: android json file android-manifest manifest


【解决方案1】:

是的,ACTION_VIEW 效果很好。我只是没有运行代码代码,因为我的 Mainfest 有红色下划线:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多