简体   繁体   English

如何将自定义相机应用程序设为默认应用程序?

[英]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. 它会启动默认的Android相机应用程序...我已经编写了一个自定义相机应用程序,但如何让Android知道它是一个相机应用程序,并且应该给用户选择使用哪个相机应用程序。

In other words, if I used the code above, my app should start, and not the default android one. 换句话说,如果我使用上面的代码, 我的应用程序应该启动,而不是默认的android。

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. 但是如何让Android知道它是一个相机应用程序,用户应该选择使用哪个相机应用程序。

Have an <intent-filter> on an <activity> for that action: 在该<activity><activity>上有一个<intent-filter>

<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. 下次有人执行上面的startActivityForResult()调用时,您将在选择器旁边显示支持该Intent结构的任何其他内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何制作跟随我的播放器跟随的相机? - How do I make a camera that follows my Player? 如何让我的应用程序出现在app chooser中? - How do I make my app appear in app chooser? 如何使我的自定义Swing组件可见? - How do I make my custom Swing component visible? 如何使自定义按钮的toString()与MouseEntered()一起使用? - How do I make the toString() for my custom button work with MouseEntered()? 如何让我的 java 程序在双击执行时使用我的自定义 JRE,而不是默认安装的 JDK? - How do I make my java program use my custom JRE when executed by double-clicking, rather than the default JDK installed? 你如何在 android 中创建一个按钮来打开一个新的活动,这个活动不仅仅是一个默认活动,它是一个自定义活动 - How do you make a button in android that opens a new activity and this activity is not just a default activity its a custom one 如何为我的Java应用程序提供目标库? - How do I make a target library available to my Java app? 我对应用程序的要求如何拨打和管理电话? - How i do to my app asks to make and manage phone calls? 如何确保我的应用在平板电脑商店中展示 - How do I make sure that my app showing in tablet store 如何让我的Android应用生成随机数? - How do I make my Android app generate a random number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM