安卓通过Intent分享

private void sendWithChosenClient() {


        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // for sms/mms only
        sendIntent.putExtra("address", "10086");
        sendIntent.putExtra("sms_body", "See attached picture");
       // for email only
        String[] mailto = {"[email protected]"};                
        sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT,"sendEmail2");
        sendIntent.putExtra(Intent.EXTRA_TEXT,"sendEmail2 Text");
        // attachment
        String fileName = Environment.getExternalStorageDirectory().toString() 
                + File.separator + "000.jpg" ;
        String url = "file://" + fileName;
        sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
        sendIntent.setType("image/png");
        startActivity(Intent.createChooser(sendIntent,"请选择"));


}


效果图如下啊!

你可能感兴趣的:(安卓通过Intent分享)