从一个BroadcastReceiver调用一个活动的完成()方法 [英] Calling the finish() method of an Activity from a BroadcastReceiver

查看:340
本文介绍了从一个BroadcastReceiver调用一个活动的完成()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个活动(活动1,活性2)和一个BroadcastReceiver类

I have 2 Activities (Activity1, Activity2) and a BroadcastReceiver class

假设我们现在对活性2,我在那里建立了一个AlarmManager在特定时间运行。

Assume that we are now on Activity2, where I set up an AlarmManager to run at a specific time.

有没有办法给的BroadcastReceiver?

Is there a way to call the finish() method of Activity2 within the onReceive() of the BroadcastReceiver?

我的目标是从活性2回不活动1起onRecieve一个新的Intent()。

My goal is to return to Activity1 from Activity2 without starting a new Intent in onRecieve().

注:BroadcastReceiver的类没有活性2的活动中注册。它被登记在AndroidManifest.xml

Note: The BroadcastReceiver class is not registered within the Activity of Activity2. It is registered in the AndroidManifest.xml.

推荐答案

您可以使用Activity2class.finish();

You can use Activity2class.finish();

这篇关于从一个BroadcastReceiver调用一个活动的完成()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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