将文件传递到另一个Android应用程序的问题

问题描述 投票:0回答:1

非常奇怪的行为,对于Android来说我还很陌生,但是我正在生成一些json(下面的第一行),并且我试图将其发送到清单中表示接受“ application / xctsk”类型的任何内容的应用程序。

生成的文件很好,但是应用选择器不提供该应用。我仍然可以将文件共享给Whatsapp,从内容的角度来看会很好。但是,我仍然无法从Whatsapp打开它。同时我可以

  • 手动打开文件
  • 从Whatsapp的其他来源打开其他文件

正在接收应用程序的清单

             <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="application/xctsk"
                android:host="*"/>
                <data android:scheme="http"/>
                <data android:scheme="https"/>
                <data android:scheme="content"/>
                <data android:scheme="file"/>
            </intent-filter>

我的代码

 Uri xctskURI= saveTask(somejson);
 Intent shareIntent = new Intent();
 shareIntent.setAction(Intent.ACTION_SEND);
 shareIntent.putExtra(Intent.EXTRA_STREAM, xctskURI);
 shareIntent.setType("application/xctsk");
 shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 startActivity(Intent.createChooser(shareIntent, "Send to XCTrack"));
android android-intent mime-types send
1个回答
0
投票

接收应用仅支持ACTION_VIEW。您正在使用ACTION_SEND。这些不匹配。更改发送应用程序以使用ACTION_VIEW或更改接收应用程序以使其支持ACTION_SEND

© www.soinside.com 2019 - 2024. All rights reserved.