Android Open Source - Steering-Wheel-Interface Steering Wheel Interface Activity






From Project

Back to project page Steering-Wheel-Interface.

License

The source code is released under:

Copyright 2013 Kristoffer Smith and other contributors http://theksmith.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation...

If you think the Android project Steering-Wheel-Interface listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.theksmith.steeringwheelinterface;
//from  w w  w  .  j  a v  a 2  s  . c om
import android.R.style;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.preference.PreferenceFragment;


/**
 * Main entry point activity, has no UI.
 * Starts the background service by default.
 * Opens the settings screen if called with Intent.ACTION_EDIT. 
 * Kills the background service and exits the app if called with Intent.ACTION_DELETE.
 * 
 * @author Kristoffer Smith <kristoffer@theksmith.com>
 */
public class SteeringWheelInterfaceActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    try {
      PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
      setTitle(getTitle() + " " + info.versionName);
    } catch (NameNotFoundException e) { }
    
    String action = getIntent().getAction(); 
    
    if (action == Intent.ACTION_EDIT) {
        //replace the blank UI with the settings screen        
      this.setTheme(style.Theme_DeviceDefault);  

      PreferenceFragment mSettingsFragment = new SteeringWheelInterfaceSettings();      
          getFragmentManager()
              .beginTransaction()
                  .replace(android.R.id.content, mSettingsFragment)
                  .commit();
    } else if (action == Intent.ACTION_DELETE) {
      //TODO: if settings screen is open when this is called, it stays - how to end it?
      
      //kill car interface service and exit the app
      Intent interfaceService = new Intent(getBaseContext(), SteeringWheelInterfaceService.class);
      stopService(interfaceService);
      
      finish();
    } else {        
      //start the main car interface service and then exit the app
      Intent interfaceService = new Intent(getBaseContext(), SteeringWheelInterfaceService.class);
      startService(interfaceService);
      
      finish();
      }
  }
}




Java Source Code List

com.hoho.android.usbserial.BuildInfo.java
com.hoho.android.usbserial.driver.CdcAcmSerialDriver.java
com.hoho.android.usbserial.driver.CommonUsbSerialDriver.java
com.hoho.android.usbserial.driver.Cp2102SerialDriver.java
com.hoho.android.usbserial.driver.FtdiSerialDriver.java
com.hoho.android.usbserial.driver.UsbId.java
com.hoho.android.usbserial.driver.UsbSerialDriver.java
com.hoho.android.usbserial.driver.UsbSerialProber.java
com.hoho.android.usbserial.driver.UsbSerialRuntimeException.java
com.hoho.android.usbserial.util.HexDump.java
com.hoho.android.usbserial.util.SerialInputOutputManager.java
com.theksmith.steeringwheelinterface.ButtonActions.java
com.theksmith.steeringwheelinterface.ElmInterface.java
com.theksmith.steeringwheelinterface.SteeringWheelInterfaceActivity.java
com.theksmith.steeringwheelinterface.SteeringWheelInterfaceService.java
com.theksmith.steeringwheelinterface.SteeringWheelInterfaceSettings.java