ChromeOS startActivity does not work if I close app (X top right) and get a notification

65 views Asked by At

I have a ChromeOS 100 Acer Chromebook 314. I open the app, I am logged in, and after that I will close it from the top-right corner. Then I receive a notification and I run this code:

 try {
                    val intentActivity = Intent(context, IncomingCallActivity::class.java)
                    intentActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
                    context.startActivity(intentActivity)
                } catch (e: Exception) {
                    FL.e(TAG, "makeCall()::Failed -> cannot start activity: ${e.message}")
                }

This does not fail, but does not open the activity neither.

I have also tried:

  PendingIntent.getActivity(context, 12346, intentActivity, PendingIntent.FLAG_IMMUTABLE).send()

But same issue. This works fine on phones. BUT on phones I am running this from the ConnectionService.onShowIncomingCall. I cannot use that because there is no ConnectionService in the chromeOS api. Any idea I can make my activity appear properly always?

1

There are 1 answers

0
rosu alin On BEST ANSWER

Fixed it by requesting permission to drawOverlays

 if (!Settings.canDrawOverlays(context)) {
                    val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:${context.packageName}"))
                    resultLauncher.launch(intent)
                }