给高德车机版发送导航数据时,logcat提示
W/BroadcastQueue: Background execution not allowed: receiving Intent { act=AUTONAVI_STANDARD_BROADCAST_RECV flg=0x30 (has extras) } to com.autonavi.amapauto/.adapter.internal.AmapAutoBroadcastReceiver
使用下面的指定包名的显示intent,就可以突破系统限制
Intent intent = new Intent();
//这里用显示 intent,因为车机版是注册的静态广播
ComponentName cn = new ComponentName("com.autonavi.amapauto"
,"com.autonavi.amapauto.adapter.internal.AmapAutoBroadcastReceiver");
intent.setComponent(cn);
下面记录一下用到的api
Intent intent = new Intent();
//这里用显示 intent,因为车机版是注册的静态广播
ComponentName cn = new ComponentName(amapCheJiPkg
,"com.autonavi.amapauto.adapter.internal.AmapAutoBroadcastReceiver");
intent.setComponent(cn);
intent.setAction("AUTONAVI_STANDARD_BROADCAST_RECV");
/**
* 10038 这个可以直接发起导航,不用规划
*/
intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.putExtra("KEY_TYPE", 10038);
intent.putExtra("POINAME", destinationTitle);
intent.putExtra("LAT", Double.parseDouble(lat));
intent.putExtra("LON", Double.parseDouble(lon));
intent.putExtra("DEV", 0);
intent.putExtra("STYLE", 0);
intent.putExtra("SOURCE_APP", context.getString(R.string.app_name));
context.sendBroadcast(intent);