Android調用平台功能具體技巧分享

來源:互聯網
上載者:User

Android作業系統那個可以通過調用手機平台來實現一些特定的功能,諸如網頁的顯示,郵件的發送等等。那麼今天就為大家總結了幾個Android調用平台功能的應用技巧,協助大家增加編程經驗。

Android調用平台功能之顯示網頁

 
  1. Uri uri = Uri.parse("http://google.com");   
  2. Intent it = new Intent(Intent.ACTION_VIEW, uri);   
  3. startActivity(it);   
  4. Uri uri = Uri.parse("http://google.com");   
  5. Intent it = new Intent(Intent.ACTION_VIEW, uri);   
  6. startActivity(it);  

Android調用平台功能之顯示地圖

 
  1. Uri uri = Uri.parse("geo:38.899533,-77.036476");   
  2. Intent it = new Intent(Intent.ACTION_VIEW, uri);   
  3. startActivity(it);   
  4. //其他 geo URI 範例   
  5. //geo:latitude,longitude   
  6. //geo:latitude,longitude?z=zoom   
  7. //geo:0,0?q=my+street+address   
  8. //geo:0,0?q=business+near+city   
  9. //google.streetview:cbll=lat,lng&cbp=1,yaw,,pitch,
    zoom&mz=mapZoom   
  10. Uri uri = Uri.parse("geo:38.899533,-77.036476");   
  11. Intent it = new Intent(Intent.ACTION_VIEW, uri);   
  12. startActivity(it);   
  13. //其他 geo URI 範例   
  14. //geo:latitude,longitude   
  15. //geo:latitude,longitude?z=zoom   
  16. //geo:0,0?q=my+street+address   
  17. //geo:0,0?q=business+near+city   
  18. //google.streetview:cbll=lat,lng&cbp=1,yaw,,pitch,
    zoom&mz=mapZoom 

Android調用平台功能之撥打到電話

 
  1. //叫出撥號程式   
  2. Uri uri = Uri.parse("tel:0800000123");   
  3. Intent it = new Intent(Intent.ACTION_DIAL, uri);   
  4. startActivity(it);   
  5. //直接打電話出去   
  6. Uri uri = Uri.parse("tel:0800000123");   
  7. Intent it = new Intent(Intent.ACTION_CALL, uri);   
  8. startActivity(it);   
  9. //用這個,要在 AndroidManifest.xml 中,加上   
  10. //< uses-permission id="android.permission.CALL_PHONE" />   
  11. //叫出撥號程式   
  12. Uri uri = Uri.parse("tel:0800000123");   
  13. Intent it = new Intent(Intent.ACTION_DIAL, uri);   
  14. startActivity(it);   
  15. //直接打電話出去   
  16. Uri uri = Uri.parse("tel:0800000123");   
  17. Intent it = new Intent(Intent.ACTION_CALL, uri);   
  18. startActivity(it);   
  19. //用這個,要在 AndroidManifest.xml 中,加上   
  20. //< uses-permission id="android.permission.CALL_PHONE" />  

Android調用平台功能之發送SMS/MMS

 
  1. //需寫號碼SMS   
  2. Intent it = new Intent(Intent.ACTION_VIEW);   
  3. it.putExtra("sms_body", "The SMS text");   
  4. it.setType("vnd.android-dir/mms-sms");   
  5. startActivity(it);   
  6. //發送SMS   
  7. Uri uri = Uri.parse("smsto:0800000123");   
  8. Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
  9. it.putExtra("sms_body", "The SMS text");   
  10. startActivity(it);   
  11. //發送MMS   
  12. Uri uri = Uri.parse("content://media/external
    /images/media/23");   
  13. Intent it = new Intent(Intent.ACTION_SEND);   
  14. it.putExtra("sms_body", "some text");   
  15. it.putExtra(Intent.EXTRA_STREAM, uri);   
  16. it.setType("image/png");   
  17. startActivity(it);   
  18. //需寫號碼SMS   
  19. Intent it = new Intent(Intent.ACTION_VIEW);   
  20. it.putExtra("sms_body", "The SMS text");   
  21. it.setType("vnd.android-dir/mms-sms");   
  22. startActivity(it);   
  23. //發送SMS   
  24. Uri uri = Uri.parse("smsto:0800000123");   
  25. Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
  26. it.putExtra("sms_body", "The SMS text");   
  27. startActivity(it);   
  28. //發送MMS   
  29. Uri uri = Uri.parse("content://media/external/
    images/media/23");   
  30. Intent it = new Intent(Intent.ACTION_SEND);   
  31. it.putExtra("sms_body", "some text");   
  32. it.putExtra(Intent.EXTRA_STREAM, uri);   
  33. it.setType("image/png");   
  34. startActivity(it); 

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.