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é)》
希望本文所述對大家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)簡單的微信朋友圈分享功能
- Android實(shí)現(xiàn)調(diào)用系統(tǒng)分享功能示例的總結(jié)
相關(guān)文章
詳解Android實(shí)現(xiàn)定時(shí)器的幾種方法
本篇文章主要介紹了詳解Android實(shí)現(xiàn)定時(shí)器的幾種方法,主要包括了Handler, Timer, Thread, AlarmManager,有興趣的可以了解一下2017-09-09
Android 讀取sdcard上的圖片實(shí)例(必看)
下面小編就為大家?guī)硪黄狝ndroid 讀取sdcard上的圖片實(shí)例(必看)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-03-03
Android Studio 3.1.3升級至3.6.1后舊項(xiàng)目的兼容操作方法
這篇文章主要介紹了Android Studio 3.1.3升級至3.6.1后舊項(xiàng)目的兼容操作方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03
Android獲取assets文件夾中的數(shù)據(jù)并寫入SD卡示例
這篇文章主要介紹了Android獲取assets文件夾中的數(shù)據(jù)并寫入SD卡示例,對初學(xué)Android開發(fā)的朋友來說是一個(gè)很實(shí)用的功能,需要的朋友可以參考下2014-07-07
Android實(shí)現(xiàn)短信驗(yàn)證碼自動(dòng)攔截讀取功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)短信驗(yàn)證碼自動(dòng)攔截讀取功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-08-08
Android通過手機(jī)拍照或從本地相冊選取圖片設(shè)置頭像
微信、QQ、微博等社交類APP如何更換自己的頭像,這篇文章主要介紹了Android通過手機(jī)拍照或從本地相冊選取圖片設(shè)置頭像,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
Android自定義ListView實(shí)現(xiàn)下拉刷新
這篇文章主要為大家詳細(xì)介紹了Android自定義ListView實(shí)現(xiàn)下拉刷新的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07
Flutter?StreamBuilder實(shí)現(xiàn)局部刷新實(shí)例詳解
這篇文章主要為大家介紹了Flutter?StreamBuilder實(shí)現(xiàn)局部刷新實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08

