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: MainActivity.java    From music_player with Open Software License 3.0 6 votes vote down vote up
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 #2
Source File: PermissMeUtils.java    From PermissMe with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: MyApplication.java    From FaceSlim with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: NavigationBarObserver.java    From MNImageBrowser with GNU General Public License v3.0 6 votes vote down vote up
@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 #5
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: VolumePreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
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: NotificationChannels.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #8
Source File: PackageUtil.java    From android-common with Apache License 2.0 6 votes vote down vote up
/**
 * 打开已安装应用的详情
 */
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 #9
Source File: Rule.java    From kcanotify with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: BatteryStyleController.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
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 #11
Source File: MainActivity.java    From BS-Weather with Apache License 2.0 6 votes vote down vote up
/**
 * 显示对话框
 */
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 #12
Source File: MainActivity.java    From together-go with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #13
Source File: VinciActivityDelegate.java    From vinci with Apache License 2.0 6 votes vote down vote up
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 #14
Source File: MainActivity.java    From voip_android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 #15
Source File: Device.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: PermissionUtil.java    From FloatWindow with Apache License 2.0 5 votes vote down vote up
static boolean hasPermission(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return Settings.canDrawOverlays(context);
    } else {
        return hasPermissionBelowMarshmallow(context);
    }
}
 
Example #17
Source File: ScreenUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 设置进入休眠时长
 * @param duration 时长
 * @return {@code true} success, {@code false} fail
 */
@RequiresPermission(android.Manifest.permission.WRITE_SETTINGS)
public static boolean setSleepDuration(final int duration) {
    try {
        Settings.System.putInt(ResourceUtils.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, duration);
        return true;
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "setSleepDuration");
    }
    return false;
}
 
Example #18
Source File: ExpandedDesktopTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void setListening(boolean listening) {
    if (listening && mEnabled) {
        mExpanded = (Settings.Global.getInt(mContext.getContentResolver(),
                ModExpandedDesktop.SETTING_EXPANDED_DESKTOP_STATE, 0) == 1)
                && (mMode > 0);
        if (DEBUG) log(getKey() + ": mExpanded=" + mExpanded);
        mSettingsObserver.observe();
    } else {
        mSettingsObserver.unobserve();
    }
}
 
Example #19
Source File: OrientationListener.java    From WidgetCase with Apache License 2.0 5 votes vote down vote up
@Override
public void mtcSettingsSystemChanged(SettingsSystemObserver observer) {
    try {
        mAccelerometerRotation = Settings.System.getInt(
                mContext.getContentResolver(),
                Settings.System.ACCELEROMETER_ROTATION);
        LogUtil.logD("旋转", "mtcSettingsSystemChanged...");
    } catch (Settings.SettingNotFoundException e) {
        mAccelerometerRotation = 1;
        e.printStackTrace();
    }
}
 
Example #20
Source File: HapticFeedbackController.java    From cathode with Apache License 2.0 5 votes vote down vote up
/**
 * Call to setup the controller.
 */
public void start() {
    mVibrator = (Vibrator) mContext.getSystemService(Service.VIBRATOR_SERVICE);

    // Setup a listener for changes in haptic feedback settings
    mIsGloballyEnabled = checkGlobalSetting(mContext);
    Uri uri = Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED);
    mContext.getContentResolver().registerContentObserver(uri, false, mContentObserver);
}
 
Example #21
Source File: ScrollingActivity.java    From Android-TopScrollHelper with Apache License 2.0 5 votes vote down vote up
public void initTopScrollHelper() {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
            return;
        }
    }

    TopScrollHelper.getInstance(getApplicationContext()).addTargetScrollView(mNestedScrollView);

}
 
Example #22
Source File: DefaultAndroidEventProcessor.java    From sentry-android with MIT License 5 votes vote down vote up
@SuppressWarnings("ObsoleteSdkInt")
private @Nullable String getDeviceName() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    return Settings.Global.getString(context.getContentResolver(), "device_name");
  } else {
    return null;
  }
}
 
