Intent Chooser中的自定义图标和文本

时间:2014-02-17 14:40:12

标签: android android-intent

我需要允许用户选择图片或拍摄新照片。我已经实现了自定义相机活动。

当用户点击某个按钮时,会启动一个Intent Chooser,询问允许选择图像的应用程序。其中,我添加了一个意图,开始我的相机活动,以拍摄新照片。

    Intent pickImageIntent = new Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI);
    pickImageIntent.setType("image/jpeg");

    Intent takePhotoIntent = new Intent(this, CameraActivity.class);
    takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, file.getAbsolutePath());

    Intent chooserIntent = Intent.createChooser(pickImageIntent, "");
    if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA))
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent });

    startActivityForResult(chooserIntent, 0);

问题是,在Intent Chooser对话框中的图标中,还有我的应用程序的图标及其名称,因为相机意图。

enter image description here

是否可以自定义图标和标签,而不是使用应用程序?

2 个答案:

答案 0 :(得分:4)

请阅读此http://developer.android.com/guide/topics/manifest/activity-element.html,注意“标签”和“图标”属性

答案 1 :(得分:0)

只需在AndroidManifest.xml中指定活动中的名称和图标即可。像这样:

<activity android:label="Camera" android:icon="@drawable/myCameraIcon" android:name=".CameraActivity" />
相关问题