[英]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.