protected void updateNotification() { if (mCarInterface != null && mCarInterface.getsStatus() == ElmInterface.STATUS_OPEN_MONITORING) { mNoticeBuilder.setContentText(getString(R.string.msg_monitoring)); } else { mNoticeBuilder.setContentText(getString(R.string.msg_monitoring_stopped)); } mNoticeManager.notify(mNoticeID, mNoticeBuilder.build()); }
@Override public void onCreate() { IntentFilter filterUsbDetached = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED); registerReceiver(mUsbDetachedReceiver, filterUsbDetached); Intent settingsIntent = new Intent(this, SteeringWheelInterfaceActivity.class); settingsIntent.setAction(Intent.ACTION_EDIT); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(SteeringWheelInterfaceActivity.class); stackBuilder.addNextIntent(settingsIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mNoticeBuilder.setContentIntent(resultPendingIntent); mNoticeBuilder.setSmallIcon(R.drawable.ic_notice); mNoticeBuilder.setContentTitle(getString(R.string.app_name)); mNoticeBuilder.setContentText(getString(R.string.msg_app_starting)); mNoticeManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNoticeManager.notify(mNoticeID, mNoticeBuilder.build()); mCarInterface = new ElmInterface(getApplicationContext()); mCarInterface.deviceOpenEvent_AddListener(mDeviceOpenListener); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String baudDefault = getString(R.string.scantool_baud); int baudValue = Integer.parseInt(settings.getString("scantool_baud", baudDefault)); mCarInterface.setBaudRate(baudValue); String deviceNumDefault = getString(R.string.scantool_device_number); int deviceNumValue = Integer.parseInt(settings.getString("scantool_device_number", deviceNumDefault)); mCarInterface.setDeviceNumber(deviceNumValue); String protocolCommandDefault = getString(R.string.scantool_protocol); String protocolCommandValue = settings.getString("scantool_protocol", protocolCommandDefault); mCarInterface.setProtocolCommand(protocolCommandValue); String monitorCommandDefault = getString(R.string.scantool_monitor_command); String monitorCommandValue = settings.getString("scantool_monitor_command", monitorCommandDefault); mCarInterface.setMonitorCommand(monitorCommandValue); }