Example usage for android.location LocationManager GPS_PROVIDER

List of usage examples for android.location LocationManager GPS_PROVIDER

Introduction

In this page you can find the example usage for android.location LocationManager GPS_PROVIDER.

Prototype

String GPS_PROVIDER

To view the source code for android.location LocationManager GPS_PROVIDER.

Click Source Link

Document

Name of the GPS location provider.

Usage

From source file:cl.gisred.android.PowerOnActivity.java

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

    LicenseResult licenseResult = ArcGISRuntime.setClientId(CLIENT_ID);
    LicenseLevel licenseLevel = ArcGISRuntime.License.getLicenseLevel();

    if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.BASIC) {
        //Toast.makeText(getApplicationContext(), "Licencia bsica vlida", Toast.LENGTH_SHORT).show();
    } else if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.STANDARD) {
        //Toast.makeText(getApplicationContext(), "Licencia standard vlida", Toast.LENGTH_SHORT).show();
    }/*from   w  w  w .  ja va  2 s.  c o  m*/

    setContentView(R.layout.activity_power);

    Toolbar toolbar = (Toolbar) findViewById(R.id.apptool);
    setSupportActionBar(toolbar);

    /*Get Credenciales String*/
    Bundle bundle = getIntent().getExtras();
    usuar = bundle.getString("usuario");
    passw = bundle.getString("password");
    modulo = bundle.getString("modulo");
    empresa = bundle.getString("empresa");

    //Set Credenciales
    setCredenciales(usuar, passw);

    //Set Mapa
    setMap(R.id.map, 0xffffff, 0xffffff, 10, 10, false, true);
    choices = 0;

    if (Build.VERSION.SDK_INT >= 23)
        verifPermisos();
    else
        initGeoposition();

    setLayersURL(this.getResources().getString(R.string.url_Mapabase), "MAPABASE");
    setLayersURL(this.getResources().getString(R.string.url_token), "TOKENSRV");
    setLayersURL(this.getResources().getString(R.string.url_EquiposLinea), "EQUIPOS_LINEA");
    setLayersURL(this.getResources().getString(R.string.url_TRAMOS), "TRAMOS");
    setLayersURL(this.getResources().getString(R.string.url_EquiposPTO), "EQUIPOS_PTO");
    setLayersURL(this.getResources().getString(R.string.url_Nodos), "NODOS");
    setLayersURL(this.getResources().getString(R.string.url_Luminarias), "LUMINARIAS");
    setLayersURL(this.getResources().getString(R.string.url_Clientes), "CLIENTES");
    setLayersURL(this.getResources().getString(R.string.url_Concesiones), "CONCESIONES");
    setLayersURL(this.getResources().getString(R.string.url_Direcciones), "DIRECCIONES");
    setLayersURL(this.getResources().getString(R.string.url_medidores), "MEDIDORES");
    setLayersURL(this.getResources().getString(R.string.url_Stx), "STX");
    setLayersURL(this.getResources().getString(R.string.url_interrupciones), "PO");
    setLayersURL(this.getResources().getString(R.string.url_ECSE_varios), "ECSE");
    setLayersURL(this.getResources().getString(R.string.url_Electrodependientes), "ELECTRODEP");

    //Agrega layers dinmicos.
    addLayersToMap(credenciales, "DYNAMIC", "MAPABASECHQ", din_urlMapaBase, null, true);
    addLayersToMap(credenciales, "DYNAMIC", "SED", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "SSEE", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "SALIDAALIM", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDMT", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDBT", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDAP", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "POSTES", din_urlNodos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EQUIPOS_LINEA", din_urlEquiposLinea, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EQUIPOS_PTO", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "LUMINARIAS", din_urlLuminarias, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "CLIENTES", din_urlClientes, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "MEDIDORES", din_urlMedidores, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "CONCESIONES", din_urlConcesiones, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "DIRECCIONES", din_urlDirecciones, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EMPALMES", din_urlClientes, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDSTX", din_urlStx, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "TORRESSTX", din_urlStx, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "ENCUESTADO", din_urlECSE, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REEMPLAZO", din_urlECSE, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "ELECTRODEP", din_urlElectroDep, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "POTRAMO", din_urlInterrupciones, null, true);
    addLayersToMap(credenciales, "DYNAMIC", "POSED", din_urlInterrupciones, null, true);
    addLayersToMap(credenciales, "DYNAMIC", "POCLIENTES", din_urlInterrupciones, null, true);

    //Aade Layer al Mapa
    myMapView.addLayer(mRoadBaseMaps, 0);
    myMapView.addLayer(LySED, 1);
    myMapView.addLayer(LySSEE, 2);
    myMapView.addLayer(LySALIDAALIM, 3);
    myMapView.addLayer(LyREDMT, 4);
    myMapView.addLayer(LyREDBT, 5);
    myMapView.addLayer(LyREDAP, 6);
    myMapView.addLayer(LyPOSTES, 7);
    myMapView.addLayer(LyEQUIPOSLINEA, 8);
    myMapView.addLayer(LyEQUIPOSPTO, 9);
    myMapView.addLayer(LyLUMINARIAS, 10);
    myMapView.addLayer(LyCLIENTES, 11);
    myMapView.addLayer(LyMEDIDORES, 12);
    myMapView.addLayer(LyCONCESIONES, 13);
    myMapView.addLayer(LyDIRECCIONES, 14);
    myMapView.addLayer(LyEMPALMES, 15);
    myMapView.addLayer(LyREDSTX, 16);
    myMapView.addLayer(LyTORRESSTX, 17);
    myMapView.addLayer(LyENCUESTA, 18);
    myMapView.addLayer(LyREEMPLAZO, 19);
    myMapView.addLayer(LyELECTRODEP, 20);
    myMapView.addLayer(LyPOTRAMO, 21);
    myMapView.addLayer(LyPOSED, 22);
    myMapView.addLayer(LyPOCLIENTES, 23);

    final FloatingActionButton btnGps = (FloatingActionButton) findViewById(R.id.action_gps);
    btnGps.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                alertNoGps();
            }
            toogleGps(v);
        }
    });

    btnGps.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getApplicationContext(), "Funcin Gps", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    final FloatingActionButton btnVerData = (FloatingActionButton) findViewById(R.id.action_ver_data);
    btnVerData.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            toogleData(v);
        }
    });

    btnVerData.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getApplicationContext(), "Ver Datos", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    drawOk = new ShapeDrawable(new OvalShape());
    drawOk.getPaint().setColor(getResources().getColor(R.color.colorPrimary));

    drawNo = new ShapeDrawable(new OvalShape());
    drawNo.getPaint().setColor(getResources().getColor(R.color.black_overlay));

    menuPowerActions = (FloatingActionsMenu) findViewById(R.id.power_actions);

    fabShowForm = (FloatingActionButton) findViewById(R.id.action_show_form);
    if (fabShowForm != null)
        fabShowForm.setVisibility(View.GONE);

    fabNavRoute = (FloatingActionButton) findViewById(R.id.action_nav_route);
    if (fabNavRoute != null) {
        fabNavRoute.setVisibility(View.GONE);
        fabNavRoute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (myMapView != null && myMapView.getCallout().isShowing()) {
                    Point p = (Point) GeometryEngine.project(myMapView.getCallout().getCoordinates(), wm, egs);
                    Util.QueryNavigation(PowerOnActivity.this, p);
                }
            }
        });

        fabNavRoute.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Toast.makeText(getApplicationContext(), "Ir a Ruta", Toast.LENGTH_SHORT).show();
                return true;
            }
        });
    }

    if (modulo.replace(" ", "_").equals(modPowerOn)) {

        arrayWidgets = bundle.getStringArrayList("widgets");
        arrayModulos = bundle.getStringArrayList("modulos");

        FloatingActionButton oFabView = (FloatingActionButton) findViewById(R.id.action_view);
        oFabView.setIconDrawable(drawOk);
        oFabView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                abrirLeyenda();
            }
        });

    } else {
        menuPowerActions.setVisibility(View.GONE);
    }
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    DataSource.createIcons(getResources());

    try {/*from ww  w.  j a va 2s . c o m*/
        // ??
        final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        // ?    ?? ?
        this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
        // ?? 
        locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        //  ?? . 2 ?? (1/1000s), 3 ?? (m)? ? 
        locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 3, this);

        //orientation sensor 
        sensorMgr_ori = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        orientationSensor = sensorMgr_ori.getDefaultSensor(Sensor.TYPE_ORIENTATION);

        killOnError(); // ?  ?
        requestWindowFeature(Window.FEATURE_NO_TITLE); // ?   ? 

        //  ?? 
        FrameLayout frameLayout = new FrameLayout(this);

        //  ?    ?, ? 
        frameLayout.setMinimumWidth(3000);
        frameLayout.setPadding(10, 0, 10, 10);

        // ? ? ? ?? ?
        camScreen = new CameraSurface(this);
        augScreen = new AugmentedView(this);
        setContentView(camScreen); // ? ?? ?  ? 

        // ? ?? ? 
        addContentView(augScreen, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        // ? ? ? ?   ?.
        // ? ?  ?  ?? ?  ?  ?
        addContentView(frameLayout, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));

        topLayoutOnMixView = new TopLayoutOnMixView(this);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addContentView(topLayoutOnMixView.mainArView, params);

        // ? ? ? topLayoutOnMixView ?  ?
        handleIntent(getIntent()); // ?? 

        //  ? ? ?
        if (!isInited) {
            mixContext = new MixContext(this); // ? ?
            // ? ?
            mixContext.downloadManager = new DownloadManager(mixContext);

            //? ?  ? 
            navigator = new Navigator(mixContext, topLayoutOnMixView.naverFragment);

            // ? ? ?? ? ?
            dWindow = new PaintScreen();
            dataView = new DataView(mixContext);

            isInited = true; //   true

        }

        if (mixContext.isActualLocation() == false) {
            Toast.makeText(this, getString(DataView.CONNECTION_GPS_DIALOG_TEXT), Toast.LENGTH_LONG).show();
        }

    } catch (Exception ex) {
        doError(ex); //  ? ? 
    }

    //   ? 
    IntentFilter naviBraodFilter = new IntentFilter();
    naviBraodFilter.addAction("NAVI");
    registerReceiver(naviRecevicer, naviBraodFilter);
}

