下面列出了android.provider.Settings#ACTION_SYNC_SETTINGS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void openSyncSettingsPage(Activity activity) {
// TODO(crbug/557784): This needs to actually take the user to a specific account settings
// page. There doesn't seem to be an obvious way to do that at the moment, but should update
// this when we figure that out.
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[] {"com.google"});
activity.startActivity(intent);
}
private static void showPromptForProfileManualRemoval(final Activity activity) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(activity).setMessage(R.string.dialog_cannot_destroy_message)
.setNegativeButton(android.R.string.ok, null);
final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
if (intent.resolveActivity(activity.getPackageManager()) == null) intent.setAction(Settings.ACTION_SETTINGS); // Fallback to entrance of Settings
if (intent.resolveActivity(activity.getPackageManager()) != null)
dialog.setPositiveButton(R.string.open_settings, (d, w) -> activity.startActivity(intent));
dialog.show();
Analytics.$().event("cannot_destroy").send();
}
public void requestToRemoveAccounts()
{
Toast.makeText(MainActivity.mainActivity, "Please remove all accounts before going back", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
MainActivity.mainActivity.startActivityForResult(intent, MainActivity.REQUEST_FIRST_SETUP_ADMINISTRATOR_PRIVILEGES);
}