I working on a flutter project which uses location services. There is one case where user 'denied permission forever', that time i need to open app location setting to turn it on and for that i'm using native code of kotlin. all code of native is working fine (checking using Log) but on startActivity(Intent(this, Settings.ACTION_LOCATION_SOURCE_SETTINGS::class.java)) it does not open that app location setting page and says the error

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.location/java.lang.String}; have you declared this activity in your AndroidManifest.xml?

anyone can help me get that specific location permission of my flutter app (dont share about 'app info page, phone location page) Thanks


Solution 1: user19309143

You are passing in Settings.ACTION_LOCATION_SOURCE_SETTINGS::class.java which calls the overloaded constructor Intent(Context packageContext, Class<?> cls).

What you are looking for is the constructor Intent(String action) where Settings.ACTION_LOCATION_SOURCE_SETTINGS is the action.

The actual call should look like: startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))