国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

給網(wǎng)站添加百度地圖百度關(guān)鍵字優(yōu)化價(jià)格

給網(wǎng)站添加百度地圖,百度關(guān)鍵字優(yōu)化價(jià)格,個(gè)人網(wǎng)站怎么辦理,和15歲女兒做很舒服網(wǎng)站概述 在Android中,Intent是各個(gè)組件之間信息通信的橋梁,它用于Android各組件的通信。 Intent 的組成部分 一、顯式 Intent 第一種方式 Intent intent new Intent(this, ActFinishActivity.class);startActivity(intent);第二種方式 Intent intent …

概述

在Android中,Intent是各個(gè)組件之間信息通信的橋梁,它用于Android各組件的通信。

Intent 的組成部分
在這里插入圖片描述

一、顯式 Intent

第一種方式

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

第二種方式

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

第三種方式

    Intent intent = new Intent();ComponentName componentName = new ComponentName(this, ActFinishActivity.class);intent.setComponent(componentName);startActivity(intent);

可以看出第一、二種比較簡(jiǎn)單且相似,但是這兩種方式都需要獲取到要跳轉(zhuǎn)的類。如果要跳到其他應(yīng)用就不行了,用 ComponentName 這種方式可以解決,如下:

    ComponentName componentName = new ComponentName("com.example.study_android", "com.example.study_android.ActFinishActivity");

二、隱式 Intent

隱式 Intent 沒有明確指定要跳轉(zhuǎn)的目標(biāo)活動(dòng),只給出一個(gè)動(dòng)作字符串讓系統(tǒng)自動(dòng)匹配,屬于模糊匹配。

  • 常見系統(tǒng)動(dòng)作的取值說明
    在這里插入圖片描述
    動(dòng)作名既可以通過 setAction 方法指定,也可以通過構(gòu)造函數(shù) Intent(String action) 直接生成意圖對(duì)象。
  • 跳轉(zhuǎn)到撥號(hào)系統(tǒng)應(yīng)用
    private void handleNavHidden() {String phoneNo = "12345";Intent intent = new Intent();intent.setAction(Intent.ACTION_DIAL);Uri uri = Uri.parse("tel:" + phoneNo);intent.setData(uri);startActivity(intent);}
  • 跳轉(zhuǎn)到另一個(gè)APP
    private void handleNavMy() {Intent intent = new Intent();intent.setAction("android.intent.action.MYAPP");intent.addCategory(Intent.CATEGORY_DEFAULT);startActivity(intent);}

在另一個(gè)APP的主Activity中添加以下代碼:

   <intent-filter><action android:name="android.intent.action.MYAPP"/><category android:name="android.intent.category.DEFAULT" /></intent-filter>

三、向下一個(gè)Activity發(fā)送數(shù)據(jù)

  • Intent 使用 Bundle 對(duì)象存放待傳遞的數(shù)據(jù)信息。
  • Bundle 對(duì)象操作各類型數(shù)據(jù)的讀寫方法說明見下表:
    在這里插入圖片描述
    通過 Bundle 傳遞
    private void handleNextData() {Intent intent = new Intent(this, ActFinishActivity.class);Bundle bundle = new Bundle();long currentTimeMillis = System.currentTimeMillis();bundle.putString("request_time", Long.toString(currentTimeMillis));bundle.putString("request_content", "hello,world");intent.putExtras(bundle);startActivity(intent);}

在跳轉(zhuǎn)后的頁面中接收 Bundle

    @Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_act_finish);tv_desc=findViewById(R.id.tv_desc);Bundle bundle = getIntent().getExtras();String request_time = bundle.getString("request_time");String request_content = bundle.getString("request_content");String desc = String.format("消息是:%s,\n時(shí)間是:%s", request_content, request_time);tv_desc.setText(desc);}

也可以不通過Bundle,直接傳單個(gè)數(shù)據(jù)

 	intent.putExtra("name","張三");

接收單個(gè)數(shù)據(jù)

	String name = getIntent().getStringExtra("name");

四、向上一個(gè)Activity發(fā)送數(shù)據(jù)

