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.
Related
Some users are reporting on Huawei EMUI 8.0 Oreo that the Notification Channel does not have the option to change tone "Sound" / "Notification Tone" from the app!
As of the official docs the developer can't change the settings anymore.
So how can I add an option for Huawei phones to change the "Notification Tone" again?
And does anyone know why the hell Huawei removed this feature?
I don't find official docs from Huawei how we can now let the user change the notification tone.
Offical docs I am referring:
https://developer.android.com/reference/android/app/NotificationChannel.html
https://developer.android.com/reference/android/app/NotificationChannel.html#setSound(android.net.Uri, android.media.AudioAttributes)
We ran into the same issue recently.
It is not a nice solution, but WhatsApp is doing the same.
Basically we show a ringtone selection inside our app and then delete and recreate the notification channel with a new channel id and the selected ringtone uri. You can copy most settings made to the channel to the new one except 'do not disturb'.
Like I said it is not a nice solution and I don't know what will happen if the channel is recreated a lot. But hopefully the ringtone is not changed too often.
Note: The notification settings screen displays the number of deleted channels, as a spam prevention mechanism.
Faced with same issue on chinese devices. Firstly, i have same solution like describe #Devenias. How it works in system: when you're defining a new channel, NotificationService save this channel in xml, after you changed it, it still contains in this xml. So on a new change of channel, NotificationService will check if it have a channel with a same name, and just retrieve it. So i make new channel with a new settings all the time, when user change vibration or ringtone in app. Also it works like a cache, just make unique channel name for pair<ringtone, vibration>. This solution is pretty hacky, since it works good on Honor's, Huawei's, Samsung's devices and Xiaomi Mi A1, but it have been crashing NotificationService with NullPointer in SystemUI on Xiaomi Mi Mix 2 (device make soft reboot, if SystemUI service crashed), so don't use this solution.
So nowadays a safe workaroud is to play sound and vibration manually.
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
I'm developing an Android app which supports Chromecast and to do that I'm using a combination of MinimalCastMediaRouteProvider + a custom receiver. All is well with the playback but the Chomecast UX guide has a section headed Cast menu functions appropriately for available receiver devices. It seems to state that when the Chromecast device is already connected to a service it should have a label indicating it, like the following with netflix:
The issue is that on my device all I see is this:
where it's missing the "casting xxx" while I have another device casting to it. Is there something I need to set in my receiver app or is it something in the Android code? I don't see any documentation about it.
You don't need to do anything on your side at this point; there is currently a bug in the preview sdk that doesn't let that to work properly.
I have an SBH50 from Sony this one, http://www.sonymobile.com/global-en/products/accessories/stereo-bluetooth-headset-sbh50/, (not the MW1).
I've been wasting time trying to make work the sample control app which sony provides in the Add On SDK.
I was able to run the notification API example, it creates a new item in the 'Events list'. But I cant do the same with the Control API.
Btw, I cant either debug the app. I mean, I put a breakpoint in the same point a log is made, and the log IS made, but the debug does not stops there.
I just want to capture a key event.
The Control API isn't supported on the SBH50, only the Notification API as you have noted above.
In order to debug try running your extension in debug mode, then in DDMS select the running task and press the debug button. Then it should stop at your breakpoints.
It seems Sony has just released new add-on API to control the SBH50 as well. Please refer to link below:
http://developer.sonymobile.com/2013/11/12/sony-add-on-sdk-updated-adds-support-for-stereo-bluetooth-headset-sbh50-and-smart-bluetooth-handset-sbh52/
I want to develop an application that disables the Background Data (new feature in Android 1.5) and Auto Sync and then enables GPRS/EDGE connection and vice versa.
I figured out how to enable/disable GPRS/EDGE by changing the APN settings. (weird solution. However; Android developers couldn't think a user may want to disable GPRS/EDGE) But, I couldn't find a way to enable/disable Auto Sync and Background data.
I investigated the Android code and as I understood, the Sync operation is an intent. So, I wanted to reach with putExtra to the intent and trigger the enabling/disabling. But; I couldn't find the correct keyword. Or maybe I was totally wrong.
What is the right way to solve this?
In my HTC dreams, there is a checkbox to disable the auto sync. I can look for the menu arborescence if you wish so you can find what the callback function is in the Android source code. But I am pretty sure auto sync cannot be completely disabled. Unchecking auto sync will prevent sync from being performed on a timed basis, but it will occur everytime you run an app with sync capabilities if any network data connection is available.
Good luck anyway.
EDIT :
There are two ways to get the info you desire.
First, I think you can use the code in android-sources/packages/apps/Settings/src/com/android/settings/Utils.java to create an activity that will enlist all the keys of the intent then find the one you want.
The other way is to write a nice mail to the guy who made the Toggle Setting app (http://smartphoneandroid.com/2008/12/28/toggle-setting-perfect-app-for-android-phone.html) since he obviously found a solution to your problem. His email address is written in the app sheet on the android market. I won't write it here, but if you do not have access to real android phone, I can mail it to you on your mail address.
Background data is a secure setting, so cannot be changed by user applications. But bear in mind, it's just a setting - it's not enforced. Apps are meant to read it and respect it but I bet some don't.
To Disable the AutoSynch
ContentResolver.setMasterSyncAutomatically(false);
To Enable the AutoSynch
ContentResolver.setMasterSyncAutomatically(true);
Permission you require is
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
setMasterSyncAutomatically() on ContentResolver should do it. Check: general-sync-settings-auto-sync-checkbox-programtically