当前位置: 代码迷 >> Android >> android中施用代码启动其他程序
  详细解决方案

android中施用代码启动其他程序

热度:58   发布时间:2016-05-01 13:49:54.0
android中使用代码启动其他程序
你要訪問其他的程序,那麼這個程序要先裝載到模擬器或真機上面,因為我們要使用要訪問其他程序的包。

簡單的訪問有以下兩種方式(目前只知道這兩種):

一、使用Intent的setComponent方法

二、使用包管理器


一、使用Intent的setComponent方法

Intent intent = new Intent();

intent.setComponent(new ComponentName("包名", "包名.主類名"));

intent.setAction(Intent.ACTION_VIEW);

startActivity(intent);

二、使用包管理器

Intent intent = new Intent();

intent = getPackageManager().getLaunchIntentForPackage("包名");

startActivity(intent);
1 楼 再度重相逢 2011-11-10  
  相关解决方案