If it is determined by the resolution of the Android device's screen, is there a way to programatically get the value of that resolution?
3
There are 3 best solutions below
5
On
you can do like this
String pickedImagePath = "path/of/the/selected/file";
BitmapFactory.Options bitMapOption=new BitmapFactory.Options();
bitMapOption.inJustDecodeBounds=true;
BitmapFactory.decodeFile(pickedImagePath, bitMapOption);
int imageWidth=bitMapOption.outWidth;
int imageHeight=bitMapOption.outHeight;
Update:
you can use display metrics to get your screen with
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int height = metrics.heightPixels;
Note: The resolution of your screen and resolution of camera may not be the same. please refer the answer here.
0
On
Get the screen size using the following snippet. this means the current Activity context.
WindowManager windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getMetrics(displayMetrics);
int screenWidth = displayMetrics.widthPixels;
int screenHeight = displayMetrics.heightPixels;
No.
There is no "default size... of a photo".
If you are using the
android.hardware.Cameraorandroid.hardware.camera2APIs yourself, you need to specify the resolution that you want, from the available resolutions.If you are using
ACTION_IMAGE_CAPTURE, the resolution will be based in part on whether you passEXTRA_OUTPUTor not, but otherwise is up to the camera app. There are thousands of Android device models, shipping with hundreds of different pre-installed camera apps, and there are many other camera apps available through distribution channels like the Play Store. They will be using theandroid.hardware.Cameraorandroid.hardware.camera2APIs, and they will choose what resolution they want to use, by whatever algorithm they want.