简体   繁体   中英

How do I make my custom camera app the default one?

If I would use the following code:

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent,1);

it would start the default Android camera app right... I've written a custom camera app, but how do let Android know that it's a camera app, and that the user should be given the choice which Camera app to use.

In other words, if I used the code above, my app should start, and not the default android one.

but how do let Android know that it's a camera app, and that the user should be given the chose which Camera app to use.

Have an <intent-filter> on an <activity> for that action:

<intent-filter>
  <action android:name="android.media.action.IMAGE_CAPTURE" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

The next time that somebody executes your above startActivityForResult() call, you will appear in the chooser alongside anything else that supports that Intent structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM