2016年3月28日星期一

系统分享代码

String type = "image/*";String filename = "/dog.jpg";String mediaPath = Environment.getExternalStorageDirectory() + filename;


createInstagramIntent(type, mediaPath);

private void createInstagramIntent(String type, String mediaPath){

    // Create the new Intent using the 'Send' action.    Intent share = new Intent(Intent.ACTION_SEND);
    // Set the MIME type    share.setType(type);
    // Create the URI from the media    File media = new File(mediaPath);    Uri uri = Uri.fromFile(media);
    // Add the URI to the Intent.    share.putExtra(Intent.EXTRA_STREAM, uri);
    // Broadcast the Intent.    startActivity(Intent.createChooser(share, "Share to"));}

使用此方法弹出的是 系统中可以分享的代码

没有评论:

发表评论