如何导出的活动,以便其他应用程序可以调用它? [英] How to export an activity so other apps can call it?

查看:88
本文介绍了如何导出的活动,以便其他应用程序可以调用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,我搜索了很多,但我没有找到一个precise回答如何导出一个活动,这样一个应用程序可以启动它 startActivityforResult

Well I searched a lot, but I didn't find a precise answer how to export an Activity, so an app can start it with startActivityforResult.

我如何做到这一点?我一定要改变体现在某些方面?

How do I achieve that? Do I have to change the Manifest in some ways?

推荐答案

您需要在您的舱单申报意向过滤器(我从下面的例子吧code扫描仪):

You need to declare an intent-filter in your Manifest (I took the following example from Barcode Scanner) :

<activity android:name="...">
    <intent-filter>
        <action android:name="com.google.zxing.client.android.SCAN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

然后创建一个相同的动作字符串意图:

Then create an intent with the same action string :

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, code);

Android的应该开始你的活动(或者它会显示一个下拉框,如果有多个应用程序共享相同的操作字符串)。

Android should start your activity (or it will show a drop-down box if there are multiple apps sharing the same action string).

这篇关于如何导出的活动,以便其他应用程序可以调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