Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从我的应用程序打开已安装的应用程序以共享内容_Java_Android_Share Intent - Fatal编程技术网

Java 如何从我的应用程序打开已安装的应用程序以共享内容

Java 如何从我的应用程序打开已安装的应用程序以共享内容,java,android,share-intent,Java,Android,Share Intent,我需要将手机中安装的所有应用程序打开到我的android应用程序中以共享内容,我能找到一个简单的方法吗?你的问题不清楚。但我想我明白你的问题了 你想分享一些数据吗 您必须使用共享意图 以下是示例- 共享文本数据- Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Here is the sh

我需要将手机中安装的所有应用程序打开到我的android应用程序中以共享内容,我能找到一个简单的方法吗?

你的问题不清楚。但我想我明白你的问题了

你想分享一些数据吗

您必须使用
共享意图

以下是示例-

共享文本数据-

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
共享图像

String fileName = "image-3116.jpg";//Name of an image
String externalStorageDirectory =     Environment.getExternalStorageDirectory().toString();
String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images
Uri uri = Uri.parse("file:///" + myDir + fileName);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/html");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share Deal"));

如果数据是文本格式的,我想你可以试试这个

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);

    sharingIntent.setType("text/plain");
    String shareBody = "Here is the share content body";

    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);


    startActivity(Intent.createChooser(sharingIntent, "Share via"));

你想打开哪个应用程序?你必须知道它的软件包名称,才能打开安卓手机上安装的所有应用程序。如果问题不清楚,请标记为“不回答”。我可能会以不同的方式阅读和理解它,并给出完全不同的答案。@Adrian你是对的,但我理解sree想要什么。所以我给出了答案,那个就是最好打旗子。