简体   繁体   中英

App screen is freezes when It is opened from background service and phone screen is locked

I am opening my app from background when it receives a notification. For this I am using a service. Whenever my app is in background and a new notification comes, app will open automatically. It is working fine. But when app is in background and phone screen is locked, now when a notification will come, it will show on screen(locked screen) and when user will open phone lock, my app's screen will be visible but screen will not responding, screen colour will also be like greyish layout on it.

To open app I am using a service, code is:

Intent serviceIntent = new Intent(getApplicationContext(), NewTaskService.class);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        startForegroundService(serviceIntent);
                    } else {
                        startService(serviceIntent);
                    }

In NewTaskService Class I am opening my app.

The resulted screen image when app is opened with notification from on lock screen is attached.

It seems like app is doing much work on main thread. Why don't you try to push your code in multi-thread or use Asynchronized class that handles everything in background

Basically it was due to a dialog box. When app is opened and user unlocks mobile screen, dialog box disappears but screen is visible like there is a dialog box. Screen was not freeze nor stuck, also it was greyish type due to that dialog box. Because in such scenario dialog box view disappears.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM