Home > Mobile >  android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.locat
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.locat

Time:07-08

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

CodePudding user response:

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))

  • Related