由于activity一到后台就会把进程优先级调低到
Background process,导致语音播报卡顿。
目前的解决方法好像只有把我们的initnavi,startnavi这2个接口放到一个service里面,
然后
在Service的onCreate方法中调用improvePriority来提高进程的优先级
- private void improvePriority() {
- PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
- new Intent(this, YourService.class), 0);
- Notification notification = new Notification.Builder(this)
- .setContentTitle("Foreground Service")
- .setContentText("Foreground Service Started.")
- .setSmallIcon(R.drawable.ic_launcher).setLargeIcon(null)
- .build();
- notification.contentIntent = contentIntent;
- startForeground(1, notification);
- }