Java 如何从我的应用程序打开已安装的应用程序以共享内容
我需要将手机中安装的所有应用程序打开到我的android应用程序中以共享内容,我能找到一个简单的方法吗?你的问题不清楚。但我想我明白你的问题了 你想分享一些数据吗 您必须使用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
共享意图
以下是示例-
共享文本数据-
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想要什么。所以我给出了答案,那个就是最好打旗子。