步驟:

  • 當(dāng)前頁面通過 registerForActivityResult 注冊(cè)回調(diào)
    private ActivityResultLauncher<Intent> register;
        register = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {if (result != null) {Intent intent = result.getData();if (intent != null && result.getResultCode() == Activity.RESULT_OK) {Bundle bundle = intent.getExtras();String response_time = bundle.getString("response_time");String response_content = bundle.getString("response_content");String desc = String.format("返回的消息是:%s\n,時(shí)間:%s", response_content, response_time);tv_res.setText(desc);}}});
  • 當(dāng)前頁面通過 register.launch 發(fā)起跳轉(zhuǎn)
    private void handleDataRes() {Intent intent = new Intent(this, ActFinishActivity.class);Bundle bundle = new Bundle();long currentTimeMillis = System.currentTimeMillis();bundle.putString("request_time", Long.toString(currentTimeMillis));bundle.putString("request_content", "hello,world");bundle.putString("name", "張三");intent.putExtras(bundle);register.launch(intent);}
  • 在下個(gè)頁面調(diào)用 setResult 設(shè)置數(shù)據(jù),并通過 finish結(jié)束頁面
    public void onClick(View view) {Intent intent = new Intent();Bundle bundle = new Bundle();long currentTimeMillis = System.currentTimeMillis();bundle.putString("response_time", Long.toString(currentTimeMillis));bundle.putString("response_content", "你好啊");intent.putExtras(bundle);// 攜帶意圖返回上一個(gè)頁面,RESULT_OK 表示處理成功setResult(Activity.RESULT_OK, intent);// 結(jié)束當(dāng)前活動(dòng)頁finish();}

案例代碼

http://m.aloenet.com.cn/news/38409.html

相關(guān)文章:

  • 西安模板網(wǎng)站建站魔方優(yōu)化大師官網(wǎng)
  • 成都裝修網(wǎng)站制作價(jià)格游戲推廣對(duì)接平臺(tái)
  • 南陽建網(wǎng)站公司16種營(yíng)銷模型
  • 提供網(wǎng)站建設(shè)備案沈陽網(wǎng)站關(guān)鍵詞優(yōu)化公司
  • 請(qǐng)問做網(wǎng)站怎么賺錢排名優(yōu)化軟件點(diǎn)擊
  • 北京網(wǎng)站建設(shè)在哪里天網(wǎng)站結(jié)構(gòu)有哪幾種
  • 房產(chǎn)備案登記信息查詢優(yōu)化大師網(wǎng)頁版
  • 做電商哪個(gè)設(shè)計(jì)網(wǎng)站比較好東莞最新消息今天
  • 微信公眾號(hào)是干什么用的紹興seo排名公司
  • 廣州建站方法南昌seo排名
  • 做網(wǎng)站跳轉(zhuǎn)怎么收費(fèi)網(wǎng)絡(luò)營(yíng)銷軟件推廣
  • 詳情頁制作網(wǎng)站seo交互論壇
  • 建立一個(gè)小程序多少錢小紅書關(guān)鍵詞排名優(yōu)化
  • 去哪找人做網(wǎng)站seo技術(shù)網(wǎng)網(wǎng)
  • 人大網(wǎng)站建設(shè)方案湖南省人民政府
  • 機(jī)械類畢業(yè)設(shè)計(jì)代做網(wǎng)站推薦官網(wǎng)seo關(guān)鍵詞排名系統(tǒng)
  • 哪里有做雜志的免費(fèi)模板下載網(wǎng)站網(wǎng)絡(luò)服務(wù)合同
  • 做網(wǎng)站買空間谷歌廣告開戶
  • 浙江建筑信息監(jiān)管平臺(tái)seo建站公司
  • 做網(wǎng)站視頻 上傳到哪兒百度手機(jī)版下載
  • 網(wǎng)站招工費(fèi)怎么做會(huì)計(jì)分錄企業(yè)推廣策劃
  • 幫人做網(wǎng)站在徐州被敲詐五萬網(wǎng)站開發(fā)軟件
  • 網(wǎng)站收錄做關(guān)鍵詞排名百度網(wǎng)站優(yōu)化
  • 自助微信網(wǎng)站芭蕉視頻app無限次數(shù)
  • 互聯(lián)網(wǎng)網(wǎng)站建設(shè)情況統(tǒng)計(jì)表關(guān)鍵詞資源
  • 哈爾濱微網(wǎng)站建設(shè)太原seo優(yōu)化
  • 哪些網(wǎng)站做批發(fā)衣服電子商務(wù)網(wǎng)站建設(shè)與維護(hù)
  • 南通做網(wǎng)站baidu tg做網(wǎng)站公司排名
  • 電子商城網(wǎng)站開發(fā)教程網(wǎng)絡(luò)推廣引流是做什么工作
  • bootstrap微網(wǎng)站模板下載新聞播報(bào)最新