From source file:com.kll.collect.android.activities.FormEntryActivity.java

/** Called when the activity is first created. */
@Override/*from  ww w .j  ava2s  .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // must be at the beginning of any activity that can be called from an
    // external intent
    try {
        Collect.createODKDirs();
    } catch (RuntimeException e) {
        createErrorDialog(e.getMessage(), EXIT);
        return;
    }
    Log.i("Activity", "Created");
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mSharedPreferences
            .registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
                @Override
                public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                    compressImage = mSharedPreferences
                            .getBoolean(PreferencesActivity.KEY_ENABLE_IMAGE_COMPRESSION, false);
                }
            });
    setContentView(R.layout.form_entry);
    /*      setTitle(getString(R.string.app_name) + " > "
    + getString(R.string.loading_form));*/
    setTitle(getString(R.string.app_name));

    Log.i("Entry", "Form");
    mErrorMessage = null;
    //progressBar = (ProgressBar) findViewById(R.id.progress);
    //progressBar.setVisibility(ProgressBar.VISIBLE);
    //progressBar.setProgress(0);

    mBeenSwiped = false;
    mAlertDialog = null;
    mCurrentView = null;
    mInAnimation = null;
    mOutAnimation = null;
    mGestureDetector = new GestureDetector(this, this);
    mQuestionHolder = (LinearLayout) findViewById(R.id.questionholder);

    // get admin preference settings
    mAdminPreferences = getSharedPreferences(AdminPreferencesActivity.ADMIN_PREFERENCES, 0);

    mNextButton = (ImageButton) findViewById(R.id.form_forward_button);
    mNextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mBeenSwiped = true;
            showNextView();
        }
    });

    mBackButton = (ImageButton) findViewById(R.id.form_back_button);
    mBackButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mBeenSwiped = true;
            showPreviousView();
        }
    });

    needLocation = mSharedPreferences.getBoolean(PreferencesActivity.KEY_GPS_FIX, false);
    if (needLocation) {

        mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 5, this);
    }

    // Load JavaRosa modules. needed to restore forms.
    new XFormsModule().registerModule();

    // needed to override rms property manager
    org.javarosa.core.services.PropertyManager.setPropertyManager(new PropertyManager(getApplicationContext()));

    String startingXPath = null;
    String waitingXPath = null;
    String instancePath = null;
    Boolean newForm = true;
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(KEY_FORMPATH)) {
            mFormPath = savedInstanceState.getString(KEY_FORMPATH);
        }
        if (savedInstanceState.containsKey(KEY_INSTANCEPATH)) {
            instancePath = savedInstanceState.getString(KEY_INSTANCEPATH);
        }
        if (savedInstanceState.containsKey(KEY_XPATH)) {
            startingXPath = savedInstanceState.getString(KEY_XPATH);
            Log.i(t, "startingXPath is: " + startingXPath);
        }
        if (savedInstanceState.containsKey(KEY_XPATH_WAITING_FOR_DATA)) {
            waitingXPath = savedInstanceState.getString(KEY_XPATH_WAITING_FOR_DATA);
            Log.i(t, "waitingXPath is: " + waitingXPath);
        }
        if (savedInstanceState.containsKey(NEWFORM)) {
            newForm = savedInstanceState.getBoolean(NEWFORM, true);
        }
        if (savedInstanceState.containsKey(KEY_ERROR)) {
            mErrorMessage = savedInstanceState.getString(KEY_ERROR);
        }
    }

    // If a parse error message is showing then nothing else is loaded
    // Dialogs mid form just disappear on rotation.
    if (mErrorMessage != null) {
        createErrorDialog(mErrorMessage, EXIT);
        return;
    }

    // Check to see if this is a screen flip or a new form load.
    Object data = getLastNonConfigurationInstance();
    if (data instanceof FormLoaderTask) {
        mFormLoaderTask = (FormLoaderTask) data;
    } else if (data instanceof SaveToDiskTask) {
        mSaveToDiskTask = (SaveToDiskTask) data;
    } else if (data == null) {
        if (!newForm) {
            if (Collect.getInstance().getFormController() != null) {
                refreshCurrentView();
            } else {
                Log.w(t, "Reloading form and restoring state.");
                // we need to launch the form loader to load the form
                // controller...
                mFormLoaderTask = new FormLoaderTask(instancePath, startingXPath, waitingXPath);
                Collect.getInstance().getActivityLogger().logAction(this, "formReloaded", mFormPath);
                // TODO: this doesn' work (dialog does not get removed):
                // showDialog(PROGRESS_DIALOG);
                // show dialog before we execute...
                Log.i("Loader", "Executing");
                mFormLoaderTask.execute(mFormPath);
            }
            return;
        }

        // Not a restart from a screen orientation change (or other).
        Collect.getInstance().setFormController(null);
        CompatibilityUtils.invalidateOptionsMenu(this);

        Intent intent = getIntent();
        if (intent != null) {
            Uri uri = intent.getData();

            if (getContentResolver().getType(uri).equals(InstanceColumns.CONTENT_ITEM_TYPE)) {
                // get the formId and version for this instance...
                String jrFormId = null;
                String jrVersion = null;
                {
                    Cursor instanceCursor = null;
                    try {
                        instanceCursor = getContentResolver().query(uri, null, null, null, null);
                        if (instanceCursor.getCount() != 1) {
                            this.createErrorDialog("Bad URI: " + uri, EXIT);
                            return;
                        } else {
                            instanceCursor.moveToFirst();
                            instancePath = instanceCursor.getString(
                                    instanceCursor.getColumnIndex(InstanceColumns.INSTANCE_FILE_PATH));
                            Collect.getInstance().getActivityLogger().logAction(this, "instanceLoaded",
                                    instancePath);

                            jrFormId = instanceCursor
                                    .getString(instanceCursor.getColumnIndex(InstanceColumns.JR_FORM_ID));
                            int idxJrVersion = instanceCursor.getColumnIndex(InstanceColumns.JR_VERSION);

                            jrVersion = instanceCursor.isNull(idxJrVersion) ? null
                                    : instanceCursor.getString(idxJrVersion);
                        }
                    } finally {
                        if (instanceCursor != null) {
                            instanceCursor.close();
                        }
                    }
                }

                String[] selectionArgs;
                String selection;

                if (jrVersion == null) {
                    selectionArgs = new String[] { jrFormId };
                    selection = FormsColumns.JR_FORM_ID + "=? AND " + FormsColumns.JR_VERSION + " IS NULL";
                } else {
                    selectionArgs = new String[] { jrFormId, jrVersion };
                    selection = FormsColumns.JR_FORM_ID + "=? AND " + FormsColumns.JR_VERSION + "=?";
                }

                {
                    Cursor formCursor = null;
                    try {
                        formCursor = getContentResolver().query(FormsColumns.CONTENT_URI, null, selection,
                                selectionArgs, null);
                        if (formCursor.getCount() == 1) {
                            formCursor.moveToFirst();
                            mFormPath = formCursor
                                    .getString(formCursor.getColumnIndex(FormsColumns.FORM_FILE_PATH));
                        } else if (formCursor.getCount() < 1) {
                            this.createErrorDialog(
                                    getString(R.string.parent_form_not_present, jrFormId)
                                            + ((jrVersion == null) ? ""
                                                    : "\n" + getString(R.string.version) + " " + jrVersion),
                                    EXIT);
                            return;
                        } else if (formCursor.getCount() > 1) {
                            // still take the first entry, but warn that
                            // there are multiple rows.
                            // user will need to hand-edit the SQLite
                            // database to fix it.
                            formCursor.moveToFirst();
                            mFormPath = formCursor
                                    .getString(formCursor.getColumnIndex(FormsColumns.FORM_FILE_PATH));
                            this.createErrorDialog(getString(R.string.survey_multiple_forms_error), EXIT);
                            return;
                        }
                    } finally {
                        if (formCursor != null) {
                            formCursor.close();
                        }
                    }
                }
            } else if (getContentResolver().getType(uri).equals(FormsColumns.CONTENT_ITEM_TYPE)) {
                Cursor c = null;
                try {
                    c = getContentResolver().query(uri, null, null, null, null);
                    if (c.getCount() != 1) {
                        this.createErrorDialog("Bad URI: " + uri, EXIT);
                        return;
                    } else {
                        c.moveToFirst();
                        mFormPath = c.getString(c.getColumnIndex(FormsColumns.FORM_FILE_PATH));
                        // This is the fill-blank-form code path.
                        // See if there is a savepoint for this form that
                        // has never been
                        // explicitly saved
                        // by the user. If there is, open this savepoint
                        // (resume this filled-in
                        // form).
                        // Savepoints for forms that were explicitly saved
                        // will be recovered
                        // when that
                        // explicitly saved instance is edited via
                        // edit-saved-form.
                        final String filePrefix = mFormPath.substring(mFormPath.lastIndexOf('/') + 1,
                                mFormPath.lastIndexOf('.')) + "_";
                        final String fileSuffix = ".xml.save";
                        File cacheDir = new File(Collect.CACHE_PATH);
                        File[] files = cacheDir.listFiles(new FileFilter() {
                            @Override
                            public boolean accept(File pathname) {
                                String name = pathname.getName();
                                return name.startsWith(filePrefix) && name.endsWith(fileSuffix);
                            }
                        });
                        // see if any of these savepoints are for a
                        // filled-in form that has never been
                        // explicitly saved by the user...
                        for (int i = 0; i < files.length; ++i) {
                            File candidate = files[i];
                            String instanceDirName = candidate.getName().substring(0,
                                    candidate.getName().length() - fileSuffix.length());
                            File instanceDir = new File(
                                    Collect.INSTANCES_PATH + File.separator + instanceDirName);
                            File instanceFile = new File(instanceDir, instanceDirName + ".xml");
                            if (instanceDir.exists() && instanceDir.isDirectory() && !instanceFile.exists()) {
                                // yes! -- use this savepoint file
                                instancePath = instanceFile.getAbsolutePath();
                                break;
                            }
                        }
                    }
                } finally {
                    if (c != null) {
                        c.close();
                    }
                }
            } else {
                Log.e(t, "unrecognized URI");
                this.createErrorDialog("Unrecognized URI: " + uri, EXIT);
                return;
            }

            mFormLoaderTask = new FormLoaderTask(instancePath, null, null);
            Collect.getInstance().getActivityLogger().logAction(this, "formLoaded", mFormPath);
            showDialog(PROGRESS_DIALOG);
            // show dialog before we execute...
            Log.i("Loader", "Executing");
            mFormLoaderTask.execute(mFormPath);
        }
    }

}

