从主应用程序获取主活动 [英] Getting Main Activity from Main Application
本文介绍了从主应用程序获取主活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下清单.
<application
android:name=".MyMainApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyMainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我还具有以下全局静态函数.
I also have the following global static function.
MyMainApplication application = MyMainApplication.instance();
是在各处都使用应用程序上下文中描述的技术?
我想从变量application
中获取MyMainActivity
吗?
推荐答案
无法使用Application
实例检索应用程序的主Activity
.
There is no way to retrieve the application's main Activity
using the Application
instance.
通常没有理由这样做……也许有比您显然在直接操作主Activity
更好的解决方案.也许您应该更新您的帖子,特别说明您要尝试做的事情.
Usually there is no reason to do this... perhaps there is a better solution than manipulating the main Activity
directly as you apparently are doing. Maybe you should update your post explaining specifically what you are attempting to do.
这篇关于从主应用程序获取主活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文