开发有时需要在一个应用中启动另一个应用,比如Launcher加载所有的已安装的程序的列表,当点击图标时可以启动另一个应用,一般我们知道了另一个应用的包名和MainActivity的名字之后便可以直接通过如下代码来启动。
网上看了很多文章,都是说用intent跳转,方法如下:
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- ComponentName cn = new ComponentName(packageName, className);
- intent.setComponent(cn);
- startActivity(intent);
Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("weixin://dl/scan"));
startActivity(intent1);
这个是跳到微信的扫一扫功能
支付宝钱包扫码的 URL Scheme 是这样的
alipayqr://platformapi/startapp?saId=10000007
如果想跳转到其他更多的功能,就去网上搜索该功能的 URL Scheme
希望对大家有所帮助