非常奇怪的行为,对于Android来说我还很陌生,但是我正在生成一些json(下面的第一行),并且我试图将其发送到清单中表示接受“ application / xctsk”类型的任何内容的应用程序。
生成的文件很好,但是应用选择器不提供该应用。我仍然可以将文件共享给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"));
接收应用仅支持ACTION_VIEW
。您正在使用ACTION_SEND
。这些不匹配。更改发送应用程序以使用ACTION_VIEW
或更改接收应用程序以使其支持ACTION_SEND
。