Android Open Source - gps-lock-lock Launcher Activity






From Project

Back to project page gps-lock-lock.

License

The source code is released under:

GNU General Public License

If you think the Android project gps-lock-lock 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

/*
 *  This file is a part of GPS Lock-Lock Android application.
 *  Copyright (C) 2011 Tomasz Dudziak// w  w w  .j av  a  2  s  . c om
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.github.tdudziak.gps_lock_lock;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.location.LocationManager;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class LauncherActivity extends Activity implements OnCancelListener, OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        if(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            LockService service = ((LockApplication) getApplication()).getLockService();
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
            boolean show_control_screen = !prefs.getBoolean("backgroundLaunch", false);

            // Start service if not running. Otherwise just show the control activity.
            if(service == null) {
                startService(new Intent(this, LockService.class));
            } else {
                show_control_screen = true;
            }

            if(show_control_screen) {
                startActivity(new Intent(this, ControlActivity.class));
            }

            finish();
        } else {
            AlertDialog.Builder ab = new AlertDialog.Builder(this);
            ab.setMessage(R.string.alert_nogps)
              .setOnCancelListener(this)
              .setNegativeButton("Ok", this)
              .create()
              .show();
        }
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        finish();
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        finish();
    }
}




Java Source Code List

com.github.tdudziak.gps_lock_lock.AboutActivity.java
com.github.tdudziak.gps_lock_lock.AppPreferenceActivity.java
com.github.tdudziak.gps_lock_lock.ControlActivity.java
com.github.tdudziak.gps_lock_lock.LauncherActivity.java
com.github.tdudziak.gps_lock_lock.LockApplication.java
com.github.tdudziak.gps_lock_lock.LockService.java
com.github.tdudziak.gps_lock_lock.MenuAdapter.java
com.github.tdudziak.gps_lock_lock.NotificationUi.java
com.github.tdudziak.gps_lock_lock.SeekBarPreference.java