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

问题描述:

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

+0

你想打开哪个App?你必须知道它的包名来打开它 –

+0

安装的是Android手机 – kinginisreelu

+0

可能的复制所有的应用[如何获得安装Android应用程序的列表,并选择一个运行(http://*.com/questions/2695746/如何获取安装列表的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")); 

你的问题不清楚。但我想我有你的问题。

你想分享一些数据吗?

,你必须使用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")); 
+0

如果问题不清楚,请标记为,不要回答。我可能会以不同的方式阅读和理解,并给出完全不同的答案。 – Adriaan

+0

@Adriaan你是对的,但我明白什么是希望。所以我给了答案,这更好地标志。 –