From source file:com.alibaba.weex.extend.module.location.DefaultLocation.java

private WXLocationListener findLocation(String watchId, String sucCallback, String errorCallback,
        boolean enableHighAccuracy, boolean enableAddress) {
    //    WXLogUtils.d(TAG, "into--[findLocation] mWatchId:" + watchId + "\nsuccessCallback:" + sucCallback + "\nerrorCallback:" + errorCallback + "\nenableHighAccuracy:" + enableHighAccuracy + "\nmEnableAddress:" + enableAddress);

    if (mLocationManager == null) {
        mLocationManager = (LocationManager) mWXSDKInstance.getContext()
                .getSystemService(Context.LOCATION_SERVICE);
    }//ww  w  .ja  v  a2  s .c o m
    Criteria criteria = new Criteria();
    if (enableHighAccuracy) {
        criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    }
    //String provider = locationManager.getBestProvider(criteria, false);
    if (ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(),
                    Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        WXLocationListener WXLocationListener = new WXLocationListener(mLocationManager, mWXSDKInstance,
                watchId, sucCallback, errorCallback, enableAddress);
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DISTANCE,
                WXLocationListener);
        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME, MIN_DISTANCE,
                WXLocationListener);
        return WXLocationListener;
    } else {
        Map<String, Object> options = new HashMap<>();
        options.put(ERROR_CODE, ErrorCode.NO_PERMISSION_ERROR);
        options.put(ERROR_MSG, ErrorMsg.NO_PERMISSION_ERROR);
        WXSDKManager.getInstance().callback(mWXSDKInstance.getInstanceId(), errorCallback, options);
    }
    return null;
}

