在我的 android i 应用程序中,我可以使用警报功能和注销功能。设置闹钟时间后,我通过单击注销按钮退出应用程序。
我在用
ExitActivity.this.finish();
Intent intent1 = new Intent(ExitActivity.this,PinActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent1);
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
此代码退出应用程序,进入主屏幕,然后启动主屏幕。这是因为当我回到我的应用程序时,它会启动 pinscreen。警报完全符合我的要求,但是在弹出警报消息时,它在后台具有 pinactivity(我不想要)。我不想摆脱后台的 pin 活动。
这是我的接收器类?
public class ShortTimeEntryReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"Alarm Working", Toast.LENGTH_SHORT).show();
try {
Bundle bundle = intent.getExtras();
String message = bundle.getString("alarm_message");
Intent newIntent = new Intent(context, ReminderPopupMessage.class);
newIntent.putExtra("alarm_message", message);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
} catch (Exception e) {
Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
我怎么做?谢谢你们的帮助。。