Solved by putting boolean key "fromApp" in SharedPreferences and check it in SystemSettingsChangeObserverService, then set the key to false
Delayed nottification about settings changed
Вопрос
I have method which sets stream volumes and service which has Hadler inside for checking this changes
Method for settings streams:
private setStreams(Context context)
{
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setStreamVolume(AudioManager.STREAM_RING, ringerVol, 0);
am.setStreamVolume(AudioManager.STREAM_NOTIFICATION, notifVol, 0);
am.setStreamVolume(AudioManager.STREAM_MUSIC, mediaVol, 0);
am.setStreamVolume(AudioManager.STREAM_ALARM, alarmVol, 0);
am.setStreamVolume(AudioManager.STREAM_SYSTEM, systemVol, 0);
am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, incallVol, 0);
am.setStreamVolume(6, btVol, 0);
//some other code
}
Serivce:
public class SystemSettingsChangeObserverService extends Service {
private ContentObserver observer;
private static Context context;
@Override
public void onCreate(){
super.onCreate();
context = this;
observer = new ContentObserver (new Handler()) {
@Override
public boolean deliverSelfNotifications() {
return super.deliverSelfNotifications();
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
//here I check new values of streams
}
}
...
Problem is, that onChange is called after "some other code" in setStreams method and not after setStreamVolume for every stream. I need this because I needto know if volumes was changed inside my application or by other way. Thank you.
Решение
Не связан с StackOverflow