Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom icon and text in Intent Chooser

I need to allow user to pick an image or take a new photo. I've implemented a custom camera activity.

When the user click on a button, an Intent Chooser is launched, asking among apps that allow to pick an image. Among them, I've added an intent that start my camera activity in order to take a new picture.

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

The problem is that among the icons in the dialog of the Intent Chooser there is also the icon of my app and its name, because of the camera intent.

enter image description here

Is it possible to customize the icon and the label instead of using the app ones?

like image 753
Daniele Vitali Avatar asked Oct 17 '25 13:10

Daniele Vitali


2 Answers

read this http://developer.android.com/guide/topics/manifest/activity-element.html, note "label" and "icon" attributes

like image 61
pskink Avatar answered Oct 20 '25 04:10

pskink


Just specify the name and icon in your activity in AndroidManifest.xml. Like this:

<activity android:label="Camera" android:icon="@drawable/myCameraIcon" android:name=".CameraActivity" />
like image 31
ShadowTrackr Avatar answered Oct 20 '25 02:10

ShadowTrackr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!