如何快速启动应用?

其实方法有很多中,在这里我介绍一种无意间看到的。有时候有很多需求,客户给你一个 apk,再网上下载一个 apk ,如何去启动它呢。在这里很多人就会说了,直接安装,点击应用图标啊,废话。如果可以这样操作的话,那还说个锤子。在现实的工作中,会遇到各种各样的奇葩场景,很多时候不会把所有的东西都给你准备好,如果真这样,那真没啥事了。废话不多说,直接介绍:

1.首先我们把 apk 安装到手机上,打开应用,查看 Locat 控制台,过滤掉 ActivityManager ,这个时候你就会发现很多东西了,直接是可以看到打开的 Activity 页面的全路径以及应用的包名,比如:

2020-04-18 17:05:37.336 1589-1604/? I/chatty: uid=1000(system) ActivityManager expire 2 lines
2020-04-18 17:05:40.711 1589-4854/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.mm/.ui.LauncherUI bnds=[335,749][503,917] (has extras)} from uid 10042
2020-04-18 17:05:40.779 1589-2595/? W/ActivityManager: Request to remove task ignored for non-existent task 5583
2020-04-18 17:05:41.726 1589-1614/? I/ActivityManager: Displayed com.tencent.mm/.ui.LauncherUI: +956ms
2020-04-18 17:05:42.424 1589-1606/? I/ActivityManager: Start proc 22884:com.tencent.mm:toolsmp/u0a164 for broadcast com.tencent.mm/.booter.MMReceivers$ToolsMpProcessReceiver caller=com.tencent.mm
2020-04-18 17:05:44.845 1589-1606/? I/ActivityManager: Start proc 22955:com.tencent.mm:sandbox/u0a164 for service com.tencent.mm/.service.ProcessService$SandBoxProcessService caller=com.tencent.mm

这是打开了微信应用,可以轻松看到微信的包名是:com.tencent.mm
启动页面是:.ui.LauncherUI,这样再配合代码打开应用。

 			try {
 						Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI"));
                        startActivity(intent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

就这样基本上是解决了我们在一些特殊场景下启动一个应用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值