From source file:com.snt.bt.recon.activities.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.snt.bt.recon.R.layout.activity_main);
    ButterKnife.bind(this);
    logDebug("Activity", "######################## On Create ########################");
    //Lock orientation
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    //Leave screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    //leave cpu on
    wl = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
            "wlTag");
    wl.acquire();//ww  w  .  j av a 2s  . c om

    //For device id
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    //for connectivity
    cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    try {

        logDebug("DatabaseTest", "Reading all trips..");
        List<Trip> trips = db.getAll(Trip.class);
        for (Trip trip : trips) {
            String log = "session id: " + trip.getSessionId() + " imei: " + trip.getImei() + " transport: "
                    + trip.getTransport() + " TS: " + trip.getTimestampStart() + " TE: "
                    + trip.getTimestampEnd() + " upload status: " + trip.getUploadStatus();
            logDebug("DatabaseTest", log);
        }
        logDebug("DatabaseTest", "Reading all locations..");
        List<GPSLocation> locs = db.getAll(GPSLocation.class);
        for (GPSLocation loc : locs) {
            String log = "loc id: " + loc.getLocationId() + " sess id: " + loc.getSessionId() + " timestamp: "
                    + loc.getTimestamp() + " upload status: " + loc.getUploadStatus();
            logDebug("DatabaseTest", log);
        }
        logDebug("DatabaseTest", "Reading all bc..");
        List<BluetoothClassicEntry> bcs = db.getAll(BluetoothClassicEntry.class);
        for (BluetoothClassicEntry bc : bcs) {
            String log = "sess id: " + bc.getSessionId() + " loc id: " + bc.getLocationId() + " upload status: "
                    + bc.getUploadStatus();
            logDebug("DatabaseTest", log);
        }
        logDebug("DatabaseTest", "Reading all ble..");
        List<BluetoothLowEnergyEntry> bles = db.getAll(BluetoothLowEnergyEntry.class);
        for (BluetoothLowEnergyEntry ble : bles) {
            String log = "sess id: " + ble.getSessionId() + " loc id: " + ble.getLocationId()
                    + " upload status: " + ble.getUploadStatus();
            logDebug("DatabaseTest", log);
        }
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }

    //Show select transpot mode
    new TransportMode(this).show();

    // Show EULA
    new AppEULA(this).show();

    //displayFeedbackDialog();

    //avtivity recognition start
    mActivityRecognitionScan = new ActivityRecognitionUtil(this);
    mActivityRecognitionScan.startActivityRecognitionScan();
    //Filter the Intent and register broadcast receiver
    registerReceiver(ActivityRecognitionReceiver, new IntentFilter("ImActive"));

    //gps
    gpsStatusCheck();

    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    locationListener = new MyLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 3, locationListener);

    //bt
    mBluetoothUtils = new BluetoothUtils(this);

    //ble
    mLeDeviceStore = new BluetoothLeDeviceStore();
    mLeScanner = new BluetoothLeScanner(mLeScanCallback, mBluetoothUtils);
    //bc
    mBcDeviceList = new ArrayList<>();

    final Handler h = new Handler();
    final int delay = 60000;

    h.postDelayed(new Runnable() {
        public void run() {
            syncServerDatabase();

            h.postDelayed(this, delay);
        }
    }, delay);

    //Clean BLE table in case device last timestamp is > 10 seconds
    final Handler h2 = new Handler();
    h2.postDelayed(new Runnable() {
        public void run() {
            //clear old ble devices
            for (BluetoothLeDevice device : mLeDeviceStore.getDeviceList()) {
                long diff = System.currentTimeMillis() - device.getTimestamp();
                if (diff > 10000) {
                    mLeDeviceStore.removeDevice(device);
                    //Refresh the listview
                    final EasyObjectCursor<BluetoothLeDevice> c = mLeDeviceStore.getDeviceCursor();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mLeDeviceListAdapter.swapCursor(c);
                        }
                    });
                }
            }

            h2.postDelayed(this, 1000);//1 sec
        }
    }, 1000);
}

