Example usage for android.content Context SENSOR_SERVICE

List of usage examples for android.content Context SENSOR_SERVICE

Introduction

In this page you can find the example usage for android.content Context SENSOR_SERVICE.

Prototype

String SENSOR_SERVICE

To view the source code for android.content Context SENSOR_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.hardware.SensorManager for accessing sensors.

Usage

From source file:com.wordpress.tonytam.avatar.AvatarWearActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.jj_layout);/*  w w  w.  j a  v  a2s . c o  m*/
    setupViews();
    mHandler = new Handler();
    mJumpCounter = Utils.getCounterFromPreference(this);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    renewTimer();
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
    mSensorAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Wearable.API).build();
}

From source file:com.artioml.practice.MainActivity.java

@Override
protected void onPause() {
    super.onPause();

    SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    sensorManager.unregisterListener(sensorEventListener,
            sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION));
}

From source file:com.sorin.cloudcog.car.obd2.RubyBluetoothChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)/* w  ww  .  j av  a2 s.  co m*/
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.car_pager_main_ruby);
    // toast message at begining of activity start
    Toast.makeText(this, "Ruby Red Style OBD2 data console", Toast.LENGTH_SHORT).show();
    mRubyAdapter = new CarTabFragmentHandlerRuby(getSupportFragmentManager());
    mRubyPager = (ViewPager) findViewById(R.id.pager_ruby);
    mRubyPager.setAdapter(mRubyAdapter);

    mRubyIndicator = (TitlePageIndicator) findViewById(R.id.indicator_ruby);
    mRubyIndicator.setViewPager(mRubyPager);

    // When shacked it will return to main activity initialization
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mShakeDetector = new ShakeDetectorActivity();
    mShakeDetector.setOnShakeListener(new OnShakeListener() {
        // shake handler
        @Override
        public void onShake(int count) {

            RubyBluetoothChatActivity.this.finish();

        }
    });
    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
}

From source file:com.microsoft.mimickeralarm.mimics.MimicWithCameraFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_camera_mimic, container, false);

    SurfaceView previewView = (SurfaceView) view.findViewById(R.id.camera_preview_view);

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from  ww  w.  j a  va2s.c  o m
    mSize = size;
    double aspectRatio = size.y > size.x ? (double) size.y / (double) size.x
            : (double) size.x / (double) size.y;
    mCameraPreview = new CameraPreview(previewView, aspectRatio, CameraFacing);

    View overlay = view.findViewById(R.id.camera_preview_overlay);
    overlay.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                // Camera sensor ranges from -1000 to 1000 regardless of aspect ratio, sizes, resolution, ...
                int deltaX = (int) (((float) mSize.x - event.getX()) / mSize.x * -2000) + 1000;
                int deltaY = (int) (((float) mSize.y - event.getY()) / mSize.y * -2000) + 1000;
                mCameraPreview.onFocus(deltaX, deltaY);
            }
            return true;
        }
    });

    ProgressButton progressButton = (ProgressButton) view.findViewById(R.id.capture_button);
    progressButton.setReadyState(ProgressButton.State.ReadyCamera);

    mStateManager = new MimicStateManager();
    mStateManager.registerCountDownTimer((CountDownTimerView) view.findViewById(R.id.countdown_timer),
            TIMEOUT_MILLISECONDS);
    mStateManager.registerStateBanner((MimicStateBanner) view.findViewById(R.id.mimic_state));
    mStateManager.registerProgressButton(progressButton, MimicButtonBehavior.CAMERA);
    mStateManager.registerMimic(this);

    mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    if (mSensorManager != null) {
        mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    }
    mLightSensorListener = new SensorEventListener() {
        @Override
        public void onSensorChanged(SensorEvent event) {
            if (event.values[0] < LIGHT_THRESHOLD && CameraFacing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                mTooDarkToast.show();
            } else {
                mTooDarkToast.cancel();
            }
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
        }
    };
    // This toast is only shown when there is not enough light
    mTooDarkToast = Toast.makeText(getActivity(), getString(R.string.mimic_camera_too_dark),
            Toast.LENGTH_SHORT);

    return view;
}

