android app跳转到微信
来源:互联网 发布:辅助数据库已初始化 编辑:程序博客网 时间:2024/05/18 22:08
今天写这片文章主要是记录下 app跳转到微信的实现方法,我的项目需求是跳转到微信公众号,由于微信官方关闭了这个直接可以跳到公众号的接口,只能 从app打开微信,让用户自己去搜索。
我的项目需求:
点击跳转微信的时候,我实现了点击复制的方法,这样客户也省去了输入公众号的繁琐。
点击复制文本的代码:
ClipboardManager tvCopy = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);tvCopy.setText("XXX");
XXX即为你的公众号。
如图所示:点击去关注跳转到微信,就打开微信了。
/** * 跳转到微信 */private void getWechatApi(){ try { Intent intent = new Intent(Intent.ACTION_MAIN); ComponentName cmp = new ComponentName("com.tencent.mm","com.tencent.mm.ui.LauncherUI"); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(cmp); startActivity(intent); } catch (ActivityNotFoundException e) { // TODO: handle exception getBaseActivity().showToastLong("检查到您手机没有安装微信,请安装后使用该功能"); }}里面的 showToastLong方法即为自定义的Toast提示。
OK,用户自己打开微信公众号直接粘贴上搜索就可以了。
题外话:
点击复制,传参
ClipboardManager tvCopy = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);tvCopy.setText("XXX");XXX可以直接使用下面的方法替代:
tv.getText().toString().trim();
获取复制的内容:
ClipboardManager tvPaste = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);String content = tvPaste.getText().toString().trim();content就是你想要的内容。
阅读全文
0 0
- android app 跳转到微信
- android app跳转到微信
- Android APP内部跳转到微信
- Android 浏览器跳转App
- Android两个App跳转
- APP跳转到微信
- 【Android】webview点击跳转APP
- android跳转到地图app
- Android跳转到其他APP
- Android App跳转App以及App跳转指定App页面的实现
- App跳转到微信公众号
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- Android 从网页中跳转到APP
- android 从网页中跳转到APP
- android app小白试水-fragment跳转浏览器debug
- Android app跳转google play store
- Android 从网页中跳转到APP
- 谈谈 Idea编辑器和SpringBoot轻量框架 初级开发者如何让其启动和访问
- 561. Array Partition I
- Java中==和equal有什么区别
- 《人性的弱点》第二章 获取喜爱的十二大技巧:读后感
- 任务分解
- android app跳转到微信
- Jackson 时间格式化输入输出
- 人脸识别之端到端框架(六)--SphereFace
- Angular: Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’
- opencv分水岭分割算法C++是
- 功耗问题研究
- 记忆碎片
- MVP实现二级购物车
- windows查看端口使用进程