From source file:com.sitewhere.android.example.ExampleFragment.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    if (LocationManager.GPS_PROVIDER.equals(provider)) {
    }
}

From source file:com.nextgis.firereporter.GetFiresService.java

protected void GetNasaData(boolean bShowProgress) {
    Location currentLocation = null;
    String sLat = null, sLon = null;

    if (mLocManager != null) {
        currentLocation = mLocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (currentLocation == null) {
            currentLocation = mLocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }/*from ww w  .  j  ava  2s. c o m*/

        if (currentLocation == null) {
            SendError(getString(R.string.noLocation));
            return;
        } else {
            sLat = Double.toString(currentLocation.getLatitude());
            sLon = Double.toString(currentLocation.getLongitude());
        }
    }

    SharedPreferences prefs = getSharedPreferences(MainActivity.PREFERENCES, MODE_PRIVATE | MODE_MULTI_PROCESS);
    String sURL = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA,
            getResources().getString(R.string.stDefaultServer));
    String sLogin = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA_USER, "fire_usr");
    String sPass = prefs.getString(SettingsActivity.KEY_PREF_SRV_NASA_PASS, "J59DY");
    int nDayInterval = prefs.getInt(SettingsActivity.KEY_PREF_SEARCH_DAY_INTERVAL + "_int", 5);
    int fetchRows = prefs.getInt(SettingsActivity.KEY_PREF_ROW_COUNT + "_int", 15);
    int searchRadius = prefs.getInt(SettingsActivity.KEY_PREF_FIRE_SEARCH_RADIUS + "_int", 5) * 1000;//meters
    boolean searchByDate = prefs.getBoolean(SettingsActivity.KEY_PREF_SEARCH_CURR_DAY, false);

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    long diff = 86400000L * nDayInterval;//1000 * 60 * 60 * 24 * 5;// 5 days  
    date.setTime(date.getTime() - diff);
    String dt = dateFormat.format(date);

    String sFullURL = sURL + "?function=get_rows_nasa&user=" + sLogin + "&pass=" + sPass + "&limit=" + fetchRows
            + "&radius=" + searchRadius;//
    if (searchByDate) {
        sFullURL += "&date=" + dt;
    }
    if (sLat.length() > 0 && sLon.length() > 0) {
        sFullURL += "&lat=" + sLat + "&lon=" + sLon;
    }

    //String sRemoteData = "http://gis-lab.info/data/zp-gis/soft/fires.php?function=get_rows_nasa&user=fire_usr&pass=J59DY&limit=5";
    //if(!oNasa.getStatus().equals(AsyncTask.Status.RUNNING) && !oNasa.getStatus().equals(AsyncTask.Status.PENDING))
    new HttpGetter(this, 2, getResources().getString(R.string.stDownLoading), mFillDataHandler, bShowProgress)
            .execute(sFullURL);
}

From source file:cl.gisred.android.LectorInspActivity.java

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

    LicenseResult licenseResult = ArcGISRuntime.setClientId(CLIENT_ID);
    LicenseLevel licenseLevel = ArcGISRuntime.License.getLicenseLevel();

    if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.BASIC) {
        //Toast.makeText(getApplicationContext(), "Licencia bsica vlida", Toast.LENGTH_SHORT).show();
    } else if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.STANDARD) {
        //Toast.makeText(getApplicationContext(), "Licencia standard vlida", Toast.LENGTH_SHORT).show();
    }/*from   w ww .  ja  va 2  s  . c  om*/

    setContentView(R.layout.activity_lector);

    Toolbar toolbar = (Toolbar) findViewById(R.id.apptool);
    setSupportActionBar(toolbar);

    /*Get Credenciales String*/
    Bundle bundle = getIntent().getExtras();
    usuar = bundle.getString("usuario");
    passw = bundle.getString("password");
    modulo = bundle.getString("modulo");
    empresa = bundle.getString("empresa");
    objId = bundle.getString("objID");

    //Set Credenciales
    setCredenciales(usuar, passw);

    //Set Mapa
    setMap(R.id.map, 0xffffff, 0xffffff, 10, 10, false, true);
    choices = 0;

    if (Build.VERSION.SDK_INT >= 23)
        verifPermisos();
    else
        initGeoposition();

    setLayersURL(this.getResources().getString(R.string.url_Mapabase), "MAPABASE");
    setLayersURL(this.getResources().getString(R.string.url_token), "TOKENSRV");
    setLayersURL(this.getResources().getString(R.string.url_EquiposLinea), "EQUIPOS_LINEA");
    setLayersURL(this.getResources().getString(R.string.url_TRAMOS), "TRAMOS");
    setLayersURL(this.getResources().getString(R.string.url_EquiposPTO), "EQUIPOS_PTO");
    setLayersURL(this.getResources().getString(R.string.url_Nodos), "NODOS");
    setLayersURL(this.getResources().getString(R.string.url_Luminarias), "LUMINARIAS");
    setLayersURL(this.getResources().getString(R.string.url_Clientes), "CLIENTES");
    setLayersURL(this.getResources().getString(R.string.url_Concesiones), "CONCESIONES");
    setLayersURL(this.getResources().getString(R.string.url_Direcciones), "DIRECCIONES");
    setLayersURL(this.getResources().getString(R.string.url_medidores), "MEDIDORES");
    setLayersURL(this.getResources().getString(R.string.url_Stx), "STX");
    setLayersURL(this.getResources().getString(R.string.url_ECSE_varios), "ECSE");

    //Agrega layers dinmicos.
    addLayersToMap(credenciales, "DYNAMIC", "MAPABASECHQ", din_urlMapaBase, null, true);
    addLayersToMap(credenciales, "DYNAMIC", "SED", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "SSEE", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "SALIDAALIM", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDMT", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDBT", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDAP", din_urlTramos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "POSTES", din_urlNodos, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EQUIPOS_LINEA", din_urlEquiposLinea, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EQUIPOS_PTO", din_urlEquiposPunto, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "LUMINARIAS", din_urlLuminarias, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "CLIENTES", din_urlClientes, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "MEDIDORES", din_urlMedidores, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "CONCESIONES", din_urlConcesiones, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "DIRECCIONES", din_urlDirecciones, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "EMPALMES", din_urlClientes, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REDSTX", din_urlStx, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "TORRESSTX", din_urlStx, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "ENCUESTADO", din_urlECSE, null, false);
    addLayersToMap(credenciales, "DYNAMIC", "REEMPLAZO", din_urlECSE, null, false);

    //Aade Layer al Mapa
    myMapView.addLayer(mRoadBaseMaps, 0);
    myMapView.addLayer(LySED, 1);
    myMapView.addLayer(LySSEE, 2);
    myMapView.addLayer(LySALIDAALIM, 3);
    myMapView.addLayer(LyREDMT, 4);
    myMapView.addLayer(LyREDBT, 5);
    myMapView.addLayer(LyREDAP, 6);
    myMapView.addLayer(LyPOSTES, 7);
    myMapView.addLayer(LyEQUIPOSLINEA, 8);
    myMapView.addLayer(LyEQUIPOSPTO, 9);
    myMapView.addLayer(LyLUMINARIAS, 10);
    myMapView.addLayer(LyCLIENTES, 11);
    myMapView.addLayer(LyMEDIDORES, 12);
    myMapView.addLayer(LyCONCESIONES, 13);
    myMapView.addLayer(LyDIRECCIONES, 14);
    myMapView.addLayer(LyEMPALMES, 15);
    myMapView.addLayer(LyREDSTX, 16);
    myMapView.addLayer(LyTORRESSTX, 17);
    myMapView.addLayer(LyENCUESTA, 18);
    myMapView.addLayer(LyREEMPLAZO, 19);

    final FloatingActionButton btnGps = (FloatingActionButton) findViewById(R.id.action_gps);
    btnGps.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                alertNoGps();
            }
            toogleGps(v);
        }
    });

    btnGps.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getApplicationContext(), "Funcin Gps", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    final FloatingActionButton btnVerData = (FloatingActionButton) findViewById(R.id.action_ver_data);
    btnVerData.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            toogleData(v);
        }
    });

    btnVerData.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getApplicationContext(), "Ver Datos", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    drawOk = new ShapeDrawable(new OvalShape());
    drawOk.getPaint().setColor(getResources().getColor(R.color.colorPrimary));

    drawNo = new ShapeDrawable(new OvalShape());
    drawNo.getPaint().setColor(getResources().getColor(R.color.black_overlay));

    menuLectorActions = (FloatingActionsMenu) findViewById(R.id.lector_actions);
    menuLectorActions.setVisibility(View.GONE);

    menuMultipleActions = (FloatingActionsMenu) findViewById(R.id.multiple_actions);

    fabShowDialog = (FloatingActionButton) findViewById(R.id.action_show_dialog);
    if (fabShowDialog != null)
        fabShowDialog.setVisibility(View.GONE);

    fabShowForm = (FloatingActionButton) findViewById(R.id.action_show_form);
    if (fabShowForm != null)
        fabShowForm.setVisibility(View.GONE);

    fabVerCapas = (FloatingActionButton) findViewById(R.id.action_ver_capa);
    if (fabVerCapas != null)
        fabVerCapas.setVisibility(View.GONE);

    fabNavRoute = (FloatingActionButton) findViewById(R.id.action_nav_route);
    if (fabNavRoute != null) {
        fabNavRoute.setVisibility(View.GONE);
        fabNavRoute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (myMapView != null && myMapView.getCallout().isShowing()) {
                    Point p = (Point) GeometryEngine.project(myMapView.getCallout().getCoordinates(), wm, egs);
                    Util.QueryNavigation(LectorInspActivity.this, p);
                }
            }
        });

        fabNavRoute.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Toast.makeText(getApplicationContext(), "Ir a Ruta", Toast.LENGTH_SHORT).show();
                return true;
            }
        });
    }

    setLayersURL(this.getResources().getString(R.string.srv_Lectores), "SRV_LECTORES");
    setLayersURL(this.getResources().getString(R.string.srv_Postes), "SRV_POSTES");
    setLayersURL(this.getResources().getString(R.string.srv_Direcciones), "SRV_DIRECCIONES");

    addLayersToMap(credenciales, "FEATURE", "ADDLECTOR", srv_lectores, null, true);
    addLayersToMap(credenciales, "FEATURE", "ADDPOSTE", srv_urlPostes, null, true);
    addLayersToMap(credenciales, "FEATURE", "ADDADDRESS", srv_urlDireccion, null, true);

    myMapView.addLayer(LyAddLectores, 20);
    myMapView.addLayer(LyAddPoste, 21);
    myMapView.addLayer(LyAddDireccion, 22);

    if (LyAddLectores != null)
        LyAddLectores.setVisible(true);

    arrayTipoEdif = getResources().getStringArray(R.array.tipo_edificacion);
    arrayEstado = getResources().getStringArray(R.array.estado_lectura);
    arrayUserCosenza = getResources().getStringArray(R.array.user_cosenza);

    arrayWidgets = bundle.getStringArrayList("widgets");
    arrayModulos = bundle.getStringArrayList("modulos");

    if (arrayModulos != null && arrayModulos.size() > 0 && arrayModulos.contains(empresa + "@" + modIngreso)) {

        arrayTipoPoste = getResources().getStringArray(R.array.tipo_poste);
        arrayTension = getResources().getStringArray(R.array.tipo_tension);
        arrayTipoEdif = getResources().getStringArray(R.array.tipo_edificacion);
        arrayMedidor = getResources().getStringArray(R.array.tipo_medidor);
        arrayEmpalme = getResources().getStringArray(R.array.tipo_empalme);
        arrayTecMedidor = getResources().getStringArray(R.array.tec_medidor);
        arrayTipoCnr = getResources().getStringArray(R.array.tipo_cnr);
        arrayTipoFase = getResources().getStringArray(R.array.fase_conexion);

        dialogCrear = new Dialog(LectorInspActivity.this);

        fabShowDialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bMapTap = false;
                bCallOut = false;
                myMapView.getCallout().hide();
                //TODO Restringir datos dialog
                if (oUbicacion != null) {
                    btnUbicacion.setColorFilter(Color.BLACK);
                    setEnabledDialog(true);
                }
                dialogCrear.show();
                if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
                    myMapView.removeLayer(mSeleccionLayer);
            }
        });

        fabVerCapas.setVisibility(View.VISIBLE);
        fabVerCapas.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toogleCapas(v);
            }
        });

        fabVerCapas.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Toast.makeText(getApplicationContext(), "Ver Capas de Ingreso", Toast.LENGTH_SHORT).show();
                return true;
            }
        });

        final FloatingActionButton actionA = (FloatingActionButton) findViewById(R.id.action_a);
        final FloatingActionButton actionB = (FloatingActionButton) findViewById(R.id.action_b);
        final FloatingActionButton actionC = (FloatingActionButton) findViewById(R.id.action_c);
        final FloatingActionButton actionD = (FloatingActionButton) findViewById(R.id.action_d);

        setOpcion(actionA, null);
        setOpcion(actionB, null);
        setOpcion(actionC, modIngreso + "_TECNO");
        setOpcion(actionD, modIngreso + "_CNR");

        setLayersURL(this.getResources().getString(R.string.srv_Clientes), "SRV_CLIENTES");
        setLayersURL(this.getResources().getString(R.string.srv_Union_012), "SRV_UNIONES");
        setLayersURL(din_urlTramos, "TRAMOS");
        setLayersURL(this.getResources().getString(R.string.url_Mapabase), "SRV_CALLES");
        setLayersURL(this.getResources().getString(R.string.srv_ClientesCnr), "SRV_CLIENTESCNR");

        addLayersToMap(credenciales, "FEATURE", "ADDCLIENTE", srv_urlClientes, null, true);
        addLayersToMap(credenciales, "FEATURE", "ADDUNION", srv_urlUnion012, null, true);
        addLayersToMap(credenciales, "FEATURE", "ASOCTRAMO", LyREDBT.getUrl(), null, false);
        addLayersToMap(credenciales, "FEATURE", "ASOCCALLE", srv_calles, null, false);
        addLayersToMap(credenciales, "FEATURE", "ADDCLIENTECNR", srv_urlClientesCnr, null, true);

        myMapView.addLayer(LyAddCliente, 23);
        myMapView.addLayer(LyAddUnion, 24);
        myMapView.addLayer(LyAsocTramo, 25);
        myMapView.addLayer(LyAsocCalle, 26);
        myMapView.addLayer(LyAddClienteCnr, 27);

        setLayerAddToggle(false);
    } else {
        bIngCliente = false;
        menuMultipleActions.setVisibility(View.GONE);
        //Informar al usuario que carece de permisos para ver y usar la capa de ingreso clientes comun
    }

    //get test
    getUbicacionLectura(objId);
}

