无法在Android Oreo和Pie上以打ze模式启动startActivity

时间:2019-05-17 02:55:24

标签: java android android-8.0-oreo android-9.0-pie

我的问题与以下参考文献相同:startActvtiy in Doze mode on Android Pie

我开发了一个通话应用程序。当我释放去商店后,我的用户抱怨他们的电话进入空闲模式时无法接听电话。我使用下面的链接和步骤让我的应用强制进入空闲模式:https://developer.android.com/training/monitoring-device-state/doze-standby

锁定屏幕 adb shell dumpsys电池拔出 adb shell dumpsys deviceidle enable adb shell dumpsys deviceidle步骤(让我们深入到IDLE) adb shell是设置无效的packageName true 经过上述过程后,我使用pixel / piexel3 XL(Android 9)测试呼叫流程。我通过OneSignal SDK发送了最高的FCM / GCM消息(优先级= 10),并希望我的活动可以开始。测试失败。手机处于活动状态时可以开始我的活动。我的OneSignal设置遵循NotificationExtenderBareBonesExample(https://documentation.onesignal.com/docs/android-customizations#section-background-data-and-notification-overriding

此示例说明如何让应用程序在不运行应用程序的情况下接收通知。我还尝试添加如下所示的Windows标志

>

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
    Log.d(this.getClass().toString(),"turn screen on!!!");
    Bugfender.d("onCreate", "turn screen on!!!");
    setShowWhenLocked(true);
    setTurnScreenOn(true);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    KeyguardManager keyguardManager = (KeyguardManager) this.getSystemService(KEYGUARD_SERVICE);
    if (keyguardManager != null) {
        keyguardManager.requestDismissKeyguard(this, new KeyguardManager.KeyguardDismissCallback() {
            @Override
            public void onDismissError() {
                super.onDismissError();
                Log.e(this.getClass().toString(), "Keyguard Dismiss Error");
                Bugfender.d("onCreate", "Keyguard Dismiss Error");
            }

            @Override
            public void onDismissSucceeded() {
                super.onDismissSucceeded();
                Log.d(this.getClass().toString(),"Keyguard Dismiss Success");
                Bugfender.d("onCreate", "Keyguard Dismiss Success");
            }

            @Override
            public void onDismissCancelled() {
                super.onDismissCancelled();
                Log.w(this.getClass().toString(), "Keyguard Dismiss Cancelled");
                Bugfender.d("onCreate", "Keyguard Dismiss Cancelled");
            }
        });
    }
}

我检查了我的日志消息,我的手机尝试启动该活动,但是该活动在创建后立即进入销毁状态。日志显示如下:

  

2019-05-16 19:00:52 +0800 UI android.app.Application.dispatchActivityPaused活动已暂停:IncomingCallActivity 2019-05-16 19:00:52 +0800 UI android.app.Application.dispatchActivityCreated活动已创建: VideoChatViewActivity 2019-05-16 19:00:53 +0800 UI android.app.Application.dispatchActivityStarted活动已开始:VideoChatViewActivity 2019-05-16 19:00:53 +0800 UI android.app.Application.dispatchActivityResumed恢复的活动已恢复:VideoChatViewActivity 2019 -05-16 19:00:53 +0800 UI android.app.Application.dispatchActivityPaused活动已暂停:VideoChatViewActivity 2019-05-16 19:00:53 +0800 UI android.app.Application.dispatchActivityStopped活动已停止:IncomingCallActivity 2019-05 -16 19:00:53 +0800 UI android.app.Application.dispatchActivityDestroyed活动销毁:IncomingCallActivity

我不知道为什么收到推送消息后我的活动无法继续进行。请给我建议

0 个答案:

没有答案