[英]My Android App shows up twice in list when sharing from the Photos App
我的Android应用程序可以接收其他应用程序的URL和图像共享。 清单的以下摘录显示了处理这些份额所涉及的两个活动的定义:
<!-- Activity: Share Handler -->
<activity android:name="com.softframeworks.tabdancer.ShareHandlerActivity"
android:label="@string/shared_browser_url"
android:noHistory="true"
android:windowSoftInputMode="stateHidden">
<!-- Intent filter indicates that this activity can handle text -->
<!-- shared using the SEND action. -->
<intent-filter android:label="@string/app_name" android:priority="777">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
<!-- Activity: Image Share Handler -->
<activity android:name="com.softframeworks.tabdancer.edit.icon_cache.ImageShareHandlerActivity"
android:label="@string/app_name"
android:noHistory="true"
android:windowSoftInputMode="stateHidden"
android:parentActivityName="com.softframeworks.tabdancer.ManageActivity">
<!-- Intent filter indicates that this activity can handle images -->
<!-- shared using the SEND action. -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
我遇到的问题是,从Google相册应用共享照片时,我的应用显示两次。 我的两个活动的意图过滤器似乎都与“照片”应用可以共享的内容匹配。 我希望我的应用程序在那些可以从“照片”应用程序接收共享的列表中仅显示一次。 理想情况下,共享将作为图像(而不是URL)完成。
我正在运行棉花糖的Nexus 7上进行测试。
提前致谢。
我可以通过将清单更改如下来解决此问题:
<!-- Activity: Share Handler -->
<activity android:name="com.softframeworks.tabdancer.ShareHandlerActivity"
android:label="@string/shared_browser_url"
android:noHistory="true"
android:windowSoftInputMode="stateHidden">
<!-- Intent filter indicates that this activity can handle text shared -->
<!-- using the SEND action. -->
<!-- Intent filter also indicates that this activity can handle images -->
<!-- shared using the SEND action. However the code for this activity -->
<!-- redirects image shares to the ImageShareHandlerActivity. -->
<intent-filter android:label="@string/app_name" android:priority="777">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<!-- Activity: Image Share Handler -->
<activity android:name="com.softframeworks.tabdancer.edit.icon_cache.ImageShareHandlerActivity"
android:label="@string/app_name"
android:noHistory="true"
android:windowSoftInputMode="stateHidden"
android:parentActivityName="com.softframeworks.tabdancer.ManageActivity">
</activity>
因此,现在ShareHandlerActivity可以处理图像共享和文本共享。 但是,在此活动的onCreate()方法中,我测试了意图的类型。 如果是图像/ *,那么我将共享的处理委托给ImageShareHandlerActivity。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.