Declared constant for the size of photos of contacts of Android?

96x96 contact photos on my Nexus S. I really don't want to “bake” this knowledge into my code - is there somewhere a permanent announcement declaring this? I looked, but I can not find it.

+6
source share
1 answer

In android 2.3+ there is a ThumbnailUtils class which has

/** * Constant used to indicate the dimension of micro thumbnail. * @hide Only used by media framework and media provider internally. */ public static final int TARGET_SIZE_MICRO_THUMBNAIL = 96; 

but @hide is hiding it from us.

Looking at the source code of the Contacts application, AttachImage.java file I found another interesting thing:

 @Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { // omitted if (requestCode == REQUEST_PICK_CONTACT) { // A contact was picked. Launch the cropper to get face detection, the right size, etc. // TODO: get these values from constants somewhere Intent myIntent = getIntent(); Intent intent = new Intent("com.android.camera.action.CROP", myIntent.getData()); if (myIntent.getStringExtra("mimeType") != null) { intent.setDataAndType(myIntent.getData(), myIntent.getStringExtra("mimeType")); } intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 96); intent.putExtra("outputY", 96); intent.putExtra("return-data", true); startActivityForResult(intent, REQUEST_CROP_PHOTO); 

That TODO and those .putExtra intentions say a lot, even if there is a constant size sketch, it is not used in the contact application.

+7
source

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


All Articles