android launch camera app (NOT for result)

Go To StackoverFlow.com

2

I'm building a home screen replacement app and was wondering how to launch the camera app in normal mode. The 'Home' sample does not have a camera app listed since its not installed as a separate app on the device (which explains why my galaxy nexus camera issues haven't been resolved). In otherwords, I want to launch the camera app in the same way I can do so from my stock home screen launcher...

2012-04-03 21:03
by Ben
This answer worked fine for me: http://stackoverflow.com/a/18603122/76906 - Kat 2013-12-11 19:56


1

you would probably want to open an intent from a Component name with the Main intent instead of the usual method of calling the camera for an answer.

You can open any activity on Android as if you are clicking on it in the home screen you just need the compentent name, you can get the component name by opening it normally as a user then reading it off your logcat when the activity opens... I have done the Camera intent for you.

       Intent intent = new Intent("android.intent.action.MAIN");
   intent.setComponent(ComponentName.unflattenFromString("com.google.android.camera/com.android.camera.Camera"));
   intent.addCategory("android.intent.category.LAUNCHER");
   startActivity(intent);   
2012-04-03 21:25
by Martin Sykes
sorry that doesn't seem to work, i get the following:

04-04 06:42:19.840: E/AndroidRuntime(921): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.camera/com.android.camera.Camera}; have you declared this activity in your AndroidManifest.xml - Ben 2012-04-03 21:43

Hi Ben, thanks for getting back, 'not installed' will be an issue then! for your stock home screen have you installed an additional camera app? The only thing I can say is open the camera app while looking at your logcat read of the "ActivityManager" line where it says "Starting: Intent" and tells you all about what you just opened. The only trouble with this method is it won't work on anyone elses phone unless they have the same exact app! I hope someone gives you a better answer - Martin Sykes 2012-04-03 21:53
You know what this might be a much better answer try this: Intent intent = new Intent("android.intent.action.CAMERA_BUTTON"); startActivity(intent) - Martin Sykes 2012-04-03 22:00
Ads