Android 資訊分享實現

來源:互聯網
上載者:User

標籤:

一、簡訊分享

01
Intent intent = new Intent(Intent.ACTION_SEND);
02
// intent.setType("text/plain"); //純文字
03
// 圖片分享
04
intent.setType("image/png");
05
// 添加圖片
06
File f = new File("/sdcard/sd.png");
07
Uri u = Uri.fromFile(f);
08
intent.putExtra(Intent.EXTRA_STREAM, u); //添加圖片
09
intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
10
intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");
11
startActivity(Intent.createChooser(intent, getTitle()));
二、郵件分享
 
01
Intent log = new Intent("android.intent.action.SEND");
02
Object[] arrayOfObject2 = new Object[3];
03
arrayOfObject2[0] = "nick";
04
arrayOfObject2[1] = ": ";
05
arrayOfObject2[2] = "content";
06
String str1 = String.format("@%s%s %s", arrayOfObject2);
07
String str2 = str1 + "什麼";
08
Object[] arrayOfObject1 = new Object[1];
09
arrayOfObject1[0] = str2;
10
log.putExtra("android.intent.extra.TEXT", getString(R.string.mail_body_text, arrayOfObject1));
11
log.putExtra("android.intent.extra.SUBJECT", "郵件");
12
log.setType("application/octet-stream");
13
startActivity(log);

 

Android 資訊分享實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.