简体   繁体   English

如何从Intent启动Appwidget配置活动

[英]How to start an appwidget configuration activity from an intent

I am setting up an App Widget, When the user adds the widget to their home screen, It pops up with my configuration activity. 我正在设置一个应用程序小部件,当用户将小部件添加到主屏幕时,它随我的配置活动一起弹出。

but now I need my user to login, SO i redirect them to my login activty, 但是现在我需要我的用户登录,所以我将他们重定向到我的登录活动,

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!isLoggedIn()) {
        Intent intent = new Intent(AppWidgetConfigureActivity.this, LoginActivity.class);
        intent.putExtra("Source", "widgetConfig");
        startActivity(intent);
        this.finnish();
    }

But now when my login activity has successfully logged in, I need to create my appwidget config intent and start it up again. 但是现在,当我的登录活动成功登录后,我需要创建我的appwidget配置意图并重新启动它。

But im not sure how to do this, because the config activity contains information like the widget id etc. 但我不确定如何执行此操作,因为config活动包含小部件ID等信息。

How can I start-up my config activity again? 如何重新启动我的配置活动?

The answer may be as simple as not calling finish() . 答案可能就像不调用finish()一样简单。 This will keep you configuration activity on the task stack and when the login activity finishes, the configuration activity will be displayed again. 这将使您可以在任务堆栈上进行配置活动,并且当登录活动完成时,将再次显示配置活动。

If you used startActivityForResult , you could use your login activity to get some data that can be used when coming back to your own activity. 如果您使用startActivityForResult ,则可以使用登录活动获取一些可以在返回自己的活动时使用的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM