Code: Select all
public class CarScreen extends Screen {
private static String message = "We will notify you!!";
private int icon = R.drawable.ic_ts_icon_logo;
private int templateType = 1;
public CarScreen(CarContext carContext) {
super(carContext);
// Initialize the BroadcastReceiver
CarBroadcastReceiver carBroadcastReceiver = new CarBroadcastReceiver(this);
// Register the BroadcastReceiver
IntentFilter filter = new IntentFilter();
filter.addAction(Constants.ANDROID_AUTO_ALERT);
filter.addAction(Constants.ANDROID_AUTO_ARROW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
carContext.registerReceiver(carBroadcastReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
carContext.registerReceiver(carBroadcastReceiver, filter);
}
}
@NonNull
@Override
public Template onGetTemplate() {
Template template = null;
if (templateType == 1) {
CarIcon carIcon = CommonFunctions.createCarIcon(getCarContext(), icon);
template = new MessageTemplate.Builder(message)
.setTitle("Warning")
.setHeaderAction(Action.APP_ICON)
.setIcon(carIcon)
.build();
} else if (templateType == 2) {
iconList.clear();
counterList.clear();
}
assert template != null;
return template;
}
public void updateUI(String newMessage, int newIcon) {
// Update the UI based on the received data
message = newMessage;
this.icon = newIcon;
templateType = 1;
invalidate();
}}
Code: Select all
Code: Select all
Ich bin mir nicht sicher, wie ich das Problem auf Debug-Ebene reproduzieren kann auf meinem lokalen Setup. Wenn jemand eine Lösung oder Ideen hat, wäre ich sehr dankbar für Ihren Beitrag.