android.provider.Settings Java Examples
The following examples show how to use
android.provider.Settings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyApplication.java From FaceSlim with GNU General Public License v2.0 | 6 votes |
/** * Get Piwik tracker. No sensitive data is collected. Just app version, predicted location, * resolution, device model and system version. Location is based on anonymized IP address. * @return tracker instance */ public synchronized Tracker getTracker() { if (mPiwikTracker != null) return mPiwikTracker; try { mPiwikTracker = Piwik.getInstance(this).newTracker("http://indywidualni.org/analytics/piwik.php", 1); mPiwikTracker.setUserId(Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)); mPiwikTracker.setDispatchTimeout(30000); mPiwikTracker.setDispatchInterval(-1); } catch (MalformedURLException e) { Log.w("Piwik", "url is malformed", e); return null; } return mPiwikTracker; }
Example #2
Source File: NavigationBarObserver.java From MNImageBrowser with GNU General Public License v3.0 | 6 votes |
@Override public void onChange(boolean selfChange) { super.onChange(selfChange); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mApplication != null && mApplication.getContentResolver() != null && mListeners != null && !mListeners.isEmpty()) { int show = 0; if (OSUtils.isMIUI()) { show = Settings.Global.getInt(mApplication.getContentResolver(), IMMERSION_MIUI_NAVIGATION_BAR_HIDE_SHOW, 0); } else if (OSUtils.isEMUI()) { if (OSUtils.isEMUI3_x() || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { show = Settings.System.getInt(mApplication.getContentResolver(), IMMERSION_EMUI_NAVIGATION_BAR_HIDE_SHOW, 0); } else { show = Settings.Global.getInt(mApplication.getContentResolver(), IMMERSION_EMUI_NAVIGATION_BAR_HIDE_SHOW, 0); } } for (OnNavigationBarListener onNavigationBarListener : mListeners) { onNavigationBarListener.onNavigationBarChange(show != 1); } } }
Example #3
Source File: StorageManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void handleSystemReady() { initIfReadyAndConnected(); resetIfReadyAndConnected(); // Start scheduling nominally-daily fstrim operations MountServiceIdler.scheduleIdlePass(mContext); // Toggle zram-enable system property in response to settings mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.ZRAM_ENABLED), false /*notifyForDescendants*/, new ContentObserver(null /* current thread */) { @Override public void onChange(boolean selfChange) { refreshZramSettings(); } }); refreshZramSettings(); }
Example #4
Source File: NotificationChannels.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
/** * Updates the message ringtone for a specific recipient. If that recipient has no channel, this * does nothing. * * This has to update the database, and therefore should be run on a background thread. */ @WorkerThread public static synchronized void updateMessageRingtone(@NonNull Context context, @NonNull Recipient recipient, @Nullable Uri uri) { if (!supported() || recipient.getNotificationChannel() == null) { return; } Log.i(TAG, "Updating recipient message ringtone with URI: " + String.valueOf(uri)); String newChannelId = generateChannelIdFor(recipient); boolean success = updateExistingChannel(ServiceUtil.getNotificationManager(context), recipient.getNotificationChannel(), generateChannelIdFor(recipient), channel -> channel.setSound(uri == null ? Settings.System.DEFAULT_NOTIFICATION_URI : uri, getRingtoneAudioAttributes())); DatabaseFactory.getRecipientDatabase(context).setNotificationChannel(recipient.getId(), success ? newChannelId : null); ensureCustomChannelConsistency(context); }
Example #5
Source File: PackageUtil.java From android-common with Apache License 2.0 | 6 votes |
/** * 打开已安装应用的详情 */ public static void goToInstalledAppDetails(Context context, String packageName) { Intent intent = new Intent(); int sdkVersion = Build.VERSION.SDK_INT; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.fromParts("package", packageName, null)); } else { intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra((sdkVersion == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"), packageName); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
Example #6
Source File: VolumePreference.java From GravityBox with Apache License 2.0 | 6 votes |
private void initSeekBar(SeekBar seekBar, Uri defaultUri) { seekBar.setMax(mAudioManager.getStreamMaxVolume(mStreamType)); mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType); seekBar.setProgress(mOriginalStreamVolume); seekBar.setOnSeekBarChangeListener(this); // TODO: removed in MM, find different approach mContext.getContentResolver().registerContentObserver( System.getUriFor("volume_ring"), false, mVolumeObserver); if (defaultUri == null) { if (mStreamType == AudioManager.STREAM_RING) { defaultUri = Settings.System.DEFAULT_RINGTONE_URI; } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) { defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI; } else { defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI; } } mRingtone = RingtoneManager.getRingtone(mContext, defaultUri); if (mRingtone != null) { mRingtone.setStreamType(mStreamType); } }
Example #7
Source File: Rule.java From kcanotify with GNU General Public License v3.0 | 6 votes |
private static Intent getIntentDatasaver(String packageName, Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) synchronized (context.getApplicationContext()) { if (!cacheIntentDatasaver.containsKey(packageName)) { Intent intent = new Intent( Settings.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS, Uri.parse("package:" + packageName)); if (intent.resolveActivity(context.getPackageManager()) == null) intent = null; cacheIntentDatasaver.put(packageName, intent); } return cacheIntentDatasaver.get(packageName); } else return null; }
Example #8
Source File: MainActivity.java From BS-Weather with Apache License 2.0 | 6 votes |
/** * 显示对话框 */ public void showDialog(String title, String info, final int SIGN){ final AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); alertDialog.setMessage(info); alertDialog.setCancelable(false); alertDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (SIGN == SIGN_NO_INTERNET){ Intent intent = new Intent(Settings.ACTION_SETTINGS); startActivity(intent); TaskKiller.dropAllAcitivty(); } if (SIGN == SIGN_ALARMS){ alertDialog.setCancelable(true); } } }); alertDialog.show(); }
Example #9
Source File: MainActivity.java From together-go with GNU Lesser General Public License v3.0 | 6 votes |
private void initMoveManager() { if (Build.VERSION.SDK_INT < 23) { if (Settings.Secure.getInt(this.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, 0) == 0) { simulateLocationPermission(); } } random = new Random(); try { locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, true, false, false, true, true, true, 0, 5); locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true); } catch (SecurityException e) { simulateLocationPermission(); } }
Example #10
Source File: Device.java From MyHearts with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public static String getIdentifiers(Context ctx) { StringBuilder sb = new StringBuilder(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) sb.append(getPair("serial", Build.SERIAL)); else sb.append(getPair("serial", "No Serial")); sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID))); TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); sb.append(getPair("sim_country_iso", tel.getSimCountryIso())); sb.append(getPair("network_operator_name", tel.getNetworkOperatorName())); sb.append(getPair("unique_id", Crypto.md5(sb.toString()))); ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); sb.append(getPair("network_type", cm.getActiveNetworkInfo() == null ? "-1" : String.valueOf(cm.getActiveNetworkInfo().getType()))); return sb.toString(); }
Example #11
Source File: MainActivity.java From voip_android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myEditText = (EditText)findViewById(R.id.editText); peerEditText = (EditText)findViewById(R.id.editText2); String androidID = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); //app可以单独部署服务器,给予第三方应用更多的灵活性 //在开发阶段也可以配置成测试环境的地址 "sandbox.voipnode.gobelieve.io", "sandbox.imnode.gobelieve.io" String sdkHost = "imnode2.gobelieve.io"; IMService.getInstance().setHost(sdkHost); IMService.getInstance().setIsSync(false); IMService.getInstance().registerConnectivityChangeReceiver(getApplicationContext()); IMService.getInstance().setDeviceID(androidID); }
Example #12
Source File: PermissMeUtils.java From PermissMe with Apache License 2.0 | 6 votes |
/** * The onClickListener that takes you to the app's system settings screen * * @param activity * the caller activity used to start the settings intent * @return the {@link View.OnClickListener} */ public static View.OnClickListener createSettingsClickListener(final Activity activity) { return new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + activity.getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); activity.startActivity(intent); } }; }
Example #13
Source File: MainActivity.java From music_player with Open Software License 3.0 | 6 votes |
private void setAsRingtone(final Activity context, int position) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(context)) { Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + context.getPackageName())); context.startActivity(intent); } else { File music = new File(MyApplication.getMusicListNow().get(position).getMusicData()); // path is a file to /sdcard/media/ringtone ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, music.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, MyApplication.getMusicListNow().get(position).getMusicTitle()); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, MyApplication.getMusicListNow().get(position).getMusicArtist()); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, false); //Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(music.getAbsolutePath()); context.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + music.getAbsolutePath() + "\"", null); Uri newUri = context.getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, newUri); Toast.makeText(context, "已成功设置为来电铃声", Toast.LENGTH_SHORT).show(); //Snackbar // Snackbar.make(mLayout, "已成功设置为来电铃声", Snackbar.LENGTH_LONG).show(); } }
Example #14
Source File: VinciActivityDelegate.java From vinci with Apache License 2.0 | 6 votes |
protected void onCreate(Bundle savedInstanceState) { boolean needsOverlayPermission = false; if (getReactNativeHost().getUseDeveloperSupport() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Get permission to show redbox in dev builds. if (!Settings.canDrawOverlays(getContext())) { needsOverlayPermission = true; Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getContext().getPackageName())); FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE); Toast.makeText(getContext(), REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show(); ((Activity) getContext()).startActivityForResult(serviceIntent, REQUEST_OVERLAY_PERMISSION_CODE); } } if (mMainComponentName != null && !needsOverlayPermission) { loadApp(mMainComponentName); } mDoubleTapReloadRecognizer = new DoubleTapReloadRecognizer(); }
Example #15
Source File: BatteryStyleController.java From GravityBox with Apache License 2.0 | 6 votes |
private void initPreferences(XSharedPreferences prefs) { mPrefs = prefs; mBatteryStyle = Integer.valueOf(prefs.getString( GravityBoxSettings.PREF_KEY_BATTERY_STYLE, "1")); mBatteryPercentTextEnabledSb = prefs.getBoolean( GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_STATUSBAR, false); mBatteryPercentTextHeaderHide = prefs.getBoolean( GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_HEADER_HIDE, false); mBatteryPercentTextKgMode = KeyguardMode.valueOf(prefs.getString( GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_KEYGUARD, "DEFAULT")); mMtkPercentTextEnabled = Utils.isMtkDevice() ? Settings.Secure.getInt(mContext.getContentResolver(), SETTING_MTK_BATTERY_PERCENTAGE, 0) == 1 : false; mBatterySaverIndicationDisabled = prefs.getBoolean( GravityBoxSettings.PREF_KEY_BATTERY_SAVER_INDICATION_DISABLE, false); }
Example #16
Source File: OnboardingActivity.java From oversec with GNU General Public License v3.0 | 5 votes |
@Override protected void onResume() { super.onResume(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Ln.d("yeah, onResume "+ Settings.canDrawOverlays(this)); } }
Example #17
Source File: PermissionBuilder.java From PermissionX with Apache License 2.0 | 5 votes |
/** * Go to your app's Settings page to let user turn on the necessary permissions. * * @param permissions Permissions which are necessary. */ private void forwardToSettings(List<String> permissions) { forwardPermissions.clear(); forwardPermissions.addAll(permissions); Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); getInvisibleFragment().startActivityForResult(intent, InvisibleFragment.FORWARD_TO_SETTINGS); }
Example #18
Source File: MockApplicationModule.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
/** * Stops inconsistent failed test from happening in Landscape Wizard */ @Override IdsRepository provideIdsRepository(SharedPreferences defaultSharedPreferences, ContentResolver contentResolver) { return new IdsRepository( SecurePreferencesImplementation.getInstance(application.getApplicationContext(), defaultSharedPreferences), application, Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)) { @Override @WorkerThread public synchronized String getGoogleAdvertisingId() { return defaultSharedPreferences.getString("googleAdvertisingId", null); } }; }
Example #19
Source File: HeadsUpVolumePanel.java From Noyze with Apache License 2.0 | 5 votes |
void openMusic() { hide(); if (hasAlbumArt) { launchMusicApp(); } else { Intent volumeSettings = new Intent(Settings.ACTION_SOUND_SETTINGS); startActivity(volumeSettings); } }
Example #20
Source File: ItemActivity.java From Fairy with Apache License 2.0 | 5 votes |
private void requestPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!Settings.canDrawOverlays(this)) { Toast.makeText(this, getResources().getString(R.string.grand_window_permission), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse(String.format("package:%s", getPackageName()))); startActivityForResult(intent, PERMISSION_RESULT_CODE); } } }
Example #21
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 5 votes |
/** @return The default {@link android.content.Intent#ACTION_MEDIA_BUTTON} receiver, or null. */ public ComponentName getMediaButtonReceiver() { String receiverName = Settings.System.getString( getContext().getContentResolver(), Constants.getMediaButtonReceiver()); if ((null != receiverName) && !receiverName.isEmpty()) return ComponentName.unflattenFromString(receiverName); return null; }
Example #22
Source File: Sandman.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static boolean isScreenSaverActivatedOnDock(Context context) { int def = context.getResources().getBoolean( com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault) ? 1 : 0; return Settings.Secure.getIntForUser(context.getContentResolver(), Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, def, UserHandle.USER_CURRENT) != 0; }
Example #23
Source File: Utilities.java From LiveBlurListView with Apache License 2.0 | 5 votes |
public static boolean isAutoBrightness(ContentResolver aContentResolver) { boolean automicBrightness = false; try { automicBrightness = Settings.System.getInt(aContentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } catch (SettingNotFoundException e) { e.printStackTrace(); } return automicBrightness; }
Example #24
Source File: MainActivity.java From together-go with GNU Lesser General Public License v3.0 | 5 votes |
private void showFilter() { if (Build.VERSION.SDK_INT > 22) { if (Settings.canDrawOverlays(this)) { windowManager.addView(filterView, filterLayoutParams); } } //showPets(); }
Example #25
Source File: AccessibilityUtil.java From RelaxFinger with GNU General Public License v2.0 | 5 votes |
public static boolean checkAccessibility() { int accessibilityEnabled = 0; final String service = context.getPackageName() + "/" + NavAccessibilityService.class.getCanonicalName(); boolean accessibilityFound = false; try { accessibilityEnabled = Settings.Secure.getInt( context.getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ACCESSIBILITY_ENABLED); } catch (Settings.SettingNotFoundException e) { Log.e("ACBU","Error finding setting, default accessibility to not found: " + e.getMessage()); } TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':'); if (accessibilityEnabled == 1) { String settingValue = Settings.Secure.getString( context.getApplicationContext().getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES); if (settingValue != null) { TextUtils.SimpleStringSplitter splitter = mStringColonSplitter; splitter.setString(settingValue); while (splitter.hasNext()) { String accessabilityService = splitter.next(); if (accessabilityService.equalsIgnoreCase(service)) { return true; } } } } else { Log.i("ACBU","***ACCESSIBILIY IS DISABLED***"); } return accessibilityFound; }
Example #26
Source File: MainActivity.java From journaldev with MIT License | 5 votes |
private void askForSystemOverlayPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) { //If the draw over permission is not available open the settings screen //to grant the permission. Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, DRAW_OVER_OTHER_APP_PERMISSION); } }
Example #27
Source File: WindowManagerActivity.java From Android-skin-support with MIT License | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 10) { if (Settings.canDrawOverlays(this)) { startWindowService(); } else { Toast.makeText(WindowManagerActivity.this, "not granted", Toast.LENGTH_SHORT).show(); } } }
Example #28
Source File: MainMenu.java From MifareClassicTool with GNU General Public License v3.0 | 5 votes |
/** * Create a dialog that send user to NFC settings if NFC is off. * Alternatively the user can chose to use the App in editor only * mode or exit the App. * @return The created alert dialog. * @see #runSartUpNode(StartUpNode) */ private AlertDialog createNfcEnableDialog() { return new AlertDialog.Builder(this) .setTitle(R.string.dialog_nfc_not_enabled_title) .setMessage(R.string.dialog_nfc_not_enabled) .setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(R.string.action_nfc, (dialog, which) -> { // Goto NFC Settings. if (Build.VERSION.SDK_INT >= 16) { startActivity(new Intent( Settings.ACTION_NFC_SETTINGS)); } else { startActivity(new Intent( Settings.ACTION_WIRELESS_SETTINGS)); } }) .setNeutralButton(R.string.action_editor_only, (dialog, which) -> { // Only use Editor. useAsEditorOnly(true); runSartUpNode(StartUpNode.DonateDialog); }) .setNegativeButton(R.string.action_exit_app, (dialog, id) -> { // Exit the App. finish(); }) .setOnCancelListener( dialog -> finish()) .create(); }
Example #29
Source File: SettingsActivity.java From citra_android with GNU General Public License v3.0 | 5 votes |
private boolean areSystemAnimationsEnabled() { float duration = Settings.Global.getFloat( getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 1); float transition = Settings.Global.getFloat( getContentResolver(), Settings.Global.TRANSITION_ANIMATION_SCALE, 1); return duration != 0 && transition != 0; }
Example #30
Source File: XmsfApp.java From MiPushFramework with GNU General Public License v3.0 | 5 votes |
private HashSet<ComponentName> loadEnabledServices() { HashSet<ComponentName> hashSet = new HashSet<>(); String string = Settings.Secure.getString(getContentResolver() , "enabled_notification_listeners"); if (!(string == null || "".equals(string))) { String[] split = string.split(":"); for (String unflattenFromString : split) { ComponentName unflattenFromString2 = ComponentName.unflattenFromString(unflattenFromString); if (unflattenFromString2 != null) { hashSet.add(unflattenFromString2); } } } return hashSet; }