From source file:com.tml.sharethem.receiver.ReceiverActivity.java

private boolean checkLocationAccess() {
    final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        Log.e(TAG, "GPS not enabled..");
        buildAlertMessageNoGps();//  ww w  .j  av a2s . co m
        return false;
    }
    return true;
}

From source file:com.mitre.holdshort.MainActivity.java

private void startMainActivity() {

    // Set screen layout
    setContentView(R.layout.main);/*from  w  w w .  j  av  a2s  .co  m*/
    imageHelper = new ImageHelper();
    summaryGestureDetector = new GestureDetector(new summaryGester());

    // Get Reference to Shared Preferences file
    auralAlerts = settings.getBoolean("auralAlerts", true);
    settings.edit().putBoolean("auralAlerts", auralAlerts);
    announceRWY = settings.getBoolean("announceRWY", true);
    settings.edit().putBoolean("announceRWY", announceRWY);

    // Airport ID
    airportID = (TextView) findViewById(R.id.airportID);
    airportID.setText("K" + airport);

    // SpeechButton
    speechBtn = (ImageView) findViewById(R.id.speechBtn);
    speechBtn.setOnClickListener(speechBtnClickListener);

    // Get open close button
    openClose = (TextView) findViewById(R.id.openClose);
    openClose.setText("close");
    // openClose.setTextColor(Color.argb(200, 255, 255, 255));
    openClose.setOnClickListener(openCloseListener);

    // departure runway button
    depRwyBtn = (TextView) findViewById(R.id.depRwyBtn);
    depRwyBtn.setOnClickListener(depRwyListener);
    depRwyBtn.setText("Departure Rwy");
    depRwyBtn.setBackgroundResource(R.drawable.hatched_small_bg_layer);
    depRwyBtn.setPadding(10, 5, 10, 5);

    // info button - used to start prefs activity
    infoBtn = (ImageButton) findViewById(R.id.info_btn);
    // infoBtn.setBackgroundColor(Color.rgb(0,0,0));
    infoBtn.setOnClickListener(settingsMenuListener);

    // taxi button - used to start Taxi instruction activity
    taxiBtn = (ImageButton) findViewById(R.id.taxi_btn);
    // taxiBtn.setBackgroundColor(Color.rgb(0,0,0));
    taxiBtn.setOnClickListener(taxiBtnListener);

    // summary info - when drawer is closed
    summaryBar = (RelativeLayout) findViewById(R.id.summaryBar);
    summaryBar.setOnTouchListener(summaryTouchListener);
    runwayContainer = (LinearLayout) findViewById(R.id.holder);
    innerHolder = (LinearLayout) findViewById(R.id.innerHolder);
    slidingPanel = (SlidingPanel) findViewById(R.id.slidingDrawer);

    // header
    header = (RelativeLayout) findViewById(R.id.header);
    headerDropShadow = (View) findViewById(R.id.header_drop_shadow);
    slidingPanel.setHeaderDropShadow(headerDropShadow);
    slidingPanel.setRunwayContainer(runwayContainer);
    slidingPanel.setOpenCloseTextView(openClose);
    slidingPanel.setHandler(this.handler);

    summaryInfo = (RelativeLayout) findViewById(R.id.summary_info);
    summary_index = (TextView) findViewById(R.id.summary_index);
    summary_thumb = (TextView) findViewById(R.id.summary_thumb);
    summary_thumb.setWidth(90);

    // Taxi path area
    taxiClearance = (TextView) findViewById(R.id.taxiClearance);
    taxiClearance.setTextSize(12);
    taxiClearance.setPadding(5, 0, 5, 0);
    taxiClearance.setTextColor(Color.WHITE);
    // taxiClearance.setBackgroundColor(Color.rgb(0,0,0));
    taxiClearance.setOnClickListener(taxiPathListener);

    // Airport Diagram
    plateView = (AirportPlateView) findViewById(R.id.plateView);
    // Set up the nav control for the moving map
    // this is used when ownship is off screen
    navControl = (ImageView) findViewById(R.id.showNavBtn);
    plateView.setNavControls(navControl);
    navControl.setVisibility(ImageView.INVISIBLE);
    navControl.setOnClickListener(navControlListener);

    // // Lat/Lon Ref 1 SFO
    Point latLon1 = new Point(37.627827, -122.366794);
    Point latLon2 = new Point(37.606827, -122.380724);
    XYPoint xy1 = new XYPoint(134, 173);
    XYPoint xy2 = new XYPoint(340, 281);

    // Lat/Lon Ref 1 HEF
    // Point latLon1 = new Point(38.727680,-77.518803);
    // Point latLon2 = new Point(38.714041,-77.508976);
    // XYPoint xy1 = new XYPoint(140,187);
    // XYPoint xy2 = new XYPoint(322,513);
    plateView.geoReference(latLon1, latLon2, xy1, xy2);

    Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    plateView.updatePosition(loc.getBearing(), loc.getLatitude(), loc.getLongitude());

    // navView.setScroll(plateView);
    TextView emptyPlate = (TextView) findViewById(R.id.emptyPlate);

    if (!(plateView.setImage(airport))) {
        // Place holder if no plate is available
        emptyPlate.setVisibility(View.VISIBLE);
        plateView.setVisibility(View.GONE);

    } else {
        // Show plate. Hide placeholder
        plateView.setImage(airport);
        emptyPlate.setVisibility(View.GONE);
    }

    // Create logger for alerts
    alertLogger = new AlertLogger(airport, MainActivity.this);

    // Alert Panels
    alertScreen = (RelativeLayout) findViewById(R.id.alertScreen);
    betaControls = (LinearLayout) findViewById(R.id.betaControls);
    goodAlert = (TextView) findViewById(R.id.goodAlert);
    goodAlert.setOnClickListener(alertResponseListener);
    badAlert = (TextView) findViewById(R.id.badAlert);
    badAlert.setOnClickListener(alertResponseListener);
    lateAlert = (TextView) findViewById(R.id.lateAlert);
    lateAlert.setOnClickListener(alertResponseListener);
    earlyAlert = (TextView) findViewById(R.id.earlyAlert);
    earlyAlert.setOnClickListener(alertResponseListener);

    miniAlert = (TextView) findViewById(R.id.miniAlertText);
    miniAlert.setOnClickListener(maximizeAlert);

    holdShort = (LinearLayout) findViewById(R.id.holdShort);
    holdShort.getChildAt(0).setBackgroundDrawable(imageHelper
            .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10));
    holdShort.setOnClickListener(minimizeAlert);
    noClearance = (LinearLayout) findViewById(R.id.noClearance);
    noClearance.setOnClickListener(minimizeAlert);
    noClearance.getChildAt(0).setBackgroundDrawable(imageHelper
            .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10));
    crossingAlert = (LinearLayout) findViewById(R.id.crossingAlert);
    noTakeoffClearance = (LinearLayout) findViewById(R.id.noTakeoffClearance);
    noTakeoffClearance.getChildAt(0).setBackgroundDrawable(imageHelper
            .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10));
    noTakeoffClearance.setOnClickListener(minimizeAlert);
    disabled_gps = (LinearLayout) findViewById(R.id.disabled_gps);
    disabled_gps.getChildAt(0).setBackgroundDrawable(imageHelper
            .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.disabled), 10));
    disabled_gps.setOnClickListener(minimizeAlert);

    disabled_speed = (LinearLayout) findViewById(R.id.disabled_speed);
    disabled_speed.getChildAt(0).setBackgroundDrawable(imageHelper
            .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.disabled), 10));
    disabled_speed.setOnClickListener(minimizeAlert);

    // Instantiate media player & set completion listener
    mp = new MediaPlayer();
    mp.setOnCompletionListener(alertPlaybackListener);

    // Instruction List instantiation
    instructionList = new ArrayList<String>();

    setUpRunways();
    slidingPanel.setOnTouchListener(summaryTouchListener);
    // Instantiate Alert Manager
    alertManager = new AlertManager(rwyMgr);

    allSetUp = true;
}