嗯,我搜索了很多,但我没有找到一个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).