安卓启动器
我需要启动 android 应用程序,不是使用 Activity^,而是使用一些将启动某些活动的控制器类,
这可能吗?
I need to start android application not with Activity^ but with some controller class that will start some activity
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否正确理解你的问题,但是 Android 应用程序是由四个“组件”构建的,如“Android 应用程序基础知识”中所述,http://developer.android.com/guide/topics/fundamentals.html (不,您不需要全部四个即可使您的应用程序正常工作)。
启动应用程序的最常见方法(实际上也是我接触过的唯一方法)是在应用程序的 AndroidManifest.xml 文件中定义一个 Activity,如上面的链接所述。笔记! Activity 不必定义 UI;您没有义务调用“setContentView()”函数。因此,您的“控制器类”可以扩展 Activity,并成为您在清单 xml 中定义为启动 Activity 的 Activity。然后,您可以在您认为合适的时候从控制器类调用带参数的“startActivity()”函数来启动任何其他活动(这也在上面的链接中进行了描述)。
希望这有帮助。
I'm not sure if I understand your question correctly, but an Android application is built up by four "components" as mentioned in the "Android Application Fundamentals", http://developer.android.com/guide/topics/fundamentals.html (no, you don't need all four of them make your application work).
The most common way of starting an application (and actually the only one I've been in touch with) is to define an Activity in your applications AndroidManifest.xml file as described on the link above. NOTE! that an Activity doesn't have to define a UI; you are not obligated to call the "setContentView()" function. Hence your "controller class" can extend Activity and be the very Activity you define as the start-up Activity in your manifest xml. You can then call "startActivity()" function with parameters to start any other Activity, whenever you see fit, from your controller class (this is also described in the link above).
Hope this helps.
创建一个无 GUI 的活动而不调用
setContentView()
或使用接受启动器意图的 BroadcastReceiver(action=MAIN、cateogry=LAUNCHER)。在 Activity.onCreate 或接收者回调方法中,您可以放置将调用所选实际活动的逻辑。Either create a GUI-less activity without calling
setContentView()
or use a BroadcastReceiver that accepts launcher intents (action=MAIN, cateogry=LAUNCHER). In Activity.onCreate or receivers callback method you can place logic which will invoke the actual activity of choice.