欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android Intent 用法全面總結及實例代碼

 更新時間:2016年09月15日 08:52:04   作者:鑒客  
這篇文章主要介紹了Android Intent 用法全面總結的相關資料,并附實例代碼,需要的朋友可以參考下

1.調用撥號程序    

// 給移動客服10086撥打電話
Uri uri = Uri.parse("tel:10086");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);

2. 發(fā)送短信或彩信    

// 給10086發(fā)送內容為“Hello”的短信
Uri uri = Uri.parse("smsto:10086");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", "Hello");
startActivity(intent);
// 發(fā)送彩信(相當于發(fā)送帶附件的短信)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hello");
Uri uri = Uri.parse("content://media/external/images/media/23");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
startActivity(intent);

3. 通過瀏覽器打開網頁    

// 打開Google主頁
Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

4. 發(fā)送電子郵件    

// 給someone@domain.com發(fā)郵件
Uri uri = Uri.parse("mailto:someone@domain.com");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(intent);
// 給someone@domain.com發(fā)郵件發(fā)送內容為“Hello”的郵件
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, "someone@domain.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "Hello");
intent.setType("text/plain");
startActivity(intent);
// 給多人發(fā)郵件
Intent intent=new Intent(Intent.ACTION_SEND);
String[] tos = {"1@abc.com", "2@abc.com"}; // 收件人
String[] ccs = {"3@abc.com", "4@abc.com"}; // 抄送
String[] bccs = {"5@abc.com", "6@abc.com"}; // 密送
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_BCC, bccs);
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "Hello");
intent.setType("message/rfc822");
startActivity(intent);

5. 顯示地圖與路徑規(guī)劃    

// 打開Google地圖中國北京位置(北緯39.9,東經116.3)
Uri uri = Uri.parse("geo:39.9,116.3");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
// 路徑規(guī)劃:從北京某地(北緯39.9,東經116.3)到上海某地(北緯31.2,東經121.4)
Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=39.9 116.3&daddr=31.2 121.4");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

6. 播放多媒體    

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/foo.mp3");
intent.setDataAndType(uri, "audio/mp3");
startActivity(intent);
 
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

7. 拍照    

// 打開拍照程序
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(intent, 0);
// 取出照片數據
Bundle extras = intent.getExtras(); 
Bitmap bitmap = (Bitmap) extras.get("data");

8. 獲取并剪切圖片    

// 獲取并剪切圖片
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra("crop", "true"); // 開啟剪切
intent.putExtra("aspectX", 1); // 剪切的寬高比為1:2
intent.putExtra("aspectY", 2);
intent.putExtra("outputX", 20); // 保存圖片的寬和高
intent.putExtra("outputY", 40); 
intent.putExtra("output", Uri.fromFile(new File("/mnt/sdcard/temp"))); // 保存路徑
intent.putExtra("outputFormat", "JPEG");// 返回格式
startActivityForResult(intent, 0);
// 剪切特定圖片
Intent intent = new Intent("com.android.camera.action.CROP"); 
intent.setClassName("com.android.camera", "com.android.camera.CropImage"); 
intent.setData(Uri.fromFile(new File("/mnt/sdcard/temp"))); 
intent.putExtra("outputX", 1); // 剪切的寬高比為1:2
intent.putExtra("outputY", 2);
intent.putExtra("aspectX", 20); // 保存圖片的寬和高
intent.putExtra("aspectY", 40);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true); 
intent.putExtra("output", Uri.parse("file:///mnt/sdcard/temp")); 
startActivityForResult(intent, 0);

9. 打開Google Market    

// 打開Google Market直接進入該程序的詳細頁面
Uri uri = Uri.parse("market://details?id=" + "com.demo.app");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

10. 安裝和卸載程序    

Uri uri = Uri.fromParts("package", "com.demo.app", null); 
Intent intent = new Intent(Intent.ACTION_DELETE, uri); 
startActivity(intent);

11. 進入設置界面    

// 進入無線網絡設置界面(其它可以舉一反三) 
Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); 
startActivityForResult(intent, 0);

以上就是對Android Intent 的資料整理,后續(xù)繼續(xù)補充相關資料,謝謝大家對本站的支持!

相關文章

  • Android使用IntentService進行apk更新示例代碼

    Android使用IntentService進行apk更新示例代碼

    這篇文章主要介紹了Android使用IntentService進行apk更新示例代碼,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • Android 實現自定義圓形進度條的功能

    Android 實現自定義圓形進度條的功能

    這篇文章主要介紹了Android 實現自定義圓形進度條的功能的相關資料,開發(fā)Android應用的朋友肯定對自定義View不陌生,很多都有重新寫的,這里就對實現圓形進度條介紹下,需要的朋友可以參考下
    2016-11-11
  • 解析Kotlin?JSON格式

    解析Kotlin?JSON格式

    這篇文章主要介紹了Kotlin?JSON格式解析,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-03-03
  • Android  ImageView繪制圓角效果

    Android ImageView繪制圓角效果

    這篇文章主要介紹了Android ImageView繪制圓角效果,一種是使用Xfermode,另一種是BitmapShader來實現圓形和圓角的效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 優(yōu)化SimpleAdapter適配器加載效率的方法

    優(yōu)化SimpleAdapter適配器加載效率的方法

    下面小編就為大家?guī)硪黄獌?yōu)化SimpleAdapter適配器加載效率的方法。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • Android CameraX結合LibYUV和GPUImage自定義相機濾鏡

    Android CameraX結合LibYUV和GPUImage自定義相機濾鏡

    之前使用Camera實現了一個自定義相機濾鏡(Android自定義相機濾鏡 ),但是運行起來有點卡頓,這次用Camerax來實現一樣的效果發(fā)現很流暢,在此記錄一下,也希望能幫到有需要的同學
    2021-12-12
  • android繪制多個黑豎線條

    android繪制多個黑豎線條

    這篇文章主要為大家詳細介紹了android繪制多個黑豎線條,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android實現地圖軌跡的方法

    Android實現地圖軌跡的方法

    這篇文章主要為大家詳細介紹了Android實現地圖軌跡的方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • Android編程實現播放視頻的方法示例

    Android編程實現播放視頻的方法示例

    這篇文章主要介紹了Android編程實現播放視頻的方法,結合具體實例形式分析了Android使用VideoView類播放視頻的相關操作技巧與注意事項,需要的朋友可以參考下
    2017-08-08
  • Android Activity之間相互調用與傳遞參數的原理與用法分析

    Android Activity之間相互調用與傳遞參數的原理與用法分析

    這篇文章主要介紹了Android Activity之間相互調用與傳遞參數的原理與用法,較為詳細的分析了Android組件的構成以及Activity的創(chuàng)建、調用、切換等相關操作技巧,需要的朋友可以參考下
    2016-08-08

最新評論