在另一个 android 应用程序中从 APK 调用活动 [英] Invoking activity from APK in another android application

查看:22
本文介绍了在另一个 android 应用程序中从 APK 调用活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 android 应用程序,它启动一个活动并且运行良好.我需要其他开发人员能够将我的 APK 集成到他们的应用程序中,以便他们可以从他们的 android 应用程序启动我的 APK 中的活动.

I have an android application that starts an activity and is running well. I need other developers to be able to integrate my APK into their applications in such a way that they can start the activity in my APK from their android applications.

实现这一目标的方法有哪些?

What are the ways of achieving this?

谢谢乔治

推荐答案

恕我直言,最好的做法是在 Activity 的清单中声明自定义操作.类似的东西:

The best thing to do, IMHO, is declare a custom action in an in your activity's manifest. Something like:

<activity android:name="Foo">
  <intent-filter>
    <action android:name="com.commonsware.android.THIS_IS_MY_ACTION" />
  </intent-filter>
</activity>

然后,您的同胞可以通过该自定义操作启动它:

Then, your compatriots can launch it via that custom action:

startActivity(new Intent("com.commonsware.android.THIS_IS_MY_ACTION"));

通过命名您的操作,您不应该与其他任何人的应用发生意外冲突.

By namespacing your action, you should not run into accidental conflicts with anyone else's app.

这篇关于在另一个 android 应用程序中从 APK 调用活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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