網站首頁 編程語言 正文
前言
調取支付寶健康碼,其實可以不使用接口去調用;我們可以通過倆個簡單的小功能去調取:
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; }
在調用時傳入一個setOnClickListener對象作為參數,該對象是一個接口類型的,源碼如下:
/** * 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類
第一種構造函數指定類型:
Intent intent = new Intent(this,PersonActivity.class);
第二種SetClass方法指定類型:
Intent intent = new Intent();
intent.setClass(this,PersonActivity.class);
調用setComponent方法指定:
ntent intent = new Intent();
? ? ? ? ? ? ? ? ? ? ? ? ComponentName component = new ComponentName(this,PersonActivity.class);
? ? ? ? ? ? ? ? ? ? ? ? intent.setComponent(component);
我們這里用第一種方法就好了;
另外還有一些小知識點:Uri?(代表要操作的數據),好了到這里就可以操作去寫代碼了;
</ 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類里面有倆個參數(Intent.ACTION_VIEW,我們解析好的變量uri)。
這樣我們就可以去使用它了,非常的方便,比在支付寶里找要方便很多,我這個提供的是江蘇的鏈接,其它鏈接可以百度,可能比較難百度,感興趣的小伙伴可以去試試吧!
總結
原文鏈接:https://blog.csdn.net/qq_54892650/article/details/122438951
相關推薦
- 2023-05-14 Python中數字(Number)數據類型常用操作_python
- 2022-04-04 uni-app 數據上拉加載更多功能
- 2022-05-25 ASP.NET?MVC+EF實現異步增刪改查_實用技巧
- 2022-07-08 一文詳解C++中運算符的使用_C 語言
- 2022-06-08 .Net?Core?進程守護之Supervisor使用詳解_實用技巧
- 2022-11-23 Python字符串格式化實例講解_python
- 2022-11-30 AMP?Tensor?Cores節省內存PyTorch模型詳解_python
- 2022-08-19 R語言rhdf5讀寫hdf5并展示文件組織結構和索引數據_R語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支