Я пытаюсь изменить системную громкость в приложении Android, работающем на A14.
Ниже приведен мой код, но я столкнулся с ошибкой компиляции.
// с помощью carAudioManager чтобы изменить громкость
Код: Выделить всё
Car car = Car.createCar(context);
this.mCarAudioManager = (CarAudioManager) car.getCarManager(Car.AUDIO_SERVICE);
if(this.mCarAudioManager != null) {
int zoneId = PRIMARY_AUDIO_ZONE;
final int flags = 1; // to show the UI
int index = volumeToSet;
int groupId = 0;
this.mCarAudioManager.setGroupVolume(zoneId, groupId, index, flags);
} else {
Log.e(TAG, "CarAudioManager is null");
}
error: cannot find symbol
this.mCarAudioManager.setGroupVolume(zoneId, groupId, index, flags);
^ symbol: method setGroupVolume(int,int,int,int)
in the gradle file i have imported the library
useLibrary 'android.car'
These are the imports used
// change volume
Код: Выделить всё
import android.car.Car;
import android.car.media.CarAudioManager;
import android.content.Context;
import java.lang.reflect.Method;
Источник: https://stackoverflow.com/questions/781 ... io-manager