Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening Google settings on Android 6+ programmatically

Tags:

android

I'm trying to make a shortcut in my app for opening Google settings (or even better, for submenu "Ads"). While this is possible in Android version up to 5.1.1 by using the code

public void openGsettings(View view){
    Intent googleSettings = new Intent();
    googleSettings.setPackage("com.google.android.gms");
    googleSettings.addCategory(Intent.CATEGORY_LAUNCHER);
    startActivity(googleSettings);
}

and calling it on click, this doesn't really work on Android 6.0 and later as it's not a separate "app" anymore and is located in the system settings instead, so my app just crashes when I press the button.

I know it is possible as I've seen it in another app, but I can't figure out what should I call. Looked through Google documentation and there doesn't seem to be an action for this part of the settings either.

like image 762
bacje16 Avatar asked Sep 02 '25 05:09

bacje16


1 Answers

Co-worker gave me an answer, so I'm sharing it for anyone else that needs it (this one points to "Ads" section specifically):

String action = "com.google.android.gms.settings.ADS_PRIVACY";
    startActivity(new Intent(action));
like image 179
bacje16 Avatar answered Sep 04 '25 19:09

bacje16