导航软件后台播放语音有杂音,卡顿

来源:互联网 发布:阿里云免费邮箱申请 编辑:程序博客网 时间:2024/04/28 14:22
由于activity一到后台就会把进程优先级调低到Background process,导致语音播报卡顿。

目前的解决方法好像只有把我们的initnavi,startnavi这2个接口放到一个service里面,
然后在Service的onCreate方法中调用improvePriority来提高进程的优先级

  1. private void improvePriority() {  
  2.     PendingIntent contentIntent = PendingIntent.getActivity(this0,  
  3.             new Intent(this, YourService.class), 0);  
  4.     Notification notification = new Notification.Builder(this)  
  5.             .setContentTitle("Foreground Service")  
  6.             .setContentText("Foreground Service Started.")  
  7.             .setSmallIcon(R.drawable.ic_launcher).setLargeIcon(null)  
  8.             .build();  
  9.     notification.contentIntent = contentIntent;  
  10.     startForeground(1, notification);  
  11. }  
0 0
原创粉丝点击