0

I'm facing the known issue onActivityResult getting called immediately.

I read the reason behind it on some link

where it is advice to change launch mode of called activity.

But in my case I'm starting(navigating to) settings activity, to let the user enable data connection.

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS),
                            Constants.REQUEST_ENABLE_DATA_CONNECTION);

So I can't change launch mode of Settings activity.

I tried setting some flags to Intent e.g. intent.setFlags(0); but its not working.

Community
  • 1
  • 1
Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111

1 Answers1

0

I think there is some problem with your request code "Constants.REQUEST_ENABLE_DATA_CONNECTION".What is your request code value. I think you should use zero "0" value like this.

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

but if you need to open wifi settings then use this code.

startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

and see this Setting actions link for other setting actions.

I hope,this will help you.

Zohaib Hassan
  • 984
  • 2
  • 7
  • 11