How to open the default camera without showing impressions?

How to open the default camera in the application?

I do not want to open a choice for him (his client requirement). I use this intent android.media.action.IMAGE_CAPTURE and causing activity for the result.

Everything is fine, but applications such as Linear Camera, Paper Camera appear in the selection menu using the default camera application, I do not want to display chooser for.

Your attention will be highly appreciated.

+3
source share
3 answers

The only thing you can choose for a specific activity is the use of explicit intentions. And for the built-in camera application, the package name may differ and depends on the device

0
source

I believe that you can find your answer (and code) at the link below:

How to launch an Android camera using intent

The author says that: "the above code should start the default camera activity on your phone"

0
source
  List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); for (int n=0;n<list.size();n++) { if((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM)==1) { Log.d("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); Log.d("TAG", "package name : " + list.get(n).packageName); if(list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { defaultCameraPackage = list.get(n).packageName; break; } } } 

I found the following solution and its work is excellent.

 Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.setPackage(defaultCameraPackage); startActivityForResult(takePictureIntent, actionCode); 

You can filter the camera by default by installing the package in the above intention. I tested it by installing the two applications Linear Camera and Paper Camera . Both applications showed a choice, but filtering by package above the code is open only by default.

0
source

Source: https://habr.com/ru/post/887691/


All Articles