且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与Android应用程序中的内容提供商共享图像

更新时间:2023-11-22 19:11:28

正如@Sun Ning-s的注释所指出的那样,某些共享目标应用程序"可以处理以"content://.."开头的URI-s.

As @Sun Ning-s comment noted some "share target apps" can handle URI-s starting with "content://.." which you have implemented.

其他应用处理以"file://...."开头的文件uri-s,因此您必须实现第二个共享菜单共享为文件"

Other apps handle file uri-s starting with "file://...." so you have to implement a 2nd share menue "share as file"

private Intent getFileShareIntent(String fullPathTofile) {
    final Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("image/jpeg");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + fullPathTofile));
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    return shareIntent;
}

您可以使用 Android应用程序intentintercept 来查找其他共享源应用"所提供的内容.

You can use the android app intentintercept to find out what other "share source apps" provide.