On the new Android 5.0 Lollipop a new setting was added on the Developer Options called "Use NuPlayer (beta)". My app sometimes is not working well when this setting is enabled. I'm afraid when the new version of Android gets released to the public many people would enable it and have problems with my app without knowing what is wrong.
So I wanted to display a warning message about this only if the NuPlayer setting is checked on the device. I tried looking for it on the documentation of Android but I couldn't find how to access the status of this new setting.
So the question is that, how can I check the value of this setting programatically?
Thanks
I'm cross-posting my answer from here by request:
Prevent my audio app using NuPlayer on Android Lollipop 5.x?
So, I finally found a way to safely detect wether or not NuPlayer will be used or not on Lollipop. Seems like the best strategy for now is to inform the user to open Developer Settings and enable AwesomePlayer until Google fixes NuPlayer.
Sadly, there's no good way to change this setting for the user, we can just read its value unless you're signed as a system application.
This approach checks Android's system properties values to see if the user have enabled the use of AwesomePlayer or not under Developer Settings. Since Lollipop have NuPlayer on by default, if this value is disabled, we know NuPlayer will be used.
Drop SystemProperties.java into your project for access to read the system properties, do not change its package name from android.os (it calls through to its corresponding JNI methods, so needs to stay the same).
You can now check if the phone is Lollipop/5.0, if AwesomePlayer is enabled, and act accordingly if it's not (e.g. by opening the Developer Settings):
public void openDeveloperSettingsIfAwesomePlayerNotActivated(final Context context) {
final boolean useAwesome = SystemProperties.getBoolean("persist.sys.media.use-awesome", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !useAwesome) {
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
context.startActivity(intent);
}
}
Related
In the documentation, I saw that
showInputMethodPicker
Added in API level 3
public void showInputMethodPicker ()
Show IME picker popup window.
Requires the PackageManager#FEATURE_INPUT_METHODS feature which can be detected using PackageManager#hasSystemFeature(String).
I don't know how to add `FEATURE_INPUT_METHODS to enable the choose keyboard popup.
System features are set by device manufacturers, based on the device capabilities. An app does not add them.
The statement in the documentation about FEATURE_INPUT_METHODS is so that you can detect if the device that your app runs on supports input methods, so you know whether it makes sense to call showInputMethodPicker() or not.
I’m looking out for a solution in React native to check if notifications is enabled for Android. If not, enable them. I found out a library (React-native-android-permission-library) which works great. But my question here is I find that notification is enabled by default in our app without specifying in Manifest.xml. I did a bit of reading and found Access_Notification_policy is used for notification which is added as part of API level 23 and that has been considered as Normal permission.
My question here
1. Does all Android apps including our app have notification enabled by default. Is this always be the case?
2. Even lot of permissions are considered as normal, still I believe that it’s not enabled by default.
2. In case notifications are enabled by default, I’m not sure if I still need to check if notification is enabled?
3. Also found somewhere that notification is enabled when your device is registered for location. If this is the case, Can I assume that all devices are registered for location by default.
Please advise.
Android 5.0 includes a new way to control which apps are allowed to make noise on your device: when you press the volume button, the popup now lets you to choose None (completely silent), Priority (only priority notifications make sound), or All (everything is allowed to make noise.)
I would like my app to be able to query the device to find out which of these three modes is currently active, and also I would like to be able to change these modes (without requiring the device to be rooted). Does anyone know how to do this?
So far, all I can find is a brief reference on this changelog:
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
This works as described, which allows me a very limited ability to change "priority mode" by modifying the ringer mode in AudioManager. That's not enough, though, as I need to be able to know exactly which of the three priority mode settings is currently active, and it would also be nice if I could change them more precisely than AudioManager allows.
I've found a solution, but this requires root to change, because this setting is in Settings.Global.
Name of setting is "zen_mode".
Values are:
ZENMODE_ALL = 0;
ZENMODE_PRIORITY = 1;
ZENMODE_NONE = 2;
EDIT: I've found another solution. Check NotificationListenerService.requestInterruptionFilter(int interruptionFilter). https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
Implementation example: https://github.com/kpbird/NotificationListenerService-Example
Just tested my app on new Android 5.0 and found that it have some bug in switching ringer mode via Audio Manager. After set RINGER_MODE_SILENT it comes to "Allow only priority interruptions" mode and it's ok, it's how described in what's new document. But after set RINGER_MODE_NORMAL phone doesn't come back to "Always interrupt" and this is not expected behavior. User can miss the call because of it.
Does someone find solution/work around this problem? How can I turn off this filtration mode?
Update
Found this code in Android src. This settings is Global.ZEN_MODE. And code that should change it on set NORMAL_MODE looks like correct, but it doesn't work in Emulator and Nexus ROM. Had try to set via Settings.Global.putInt, but got error about permissions. Have no idea how to fix it =(
Made bug report: https://code.google.com/p/android/issues/detail?id=78158&thanks=78158&ts=1414182304
And in preview tracker https://code.google.com/p/android-developer-preview/issues/detail?id=1780&thanks=1780&ts=1414218141
Just found some work around. We can use NotificationListenerService.requestInterruptionFilter to change filtration mode. It works, but you have to add your service in "Notification access" list (it's in Sound & notification settings), otherwise you will have no permissions.
I am making a Utility app for my galaxy nexus. I want to reboot my tablet in safe mode.
I tried to look in PowerManager
PowerManager p = (PowerManager) getSystemService(POWER_SERVICE);
p.reboot(reason);
It seems this will not reboot the device in safe mode. Is it possible to reboot the device programmatically? How?
Basically there are two known ways to enter Safe Mode:
Android detects a problem with a newly installed app and force-closes it while entering into Safe Mode.
A combination of key presses at power application;
I doubt there's yet another way of doing it. If there was, most recoveries and power menus of Custom ROMS would have included that.
The string passed to reboot() is a kernel param, and would have effect only if device's kernel has that option. You can try some options here.
UPDATE:
Safe Mode is toggle is inside PackageManagerService of Android's system server ("package" service):
public void enterSafeMode() {
enforceSystemOrRoot("Only the system can request entering safe mode");
if (!mSystemReady) {
mSafeMode = true;
}
}
and here are some points about using it from any APP :
Process executing this code must be System or have Root previleges
This is an internal service and off-limits to any outside code. Though, some system classes indeed get implementation stubs (IPackageManager) of this service.
The mode change can only be useful when system is yet to be ready.
Let's suppose your app does turn on safe mode some how, due to safe mode being enabled, it won't be around to turn it off. Unless its a system app, built into ROM.
A third way to enter safe mode (available sometime after GingerBread 2.3.5)
With device fully powered up, Press power button, and the LONG press on the power off menu item. An option appears to go into safe mode. Because of this, there may now be a way to programmaticaly enter safe mode. Sure hope so to help troubleshoot. i am going from memory on a lifehacker article which referenced yet another source.