0

我正在尝试在单击按钮时启动相机应用程序,但我不想让它表现得像 lauc´ncher 启动的那样,但是当我调用我的代码时,应用程序只是关闭并且相机是'没有开始。甚至没有错误代码。

代码 :

if(v == camera)
    {

        //Intent in=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 

            // this.startActivity(in);



        Intent startupIntent = new Intent();
        ComponentName distantActivity = new ComponentName("com.android.camera","com.android.camera/.Camera");
        startupIntent.setComponent(distantActivity);
        startupIntent.setAction(Intent.ACTION_MAIN);
        startActivity(startupIntent);    


        finish();
    }
4

1 回答 1

0

使用android.intent.action.VIEW而不是Intent.ACTION_MAIN

    Intent startupIntent = new Intent();

    ComponentName distantActivity= new ComponentName("YOUR_CAMRA_APP_PACKAGE","YOUR_CAMRA_APP_PACKAGE.ACTIVTY_NAME");

// LIKE IN LG  DEVICE WE HAVE AS

//ComponentName distantActivity= new //ComponentName("com.lge.camera","com.lge.camera.CameraApp");

    startupIntent .setComponent(distantActivity);

    startupIntent .setAction("android.intent.action.VIEW");

    startActivity(startupIntent);
于 2012-05-31T16:20:56.690 回答