Android編程實(shí)現(xiàn)調(diào)用系統(tǒng)分享功能示例
本文實(shí)例講述了Android編程實(shí)現(xiàn)調(diào)用系統(tǒng)分享功能。分享給大家供大家參考,具體如下:
/**
* 調(diào)用系統(tǒng)的分享功能
* Created by admin on 15-4-13.
*/
public class ShareActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share_layout);
}
//分享文字
public void shareText(View view) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my Share text.");
shareIntent.setType("text/plain");
//設(shè)置分享列表的標(biāo)題,并且每次都顯示分享列表
startActivity(Intent.createChooser(shareIntent, "分享到"));
}
//分享單張圖片
public void shareSingleImage(View view) {
String imagePath = Environment.getExternalStorageDirectory() + File.separator + "test.jpg";
//由文件得到uri
Uri imageUri = Uri.fromFile(new File(imagePath));
Log.d("share", "uri:" + imageUri); //輸出:file:///storage/emulated/0/test.jpg
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享到"));
}
//分享多張圖片
public void shareMultipleImage(View view) {
ArrayList<Uri> uriList = new ArrayList<>();
String path = Environment.getExternalStorageDirectory() + File.separator;
uriList.add(Uri.fromFile(new File(path+"australia_1.jpg")));
uriList.add(Uri.fromFile(new File(path+"australia_2.jpg")));
uriList.add(Uri.fromFile(new File(path+"australia_3.jpg")));
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享到"));
}
}
頁面效果:

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android開發(fā)動(dòng)畫技巧匯總》、《Android布局layout技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- 詳解微信小程序開發(fā)—你期待的分享功能來了,微信小程序序新增5大功能
- 網(wǎng)頁上facebook分享功能具體實(shí)現(xiàn)
- JS中靜態(tài)頁面實(shí)現(xiàn)微信分享功能
- 微信JS-SDK自定義分享功能實(shí)例詳解【分享給朋友/分享到朋友圈】
- Android ShareSDK快速實(shí)現(xiàn)分享功能
- Android 微信圖片分享功能
- Android調(diào)用系統(tǒng)自帶的分享功能實(shí)例代碼
- 詳解Android系統(tǒng)中跨應(yīng)用數(shù)據(jù)分享功能的實(shí)現(xiàn)
- Android實(shí)現(xiàn)截圖和分享功能的代碼
- 關(guān)于Android實(shí)現(xiàn)簡(jiǎn)單的微信朋友圈分享功能
- Android實(shí)現(xiàn)調(diào)用系統(tǒng)分享功能示例的總結(jié)
相關(guān)文章
Android 點(diǎn)擊生成二維碼功能實(shí)現(xiàn)代碼
二維碼,我們也稱作QRCode,QR表示quick response即快速響應(yīng),在很多App中我們都能見到二維碼的身影,最常見的莫過于微信了。接下來給大家介紹android 點(diǎn)擊生成二維碼功能實(shí)現(xiàn)代碼,需要的朋友參考下吧2017-11-11
Android 沉浸式改變小米魅族狀態(tài)欄顏色的實(shí)例代碼
這篇文章主要介紹了Android 沉浸式改變小米魅族狀態(tài)欄顏色的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02
Android界面 NotificationManager使用Bitmap做圖標(biāo)
Android界面 NotificationManager使用Bitmap做圖標(biāo),如何實(shí)現(xiàn)呢,本文將介紹解決方法,需要的朋友可以參考下2012-12-12
Android 彈出Dialog時(shí)隱藏狀態(tài)欄和底部導(dǎo)航欄的方法
這篇文章主要介紹了Android 彈出Dialog時(shí)隱藏狀態(tài)欄和底部導(dǎo)航欄的實(shí)例代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07
Flutter Http分塊下載與斷點(diǎn)續(xù)傳的實(shí)現(xiàn)
這篇文章主要介紹了Flutter Http分塊下載與斷點(diǎn)續(xù)傳的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
Android App支付系列(二):支付寶SDK接入詳細(xì)指南(附官方支付demo)
本篇文章介紹了Android App支付系列(二):支付寶SDK接入詳細(xì)指南(附官方支付demo) ,有興趣的同學(xué)可以了解一下。2016-11-11
Android中ListView + CheckBox實(shí)現(xiàn)單選、多選效果
這篇文章主要介紹了Android中ListView + CheckBox實(shí)現(xiàn)單選、多選效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02
Kotlin StateFlow單數(shù)據(jù)更新熱流設(shè)計(jì)與使用介紹
StateFlow當(dāng)值發(fā)生變化,就會(huì)將值發(fā)送出去,下流就可以接收到新值。在某些場(chǎng)景下,StateFlow比LiveData更適用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2022-09-09