From source file:de.sixtyfourktec.mirrorhub.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i(TAG, "Starting MirrorHub v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.BUILD_TIME + "/"
            + BuildConfig.GIT_SHA + ")");

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.main);// ww  w. j av a 2 s  .c o m

    moduleManager = ModuleManager.init(this);

    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_CALENDAR },
                PERMISSIONS_REQUEST_READ_CALENDAR);
    } else
        moduleManager.enableCalendarModule();

    if (BuildConfig.ENABLE_PROXIMITY_SENSOR) {
        sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
        dimHandler = new Handler();
    }
}

From source file:com.sorin.cloudcog.car.obd2.SilverBluetoothChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)// ww  w  . j  ava  2s  .com
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.car_pager_main_silver);
    // toast message at begining of activity start
    Toast.makeText(this, "Silver Light Style OBD2 data console", Toast.LENGTH_SHORT).show();
    mSilverAdapter = new CarTabFragmentHandlerSilver(getSupportFragmentManager());
    mSilverPager = (ViewPager) findViewById(R.id.pager_silver);
    mSilverPager.setAdapter(mSilverAdapter);

    mSilverIndicator = (TitlePageIndicator) findViewById(R.id.indicator_silver);
    mSilverIndicator.setViewPager(mSilverPager);

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    // When shacked it will return to main activity initialization
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mShakeDetector = new ShakeDetectorActivity();
    mShakeDetector.setOnShakeListener(new OnShakeListener() {
        // shake handler
        @Override
        public void onShake(int count) {

            SilverBluetoothChatActivity.this.finish();

        }
    });
}

From source file:com.nick.scalpel.core.AutoFoundWirer.java

private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme,
        Field field, Object forWho) {
    Resources resources = context.getResources();
    switch (type) {
    case STRING:/*  w w w .j  a v  a  2s.c  o  m*/
        setField(field, forWho, resources.getString(idRes));
        break;
    case COLOR:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, resources.getColor(idRes, theme));
        } else {
            //noinspection deprecation
            setField(field, forWho, resources.getColor(idRes));
        }
        break;
    case INTEGER:
        setField(field, forWho, resources.getInteger(idRes));
        break;
    case BOOL:
        setField(field, forWho, resources.getBoolean(idRes));
        break;
    case STRING_ARRAY:
        setField(field, forWho, resources.getStringArray(idRes));
        break;
    case INT_ARRAY:
        setField(field, forWho, resources.getIntArray(idRes));
        break;
    case PM:
        setField(field, forWho, context.getSystemService(Context.POWER_SERVICE));
        break;
    case ACCOUNT:
        setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE));
        break;
    case ALARM:
        setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE));
        break;
    case AM:
        setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE));
        break;
    case WM:
        setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE));
        break;
    case NM:
        setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE));
        break;
    case TM:
        setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE));
        break;
    case TCM:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE));
        }
        break;
    case SP:
        setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context));
        break;
    case PKM:
        setField(field, forWho, context.getPackageManager());
        break;
    case HANDLE:
        setField(field, forWho, new Handler(Looper.getMainLooper()));
        break;
    case ASM:
        setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE));
        break;
    case CAP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE));
        }
        break;
    case KGD:
        setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE));
        break;
    case LOCATION:
        setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE));
        break;
    case SEARCH:
        setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE));
        break;
    case SENSOR:
        setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE));
        break;
    case STORAGE:
        setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE));
        break;
    case WALLPAPER:
        setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE));
        break;
    case VIBRATOR:
        setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE));
        break;
    case CONNECT:
        setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE));
        break;
    case NETWORK_STATUS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE));
        }
        break;
    case WIFI:
        setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE));
        break;
    case AUDIO:
        setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE));
        break;
    case FP:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE));
        }
        break;
    case MEDIA_ROUTER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE));
        }
        break;
    case SUB:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE));
        }
        break;
    case IME:
        setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE));
        break;
    case CLIP_BOARD:
        setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE));
        break;
    case APP_WIDGET:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE));
        }
        break;
    case DEVICE_POLICY:
        setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE));
        break;
    case DOWNLOAD:
        setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE));
        break;
    case BATTERY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE));
        }
        break;
    case NFC:
        setField(field, forWho, context.getSystemService(Context.NFC_SERVICE));
        break;
    case DISPLAY:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE));
        }
        break;
    case USER:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setField(field, forWho, context.getSystemService(Context.USER_SERVICE));
        }
        break;
    case APP_OPS:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE));
        }
        break;
    case BITMAP:
        setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null));
        break;
    }
}

