1.跳转微信
-
使用URL Scheme请求,现在微信不能直接跳转到微信扫一扫,只能跳到微信首页
fun goWeChat(context: Context) { val uri = Uri.parse("weixin://") Intent(Intent.ACTION_VIEW, uri).apply { context.startActivity(this) } } 复制代码
-
另一种方法
fun goWeChat(context: Context) { Intent().apply addCategory(Intent.CATEGORY_LAUNCHER) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) setComponent(ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI")) context.startActivity(this) } } 复制代码
-
进入微信扫一扫
fun goWeChatScan(context: Context) { Intent(Intent.ACTION_MAIN).apply putExtra("LauncherUI.From.Scaner.Shortcut", true) addCategory(Intent.CATEGORY_LAUNCHER) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) setComponent(ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI")) context.startActivity(this) } } 复制代码