android-settings

How to pop up Enable Bluetooth prompt from Google Play Services?

左心房为你撑大大i 提交于 2019-12-05 17:27:55
Application I'm working on uses both Locations and BLE and if location or bluetooth are disabled I have to ask user to enable them. Latest Google Play Services provides a standard way to do that using LocationSettingsRequest which checks requirements and raises standard popup if changes to settings are required. It works like a charm for location alone but once I add SetNeedBle (true) to LocationSettingsRequest I get a status SETTINGS_CHANGE_UNAVAILABLE . The only my guess was I need to add AddApi (FitnessClass.BLE_API) call to a GoogleApiClientBuilder as it might be vital for BLE

Devices without “Apps using Usage Data” or android.settings.USAGE_ACCESS_SETTINGS intent

此生再无相见时 提交于 2019-12-05 12:01:39
Background: Android 5 introduced a new UsageStats API that can be used to query time spent with different apps. This API is used in several apps for detecting the current foreground app (as discussed in several questions, like this ), but: This API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application. As the permission is not presented to the user, apps send

Safeguard against “a matching Activity may not exist” in android settings

非 Y 不嫁゛ 提交于 2019-12-05 06:21:16
The majority of the Activity Actions (used to launch various Settings activities) in the Settings class come with a warning : In some cases, a matching Activity may not exist, so ensure you safeguard against this. So how do I safeguard against this ? try { final Intent i = new Intent(Settings. ACTION_WIRELESS_SETTINGS); // say i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // not sure if needed startActivity(i); } catch (Exception e) { // what should I catch here // I would hate to catch Throwable, but should I ? } If I read this correctly for instance a runtime exception (NPE) is thrown. I would

How to open and check whether Play Protect is enabled or disabled

拜拜、爱过 提交于 2019-12-04 11:25:16
minSdkVersion 18 targetSdkVersion 27 Using below code, I can able to open the Google Settings page. private static final String GOOGLE_SETTINGS_COMPONENT = "com.google.android.gms"; private static final String GOOGLE_SETTINGS_ACTIVITY = ".app.settings.GoogleSettingsActivity"; Intent i = new Intent(); i.setClassName(GOOGLE_SETTINGS_COMPONENT,GOOGLE_SETTINGS_COMPONENT + GOOGLE_SETTINGS_ACTIVITY); try { startActivity(i); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getApplicationContext(), "Activity Not Found", Toast.LENGTH_LONG).show(); } Is it possible to directly

open android settings from QT app(com.android.settings)

痞子三分冷 提交于 2019-12-04 07:37:53
I have an android application in QT. I would like to call android settings from a button. I used this code in Java : public void usb(View v){ Intent intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.DevelopmentSettings"); startActivity(intent); } Is there a way to call android settings using QT C++? QAndroidJniObject makes it possible to create JNI objects from Qt C++ code. For example: to get the activity: QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");

Android; detect if the Vibrate setting in the device is on or off, esp for the case when it rings but does not vibrate

孤人 提交于 2019-12-02 18:31:41
问题 App requirement: To detect when a phone is on Ringing mode with the Vibrate Setting being OFF so the problem comes down to : detect whether the Vibrate Setting is OFF or ON Relevant information: To start with, Vibrator has no method like isVibratorModeOn() and the Flags related to Vibrate and EXTRA_VIBRATE_... are all marked deprecated with: This constant was deprecated in API level 16. Applications should maintain their own vibrate policy based on current ringer mode that can be queried via

Android; detect if the Vibrate setting in the device is on or off, esp for the case when it rings but does not vibrate

无人久伴 提交于 2019-12-02 08:12:38
App requirement: To detect when a phone is on Ringing mode with the Vibrate Setting being OFF so the problem comes down to : detect whether the Vibrate Setting is OFF or ON Relevant information: To start with, Vibrator has no method like isVibratorModeOn() and the Flags related to Vibrate and EXTRA_VIBRATE_... are all marked deprecated with: This constant was deprecated in API level 16. Applications should maintain their own vibrate policy based on current ringer mode that can be queried via getRingerMode(). But under getRingerMode() , we won't exactly know if the vibrate setting is off or not

Android Lollipop App Notification Settings

岁酱吖の 提交于 2019-11-30 18:10:34
问题 In Android Lollipop, when you long press a Notification, it gives you access to settings for that Notification's app, such as priority, or simply blocking it. Is there an intent that I can use to access those settings? 回答1: Found the answer here - https://plus.google.com/+CyrilMottier/posts/YY6tbJrJMra You need to add this to the activity you want to be attached to that settings icon <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent

How to know whether Notifications are enabled or not for an application in android?

你。 提交于 2019-11-30 11:51:21
I've a ListView which has the list of installed applications and for each application, I need to know whether the notifications are enabled or not. Currently I'm using below code to know if the notifications are enabled: appOpsClass = Class.forName(AppOpsManager.class.getName()); Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE, String.class); Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION); int value = (int)opPostNotificationValue.get(Integer.class); return ((int)checkOpNoThrowMethod.invoke(mAppOps,value,

How to Enable Android Download Manager

拟墨画扇 提交于 2019-11-30 10:28:26
问题 I'm using Android Download Manager to download list of files. Lately I came across a crash report saying Unknown java.lang.IllegalArgumentException: Unknown URL content://downloads/my_downloads Then later, I figured it out that the reason is because user disabled Android Download Manager. I check if the Download Manager is disabled by checking it's package name with the code below. int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads"); And now, I