日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

精通Android开发 1

發(fā)布時(shí)間:2023/12/15 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 精通Android开发 1 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

intent 概括?

Android引入了一個(gè)intent的概念來調(diào)用組件。

Android的活動組件包括活動(UI組件),服務(wù),廣播,和contentProvider

簡單層面上將,intent就是告訴你android要執(zhí)行的一種操作。

?一般來說我們經(jīng)常的用法是這樣的

intent = new Intent(this,Install.class); startActivity(intent);

this表示這個(gè)activity的上下文,install.class表示要跳轉(zhuǎn)的activity。當(dāng)然了,這個(gè)activity必須也要在Androidmanifast

今天看到書上的另外一種用法:

String actionName= "com.androidbook.intent.action.ShowBasicView";Intent intent = new Intent(actionName);activity.startActivity(intent);
  • 操作名字一般約定為<包名>.intent.action
  • Android中經(jīng)常使用intent的地方:

    打開瀏覽器,

    呼叫電話號碼

    打開地圖

    1 //打開一個(gè)瀏覽器,手機(jī)有多的瀏覽器的話,彈出選擇框 2 public static void invokeWebBrowser(Activity activity) 3 { 4 Intent intent = new Intent(Intent.ACTION_VIEW); 5 intent.setData(Uri.parse("http://www.google.com")); 6 activity.startActivity(intent); 7 } 8 9 public static void invokeWebSearch(Activity activity) 10 { 11 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); 12 intent.setData(Uri.parse("http://www.google.com")); 13 activity.startActivity(intent); 14 } 15 public static void dial(Activity activity) 16 { 17 Intent intent = new Intent(Intent.ACTION_DIAL); 18 activity.startActivity(intent); 19 } 20 21 public static void call(Activity activity) 22 { 23 Intent intent = new Intent(Intent.ACTION_CALL); 24 intent.setData(Uri.parse("tel:904-905-5646")); 25 activity.startActivity(intent); 26 } 27 public static void showMapAtLatLong(Activity activity) 28 { 29 Intent intent = new Intent(Intent.ACTION_VIEW); 30 //geo:lat,long?z=zoomlevel&q=question-string 31 intent.setData(Uri.parse("geo:0,0?z=4&q=business+near+city")); 32 activity.startActivity(intent); 33 }

    ?

    intent的組成

    uri

    目前我們只是介紹了簡單的intent。在呼叫電話的intent中,還要接受一個(gè)名為Data的參數(shù),該參數(shù)指向一個(gè)uri。

    ?這個(gè)uri指向了所撥的電話號碼

    ?

    使用extra信息

    extra數(shù)據(jù)以key-value。

    getExtras獲取intent中包涵的bundle。

    putExtras檢查intent中是否包涵有包,有的話,加上,沒有的話,創(chuàng)建。

    還可以添加一些復(fù)制的extra數(shù)據(jù)。

    5 intent的類別:

    Android會尋找類別被標(biāo)記為Category_launcher的活動。然后跳出這些活動名和圖標(biāo)。

    安全功能軟件。

    6 使用action_pick

    目前我們都是使用intent來操作或者調(diào)用另外的一個(gè)活動,沒有返回結(jié)果,那么我們現(xiàn)在使用action_pick試試。

    action_pick的理念是啟動一個(gè)活動來顯示列表,允許用戶從中選擇一個(gè)。用戶挑選了一會,活動

    應(yīng)該向調(diào)用方法返回挑選的uRi。

    ?

    startActivity()無法返回結(jié)果,因它是在一個(gè)獨(dú)立線程中以模擬對話框的形式打開新的活動,將主線程留給主要的事件。

    使用startActivityForRest().

    get_content

    對于action_get_content,你向Android表明你需要一個(gè)具有特定MIME類型的項(xiàng)。

    掛起intent

    http://www.cnblogs.com/feisky/archive/2010/01/16/1649081.html

    轉(zhuǎn)載于:https://www.cnblogs.com/aosting/p/3477403.html

    總結(jié)

    以上是生活随笔為你收集整理的精通Android开发 1的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。