Android 联系人照片尺寸声明为常量吗?

发布于 2024-11-28 04:48:03 字数 81 浏览 0 评论 0原文

我的 Nexus S 上的联系人照片为 96x96。我真的不想将这些知识“烘焙”到我的代码中 - 是否有一个常量声明了这一点?我看过,但似乎找不到。

Contact photos are 96x96 on my Nexus S. I really don't want to 'bake' that knowledge into my code - is there a constant somewhere that declares this? I've looked, but can't seem to find one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清音悠歌 2024-12-05 04:48:03

在 android 2.3+ 中,有一个 ThumbnailUtils 类,

/**
 * 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;

但 @hide 对我们隐藏了它。

查看联系人应用程序源代码,文件 AttachImage.java 我发现了另一个有趣的事情:

@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);

TODO 和那些 Intent.putExtra 说了很多,即使有缩略图大小常量,它也不会在联系人应用程序中使用。

In android 2.3+ there is a ThumbnailUtils class that 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 that @hide hides it from us.

Looking at the Contacts app source code, file AttachImage.java 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 intent.putExtra say a lot, even if there is a thumbnail size constant, it isn't used in the contact app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文