本文主要是介绍SystemUI接到通知播声音提示原理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在手机接收到notification的时候,有静音,震动,声音三种提示方式,特意说明下声音播放的触发流程:
在SystemUI启动的时候,会start()一个媒体播放类:
public class RingtonePlayer extends SystemUI {private static final String TAG = "RingtonePlayer";private static final String TAGG = "NotificationPlayer";private static final boolean LOGD = false | (SystemProperties.getInt("ro.debuggable", 0) == 1);// TODO: support Uri switching under same IBinderprivate IAudioService mAudioService;private final NotificationPlayer mAsyncPlayer = new NotificationPlayer(TAG);private final HashMap<IBinder, Client> mClients = new HashMap<IBinder, Client>();@Overridepublic void start() {mAsyncPlayer.setUsesWakeLock(mContext);mAudioService = IAudioService.Stub.asInterface(ServiceManager.getService(Context.AUDIO_SERVICE));try {//将一个媒体播放回调实例mCallback传递给AudioService.java mAudioService.setRingtonePlayer(mCallback);} catch (RemoteException e) {Log.e(TAG, "Problem registering RingtonePlayer: " + e);}}private IRingtonePlayer mCallback = new IRingtonePlayer.Stub() {@Overridepublic void play(IBinder token, Uri uri, int streamType) throws RemoteException {if (LOGD) {Log.d(TAG, "play(token=" + token + ", uri=" + uri + "
这篇关于SystemUI接到通知播声音提示原理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!