From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationMapFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    currentlyRouting = false;//from   w w  w  . j a va 2  s . c o  m

    pathOverlay = new PathOverlay(getRouteColor(), getActivity());

    if (getActivity().getIntent().getExtras() != null) {
        startLocation = Util.locationFromCoordinates(
                getActivity().getIntent().getExtras().getDouble("start_lat"),
                getActivity().getIntent().getExtras().getDouble("start_lng"));
        endLocation = Util.locationFromCoordinates(getActivity().getIntent().getExtras().getDouble("end_lat"),
                getActivity().getIntent().getExtras().getDouble("end_lng"));
        if (getActivity().getIntent().getExtras().containsKey("json_root"))
            jsonRoot = Util.stringToJsonNode(getActivity().getIntent().getExtras().getString("json_root"));
        source = getActivity().getIntent().getExtras().getString("source");
        destination = getActivity().getIntent().getExtras().getString("destination");
    }

    getMapActivity().stopTrackingUser();
    if (getActivity().getIntent().getExtras().containsKey("start_name"))
        this.startName = getActivity().getIntent().getExtras().getString("start_name");
    if (getActivity().getIntent().getExtras().containsKey("end_name"))
        this.endName = getActivity().getIntent().getExtras().getString("end_name");
    start(startLocation, endLocation, jsonRoot, startName, endName);
    mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);

    textA = new TextView(getActivity());
    textA.setBackgroundResource(R.drawable.rounded_rectangle_22);
    textA.setTypeface(IbikeApplication.getNormalFont());
    textA.setTextColor(Color.BLACK);
    textA.setGravity(Gravity.CENTER);
    textA.setPadding(Util.dp2px(5), Util.dp2px(5), Util.dp2px(5), Util.dp2px(5));
    textA.setVisibility(View.GONE);
    textA.setTextSize(16);
    textA.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            textA.setVisibility(View.GONE);
        }
    });
    mapView.addView(textA);
    textB = new TextView(getActivity());
    textB.setBackgroundResource(R.drawable.rounded_rectangle_22);
    textB.setTypeface(IbikeApplication.getNormalFont());
    textB.setTextColor(Color.BLACK);
    textB.setGravity(Gravity.CENTER);
    textB.setPadding(Util.dp2px(5), Util.dp2px(5), Util.dp2px(5), Util.dp2px(5));
    textB.setVisibility(View.GONE);
    textB.setTextSize(16);
    textB.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            textB.setVisibility(View.GONE);
        }
    });
    mapView.addView(textB);

    locationOverlay.setMapFragment(this);

    mapView.directionShown = true;
    mapView.isNavigation = true;

}

