I am launching an Settings.Panel.ACTION_INTERNET_CONNECTIVITY Intent from the app's MainActivity when the internet gets disconnected. When the user minimize the app without closing the Intent, the app's state is cleared and opens again from login when launched from packageManager.getLaunchIntentForPackage. But if the user close the opened Intent before minimizing the app, then the app can be opened from package manager with the current state as it is minimized.

I used the following code to launch the quick settings panel.

val panelIntent = Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY)
startActivityForResult(panelIntent,101)

Could someone show a way to close the Settings.Panel.ACTION_INTERNET_CONNECTIVITY Intent manually?

1

There are 1 answers

0
Mohamed Siad Z On

After trying to solve this for a day, I found out that this issue happens only if we launch the intent from an Activity. I tried launching this from a Broadcast Receiver(which i already had) like this:

                val panelIntent = Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY)
                panelIntent.flags =
                    Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                context.startActivity(panelIntent)

Now, the intent is auto closed when the app gets to background. Launching the app packageManager.getLaunchIntentForPackage worked as expected.