1
是否可以使用BroadcastReceiver
调用一个活动?每当用户按下电源按钮时,将触发onReceive
的BroadCast receiver
。关于广播接收机android
是否可以使用BroadcastReceiver
调用一个活动?每当用户按下电源按钮时,将触发onReceive
的BroadCast receiver
。关于广播接收机android
是的,我们可以调用试试下面的代码
Intent mIntent = new Intent(getBaseContext(), Activity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(mIntent);
您可以从广播接收器通过以下方式
public void onReceive(Context context, Intent intent) {
Intent intentStart = new Intent(context, StartActivity.class);
intentStart.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentStart);
}
启动活动