導航:首頁 > 操作系統 > androidnewintent

androidnewintent

發布時間:2023-07-09 07:10:08

『壹』 android開發intent怎麼傳遞集合

1、Intent(意圖)主要是解決Android應用的各項組件之間的通訊。
2、為了實現傳遞數據這個目的需要以下步驟
3、Activity1需要構造一個 Intent,這個Intent用於告訴系統,我們要做「查看」動作
intent可調用putExtra來存放想要傳遞的數據
4、然後調用setClass,設置Activity1和欲調用的組件Activity2
5、最後調用startActivity將構造的Intent傳入,系統會根據此Intent中的描述,到Activity1中找到滿足此Intent要求的Activity,系統會調用找到的 Activity2最終傳入Intent在Activity2中可使用getIntent來獲取傳遞的Intent,並通過獲取數據的方法來獲取數據代碼示例:
Intent intent = new Intent(); // Activity1
intent.putExtra("one", num1);
intent.putExtra("two", num2);
intent.setClass(FirstActivity.this, SecondActivity.class);
startActivity(intent); Intent intent = getIntent(); //Activity2
String num1 = intent.getStringExtra("one");
String num2 = intent.getStringExtra("two");
int ret = Integer.parseInt(num1) + Integer.parseInt(num2);
result.setText(ret+"");
注意:在使用intent的時候可以使用bundle傳遞復制的數據類型。

『貳』 如何指定Android中的瀏覽器跳轉界面

一、啟動android默認瀏覽器

在Android程序中我們可以通過發送隱式Intent來啟動系統默認的瀏覽器。如果手機本身安裝了多個瀏覽器而又沒有設置默認瀏覽器的話,系統將讓用戶選擇使用哪個瀏覽器來打開連接。關於Intent的更多內容請參考《常用Intent》

示例1

Intent intent =newIntent();

        intent.setAction("android.intent.action.VIEW");

        Uri content_url =Uri.parse("http://www.163.com");

        intent.setData(content_url);

        startActivity(intent);

這樣子,android就可以調用起手機默認的瀏覽器訪問。

二、啟動指定瀏覽器

在Android程序中我們可以通過發送顯式Intent來啟動指定的瀏覽器。

啟動Android原生瀏覽器

示例2

Intent intent =newIntent();       

        intent.setAction("android.intent.action.VIEW");   

        Uri content_url =Uri.parse("http://www.163.com"); 

        intent.setData(content_url);         

        intent.setClassName("com.android.browser","com.android.browser.BrowserActivity"); 

        startActivity(intent);

只要修改以intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");

中相應的應用程序packagename 和要啟動的activity即可啟動其他瀏覽器來

uc瀏覽器":"com.uc.browser", "com.uc.browser.ActivityUpdate「

opera瀏覽器:"com.opera.mini.android", "com.opera.mini.android.Browser"

qq瀏覽器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"

閱讀全文

與androidnewintent相關的資料

熱點內容
資料庫查詢系統源碼 瀏覽:617
php5314 瀏覽:358
完美國際安裝到哪個文件夾 瀏覽:669
什麼app可以掃一掃做題 瀏覽:540
程序員編碼論壇 瀏覽:924
淘點是什麼app 瀏覽:660
中國高等植物pdf 瀏覽:454
51單片機時間 瀏覽:182
後台如何獲取伺服器ip 瀏覽:267
單片機流水燈程序c語言 瀏覽:236
程序員第二職業掙錢 瀏覽:240
運行里怎麼輸入伺服器路徑 瀏覽:843
pythonstepwise 瀏覽:512
劉一男詞彙速記指南pdf 瀏覽:66
php認證級別 瀏覽:371
方舟編譯啥時候推送 瀏覽:1012
php手機驗證碼生成 瀏覽:677
哲學思維pdf 瀏覽:17
凌達壓縮機有限公司招聘 瀏覽:535
weblogic命令部署 瀏覽:39