当前位置: 代码迷 >> Android >> Android中起动第三方应用
  详细解决方案

Android中起动第三方应用

热度:7   发布时间:2016-04-28 04:44:46.0
Android中启动第三方应用

主要是通过包名启动第三方应用,获取去包名的方法网上很多,就不多说了。

两种方式启动:

第一种:

Intent intent = new Intent();

intent.setClassName("要启动应用的包名", "要启动应用的activity");
startActivity(intent);

第二种:

Intent intent = new Intent();
intent = MainActivity.this.getPackageManager().getLaunchIntentForPackage(“你获取的包名”);
startActivity(intent);

一般比较喜欢使用第二种方式,比较简单。不需要额外获取要启动的activity。


  相关解决方案