要使资格成为默认的画廊应用,我在应用程序的清单文件中设置了intent-filter
。
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
但是,当我触摸默认相机应用程序的图库图标时,我找不到在显示的列表中的应用程序。我该怎么办?
出于安全原因,只有Android用户才能将应用程序声明为 default for xxxx。
您可以声明您的应用程序能够处理某些意图,然后用户可以在选择器中决定是否应成为默认值。
您必须查看相机应用程序的源代码才能找出其使用的意图。
在我的Android-4.2上,此无证件动作打开了画廊
<!-- OpenCamera AlmalenceGUI.openExternalGallery() uses
undocumented action="com.android.camera.action.REVIEW"
which in my android-4.2.2 opens the gallery in
swipe mode. -->
<action android:name="com.android.camera.action.REVIEW" />
,但这可能是其他Android版本的不同(甚至是不可能的(
如果相机(和其他应用程序(使用标准意图,则可以使用https://f-droid.org/repository/browse/?fdid=uk.co.ashtonbrsc.android.intentintercept(也可以在G中使用(** e-PlayStore(。但是我恐怕您的用例既不是标准的,也不是可互化的