本文介绍了以编程方式更改发射活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,我可以改变,当应用程序启动时启动该活动?

Is there a way I can change the activity that is launched when the application is started?

推荐答案

我会建议具有总是被指定为您的清单发射活动的辅助活动。然后,在活动中,你可以做任何决定的OnCreate你需要决定哪些应用程序来启动,然后完成辅助活动。例如:

I would recommend having a helper activity that is always designated as the launcher activity in your manifest. Then, in the onCreate of that activity you can do whatever determination you need to decide what app to start and then finish the helper activity. Example:

在你的清单(发射活动):

In your manifest (launcher activity):

<activity android:name=".HelperActivity" ... />

那么,在HelperActivity的onCreate:

Then, in HelperActivity's onCreate:

@Override
public void onCreate(Bundle b){
    super.onCreate();
    //determine what activity you want
    startActivity(new Intent(this, NewActivity.class);
    finish();
}

这篇关于以编程方式更改发射活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:38