zhaochunqi
5/25/2014 - 3:19 AM

利用Intent分享。

利用Intent分享。

  public void shareTo(View view) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        File file = new File("/storage/sdcard0/DCIM/100_CFV5/DSC_0005.JPG");//写死了一个地址。
//        intent.setType("text/plain;image/*");
//        intent.putExtra(Intent.EXTRA_SUBJECT,"分享");
//        intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");
//        intent.putExtra(Intent.);
//        Intent sendIntent = new Intent();
//        sendIntent.setAction(Intent.ACTION_SEND);
//        sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
//        sendIntent.setType("text/plain");
//        startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
        intent.setType("image/*,text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT,"分享");
        intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");
        intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file));
        String title = getResources().getString(R.string.chooser_title);
        Intent chooser = Intent.createChooser(intent, title);
        startActivity(chooser);