From source file:com.microsoft.band.sdksample.SensorsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_sensors, container, false);

    senSensorManager1 = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    senSensorManager2 = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);

    senGyroscope = senSensorManager1.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    senSensorManager1.registerListener(this, senGyroscope, SensorManager.SENSOR_DELAY_NORMAL);

    senAccelerometer = senSensorManager2.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    senSensorManager2.registerListener(this, senAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    mTableAcc = (TableLayout) rootView.findViewById(R.id.tableAcc);
    mTableAcc.setVisibility(View.GONE);

    mTextAccX = (TextView) rootView.findViewById(R.id.textAccX);
    mTextAccY = (TextView) rootView.findViewById(R.id.textAccY);
    mTextAccZ = (TextView) rootView.findViewById(R.id.textAccZ);
    mTextAngX = (TextView) rootView.findViewById(R.id.textPAngX);
    mTextAngY = (TextView) rootView.findViewById(R.id.textPAngY);
    mTextAngZ = (TextView) rootView.findViewById(R.id.textPAngZ);

    mTextLong = (TextView) rootView.findViewById(R.id.textLong);
    mTextLat = (TextView) rootView.findViewById(R.id.textLat);

    mTextTime = (TextView) rootView.findViewById(R.id.textTime);

    temp_list = new double[14];

    c = 0;// w  ww.j a  va2 s .c  om
    // Acquire a reference to the system Location Manager
    LocationManager locationManager = (LocationManager) getActivity()
            .getSystemService(Context.LOCATION_SERVICE);

    // Define a listener that responds to location updates
    LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            // Called when a new location is found by the network location provider.
            temp_list[12] = location.getLongitude();
            temp_list[13] = location.getLatitude();
            mTextLong.setText(Double.toString(temp_list[12]));
            mTextLat.setText(Double.toString(temp_list[13]));
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onProviderDisabled(String provider) {
        }
    };

    // Register the listener with the Location Manager to receive location updates
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

    runnable.run();

    //
    // Gyro setup
    //
    mTableGyro = (TableLayout) rootView.findViewById(R.id.tableGyro);
    mTableGyro.setVisibility(View.GONE);

    mTextGyroAccX = (TextView) rootView.findViewById(R.id.textGyroAccX);
    mTextGyroAccY = (TextView) rootView.findViewById(R.id.textGyroAccY);
    mTextGyroAccZ = (TextView) rootView.findViewById(R.id.textGyroAccZ);
    mTextGyroAngX = (TextView) rootView.findViewById(R.id.textAngX);
    mTextGyroAngY = (TextView) rootView.findViewById(R.id.textAngY);
    mTextGyroAngZ = (TextView) rootView.findViewById(R.id.textAngZ);

    //
    // Contact setup
    //
    mTableContact = (TableLayout) rootView.findViewById(R.id.tableContact);
    mTableContact.setVisibility(View.GONE);
    mTextContact = (TextView) rootView.findViewById(R.id.textContact);

    turnOnSensors();

    return rootView;
}

From source file:com.shadowmaps.example.GpsTestActivity.java

/** Called when the activity is first created. */
@Override/*ww w  .  j  av a  2  s.  c om*/
public void onCreate(Bundle savedInstanceState) {
    setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);
    sInstance = this;

    // Set the default values from the XML file if this is the first
    // execution of the app
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    recording = false;
    mService = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mProvider = mService.getProvider(LocationManager.GPS_PROVIDER);
    if (mProvider == null) {
        Log.e(TAG, "Unable to get GPS_PROVIDER");
        Toast.makeText(this, getString(R.string.gps_not_supported), Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    mService.addGpsStatusListener(this);

    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

    // Request use of spinner for showing indeterminate progress, to show
    // the user something is going on during long-running operations
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // If we have a large screen, show all the fragments in one layout
    if (GpsTestUtil.isLargeScreen(this)) {
        setContentView(R.layout.activity_main_large_screen);
        mIsLargeScreen = true;
    } else {
        setContentView(R.layout.activity_main);
    }

    initActionBar(savedInstanceState);

    SharedPreferences settings = Application.getPrefs();

    double tempMinTime = Double.valueOf(settings.getString(getString(R.string.pref_key_gps_min_time),
            getString(R.string.pref_gps_min_time_default_sec)));
    minTime = (long) (tempMinTime * SECONDS_TO_MILLISECONDS);
    minDistance = Float.valueOf(settings.getString(getString(R.string.pref_key_gps_min_distance),
            getString(R.string.pref_gps_min_distance_default_meters)));

    if (settings.getBoolean(getString(R.string.pref_key_auto_start_gps), true)) {
        gpsStart();
    }
    if (!isShadowServiceRunning(ShadowMapsService.class)) {
        final String STARTUP_EXTRA = "com.shadowmaps.example.start";
        Intent i = new Intent(this, ShadowMapsService.class);
        i.putExtra(STARTUP_EXTRA, true);
        startService(i);
        Log.v("SERVICE", "Starting ShadowService in activity onCreate");
    }
}