tags:

views:

59

answers:

1

I see a ton of results when searching for how to open the camera, and get the returned image. What about simply opening the camera app without any return at all? I just want the camera to function as normal.

+2  A: 

You could just send an ACTION_CAMERA_BUTTON intent? That should do the trick.

Intent intent = new Intent(ACTION_CAMERA_BUTTON, null);
startActivity(intent);

Obviously, "this" needs to be your current activity.

EboMike
beat me too it while I was looking up the action, well played good sir.
schwiz
Next time, schwiz, next time :)
EboMike
How do I send an intent?
Joren
Added code sample.
EboMike
I used this and it worked.Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON);sendBroadcast(i);
Joren
If it worked, then please accept the answer. Thanks!
EboMike
@Joren: Bear in mind that other applications might intercept that button press, so there is no guarantee that this will open the camera application.
CommonsWare
Hmm. What if the phone has no camera button? Is there a more direct way to launch the camera application.
Joren
Different manufacturers might add their own camera apps, so I'm not sure there is "the camera app". You could launch Google's camera app directly, but some phones might replace that with their own custom app that has its own intent. Maybe there's a better way to get the "standard" camera app, but there's none that I'm aware of.
EboMike