我需要将手机中安装的所有应用程序打开到我的Android应用程序中以共享内容,我能找到一个简单的方法吗?
答案 0 :(得分:2)
我认为如果数据是文本格式的话,你可以试试这个
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"));
答案 1 :(得分:1)
你的问题不明确。但我想我得到了你的问题。
您想分享一些数据吗?
您必须使用share Intent
这是例子 -
分享文字数据 -
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"));