Example #23
Source File: ThetaOmnidirectionalImageProfile.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private boolean checkOverlayPermission() {
    final Context context = getContext();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (Settings.canDrawOverlays(context)) {
            return true;
        }

        final Boolean[] isPermitted = new Boolean[1];
        final CountDownLatch lockObj = new CountDownLatch(1);

        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
            Uri.parse("package:" + context.getPackageName()));
        IntentHandlerActivity.startActivityForResult(context, intent, new ResultReceiver(mHandler) {
            @Override
            protected void onReceiveResult(final int resultCode, final Bundle resultData) {
                isPermitted[0] = Settings.canDrawOverlays(context);
                lockObj.countDown();
            }
        });
        try {
            lockObj.await(60, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            return false;
        }
        return isPermitted[0] != null && isPermitted[0];
    } else {
        return true;
    }
}
 
Example #24
Source File: LocationNoticeActivity.java    From privacypolice with GNU General Public License v2.0 5 votes vote down vote up
private void openAppSettings() {
    Intent appSettingsIntent = new Intent();
    appSettingsIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri packageName = Uri.fromParts("package", getPackageName(), null);
    appSettingsIntent.setData(packageName);
    startActivity(appSettingsIntent);
}
 
Example #25
Source File: CondomContextBlockingTest.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
@Test public void testContentProviderOutboundJudge() {
	final TestContext context = new TestContext();
	final CondomOptions options = new CondomOptions().setOutboundJudge(new OutboundJudge() { @Override public boolean shouldAllow(final OutboundType type, final @Nullable Intent intent, final String target_pkg) {
		final String settings_pkg = InstrumentationRegistry.getTargetContext().getPackageManager().resolveContentProvider(Settings.System.CONTENT_URI.getAuthority(), 0).packageName;
		return ! settings_pkg.equals(target_pkg);
	}});
	final CondomContext condom = CondomContext.wrap(context, TAG, options), dry_condom = CondomContext.wrap(context, TAG, options.setDryRun(true));

	assertNull(condom.getPackageManager().resolveContentProvider(Settings.AUTHORITY, 0));
	assertNotNull(dry_condom.getPackageManager().resolveContentProvider(Settings.AUTHORITY, 0));
	assertNull(condom.getContentResolver().acquireContentProviderClient(Settings.System.CONTENT_URI));
	assertNotNull(dry_condom.getContentResolver().acquireContentProviderClient(Settings.System.CONTENT_URI));
}
 
Example #26
Source File: VoIPHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.UserFull userFull) {
	if (userFull != null && userFull.phone_calls_private) {
		new AlertDialog.Builder(activity)
				.setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
				.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable,
						ContactsController.formatName(user.first_name, user.last_name))))
				.setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
				.show();
		return;
	}
	if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) {
		boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
		AlertDialog.Builder bldr = new AlertDialog.Builder(activity)
				.setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle))
				.setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline))
				.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
		if (isAirplaneMode) {
			final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
			if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) {
				bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), (dialog, which) -> activity.startActivity(settingsIntent));
			}
		}
		bldr.show();
		return;
	}
	if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
		activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101);
	} else {
		initiateCall(user, activity);
	}
}
 
Example #27
Source File: EnergyWrapper.java    From styT with Apache License 2.0 5 votes vote down vote up
public int getBluetoothStatus()
   {
   	int iStatus = 0;
   	ContentResolver cr = mcontext.getContentResolver();
       try 
       {
    iStatus = Settings.Secure.getInt(cr, Settings.Secure.BLUETOOTH_ON);
       }
catch (SettingNotFoundException snfe)
{
    iStatus = 0;    }
       return iStatus;
   }
 
Example #28
Source File: XmsfApp.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: SettingsActivity.java    From citra_android with GNU General Public License v3.0 5 votes vote down vote up
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: Step1.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!(mList.getAdapter() instanceof AppAdapter)) {
        return super.onContextItemSelected(item);
    }
    final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    AppInfo info = ((AppAdapter) mList.getAdapter()).getList().get(menuInfo.position);
    switch (item.getItemId()) {
        case 1:
            try {
                Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                intent.setData(Uri.parse("package:" + info.packageName));
                startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(mCon, R.string.unsupport_of_package, Toast.LENGTH_SHORT).show();
            }
            break;
        case 2:
            PackageUtils.asyncStopProcess(info.packageName, new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(mCon, R.string.finish, Toast.LENGTH_SHORT).show();
                    EventBus.getDefault().post(new PageEvent(GuidePopupToast.Page.STARTING_APP.ordinal()));
                }
            }, mList);

            break;
        default:
            break;
    }
    return super.onContextItemSelected(item);
}