Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 三星Galaxy S5-当我从广播接收器打开活动时,活动在某个时间未打开_Android_Galaxy_Android Broadcastreceiver - Fatal编程技术网

Android 三星Galaxy S5-当我从广播接收器打开活动时,活动在某个时间未打开

Android 三星Galaxy S5-当我从广播接收器打开活动时,活动在某个时间未打开,android,galaxy,android-broadcastreceiver,Android,Galaxy,Android Broadcastreceiver,我正在尝试从广播接收器打开一个活动(应用程序),下面的代码在大多数设备上运行良好。特别是在三星Galaxy S5上。活动有时启动,有时不启动 该问题仅在三星Galaxy S5中出现: Intent intent = new Intent(context,Activity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); Log.e("app lau

我正在尝试从广播接收器打开一个活动(应用程序),下面的代码在大多数设备上运行良好。特别是在三星Galaxy S5上。活动有时启动,有时不启动

该问题仅在三星Galaxy S5中出现:

 Intent intent = new Intent(context,Activity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    Log.e("app launch--", "application launch code call");

请再添加一件事,在呼叫活动之前打开唤醒锁。 用于在接收到消息时防止处理器休眠

 PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        //Object flags;
        if (wl == null)
            wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "MATH_ALARM");
        wl.acquire();
当您的活动结束时,释放唤醒锁

try {
            if (wl != null)
                wl.release();
        } catch (Exception e) {
            //e.printStackTrace();
        }
并将此权限添加到您的清单中

    <uses-permission android:name="android.permission.WAKE_LOCK" />


“活动在某个时间启动”是什么意思?

使用此代码随机启动应用程序,但在其他设备上运行良好如果新活动启动不同,可能您有不同的defalt动画。我不这么认为,因为它在其他设备上运行良好,我也做了调试,我没有得到任何异常,代码执行正确,这是特定于设备的问题。您的
Log.e()
语句每次都执行吗?