[Android]检测和启动其他程序

来源:互联网 发布:suse linux ntp配置 编辑:程序博客网 时间:2024/06/05 23:00

原创文章, 转载请保留出处: http://blog.csdn.net/s278777851/article/details/7168858


第一步,检查是否已经安装某个程序, 这个时候需要知道包名.

 public boolean isAppExist(Context context,String pageName){    try {context.getPackageManager().getPackageInfo(pageName,0);return true;} catch (NameNotFoundException e) {return false;} }
第二步,启动程序, 这个时候不止需要知道包名, 还需要知道启动的activity的具体类名
Intent i = new Intent("android.intent.action.MAIN");  i.setComponent(new ComponentName("com.xxx", "com.xxx.mainActivity"));  startActivity(i); 
原创粉丝点击