intent- 启动其他应用

今天需要在图库中实现对相机的调用,代码如下

 Intent intent = new Intent(Intent.ACTION_VIEW);
              ComponentName componetName = new ComponentName("com.android.gallery3d",
                "com.android.camera.CameraLauncher");
               try {
                   intent.setComponent(componetName);
                     mContext.startActivity(intent);
                 } catch (Exception e) {
                    Toast.makeText(mContext, "可以在这里提示用户没有找到应用程序,或者是做其他的操作!", 0).show();
                 }
com.android.gallery3d:包名
com.android.camera.CameraLauncher:应用名

这里关键就是选找应用名,一般是到对应的应用模块下面查看androidManifest.xml来查看
注释:相机的应用都是在图库里面的,需要到图库的manifest.xml下查看相应的信息

原文地址:https://www.cnblogs.com/zhangshuli-1989/p/zhangshuli_intent_15020616.html