这难道不是可以开始从BroadcastReceiver的活动这难道、不是、BroadcastReceiver

由网友(依风雨晴)分享简介:我要调用从类扩展的BroadcastReceiver,但这个活动它不工作I want to call this activity from a class extending BroadcastReceiver but its not workingIntent i = new Intent(DevicePoli...

我要调用从类扩展的BroadcastReceiver,但这个活动它不工作

I want to call this activity from a class extending BroadcastReceiver but its not working

Intent i = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
context.startActivity(i);

是没可能,开始从BroadcastReceiver的活动。请大家帮帮忙。

Is it not possible to start an activity from BroadcastReceiver. Please help.

推荐答案

试试这个

@Override
public void onReceive(Context context, Intent arg1) {
    Intent intent = new Intent(context, yourclass.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

yourclass.class的是,你要开始你的活动类。另外,不要忘了添加标记为新的任务。

yourclass.class is your activity class that you want to start. Also, do not forget to add flags as new task.

阅读全文

相关推荐

最新文章