網(wǎng)站首頁 編程語言 正文
前言
調(diào)取支付寶健康碼,其實可以不使用接口去調(diào)用;我們可以通過倆個簡單的小功能去調(diào)取:
1.setOnClickListener事件,首先看源碼
/** * Register a callback to be invoked when this view is clicked. If this view is not * clickable, it becomes clickable. * * @param l The callback that will run * * @see #setClickable(boolean) */ public void setOnClickListener(@Nullable OnClickListener l) { if (!isClickable()) { setClickable(true); } getListenerInfo().mOnClickListener = l; }
在調(diào)用時傳入一個setOnClickListener對象作為參數(shù),該對象是一個接口類型的,源碼如下:
/** * Interface definition for a callback to be invoked when a view is clicked. */ public interface OnClickListener { /** * Called when a view has been clicked. * * @param v The view that was clicked. */ void onClick(View v); }
我們可以使用匿名類型setOnclick去寫
2.Intent類
第一種構(gòu)造函數(shù)指定類型:
Intent intent = new Intent(this,PersonActivity.class);
第二種SetClass方法指定類型:
Intent intent = new Intent();
intent.setClass(this,PersonActivity.class);
調(diào)用setComponent方法指定:
ntent intent = new Intent();
? ? ? ? ? ? ? ? ? ? ? ? ComponentName component = new ComponentName(this,PersonActivity.class);
? ? ? ? ? ? ? ? ? ? ? ? intent.setComponent(component);
我們這里用第一種方法就好了;
另外還有一些小知識點:Uri?(代表要操作的數(shù)據(jù)),好了到這里就可以操作去寫代碼了;
</ String path ="client_type=2"; String link = URLEncoder.encode(path, "UTF-8"); String url = "alipays://platformapi/startapp?appId=2018062060350751&page=%2Fpages%2Fweb%2Fweb%3Furl%3Dhttps%3A%2F%2Fjsstm.jszwfw.gov.cn%2FjkmIndex.html"; Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);/>
uri 里面填的就是在你手機運行打開健康碼的“地址”,
然后把他放進Uri這個類,用parse()方法去解析,
最后再把uri的值放到我們Intent類里面有倆個參數(shù)(Intent.ACTION_VIEW,我們解析好的變量uri)。
這樣我們就可以去使用它了,非常的方便,比在支付寶里找要方便很多,我這個提供的是江蘇的鏈接,其它鏈接可以百度,可能比較難百度,感興趣的小伙伴可以去試試吧!
總結(jié)
原文鏈接:https://blog.csdn.net/qq_54892650/article/details/122438951
相關(guān)推薦
- 2023-01-30 python?集合常用操作匯總_python
- 2022-09-25 阿里云服務(wù)器如何部署ssl證書即https的設(shè)置,以及為ip部署ssl
- 2022-03-25 Postman返回中文亂碼的解決方案(postman請求結(jié)果亂碼)
- 2022-07-24 .Net結(jié)構(gòu)型設(shè)計模式之享元模式(Flyweight)_基礎(chǔ)應(yīng)用
- 2022-07-09 基于fluttertoast實現(xiàn)封裝彈框提示工具類_Android
- 2023-06-19 python中time模塊指定格式時間字符串轉(zhuǎn)為時間戳_python
- 2022-10-17 Android數(shù)據(jù)存儲方式操作模式解析_Android
- 2022-11-12 Kotlin中的惰性操作容器Sequence序列使用原理詳解_Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支