2016-07-07 83 views
0

如何检测从(任意)的外部应用程序(或packagname)数据共享:Android的 - 意向共享

通过共用从另一个应用程序的图像/数据(意向)到我的应用程序(活动),

+0

请详细解释一下,让人们可以理解你在说什么 – Jas

+0

AFAIK,这是不支持的。 – CommonsWare

+0

没有解决方法? – FadyAro

回答

0
private void shareImage() { 
    Intent share = new Intent(Intent.ACTION_SEND); 

    // If you want to share a png image only, you can do: 
    // setType("image/png"); OR for jpeg: setType("image/jpeg"); 
    share.setType("image/*"); 

    // Make sure you put example png image named myImage.png in your 
    // directory 
    String imagePath = Environment.getExternalStorageDirectory() 
      + "/myImage.png"; 

    File imageFileToShare = new File(imagePath); 

    Uri uri = Uri.fromFile(imageFileToShare); 
    share.putExtra(Intent.EXTRA_STREAM, uri); 

    startActivity(Intent.createChooser(share, "Share Image!")); 
}