Back to project page Steering-Wheel-Interface.
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.
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(); } } }