从一个BroadcastReceiver调用一个活动的完成()方法 [英] Calling the finish() method of an Activity from a 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屋!