List of usage examples for android.content Context LOCATION_SERVICE
String LOCATION_SERVICE
To view the source code for android.content Context LOCATION_SERVICE.
Click Source Link
From source file:org.nasa.openspace.gc.geolocation.LocationActivity.java
@Override protected void onStart() { super.onStart(); // Check if the GPS setting is currently enabled on the device. // This verification should be done during onStart() because the system calls this method // when the user returns to the activity, which ensures the desired location provider is // enabled each time the activity resumes from the stopped state. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!gpsEnabled) { // Build an alert dialog here that requests that the user enable // the location services, then when the user clicks the "OK" button, // call enableLocationSettings() new EnableGpsDialogFragment().show(getSupportFragmentManager(), "enableGpsDialog"); }//from ww w .jav a 2 s.co m }
From source file:com.jbsoft.farmtotable.FarmToTableActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { progress = new ProgressDialog(this); super.onCreate(savedInstanceState); if (readyToGo()) { setContentView(R.layout.activity_main); SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); initListNav();/*from w w w .j a v a2 s . c o m*/ getSupportActionBar().setHomeButtonEnabled(true); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); getPreferences(sharedPrefs); sharedPrefs.registerOnSharedPreferenceChangeListener(listener); map = mapFrag.getMap(); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Getting GPS status boolean isNETWORKEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); // If GPS enabled, get latitude/longitude using GPS Services if (isGPSEnabled) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, gpsLocationListener); Log.d("GPS Enabled", "GPS Enabled"); if (locationManager != null) { location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } if (savedInstanceState == null) { CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude)); map.moveCamera(center); } if (NOFM) { //Reverse geocoder to zipcode getZipFromLocation(location, this); //start progress box going //Call api to retrieve Farmers Market from the UDSA site usdaurl = usdaurl + zipcode; } else { nozip = true; } //start progress box going progress.setMessage("Getting Farmers Markets and Other Organic Options in your area:)"); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); progress.setIndeterminate(true); progress.show(); gplaceurl = placeurl_save; placeurl_save = gplaceurl; if (NOVR) { gplaceurl = gplaceurl + queryvegan; } if (NOOR) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegetarian; } if (NOFS) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryfarms; } if ((NOVR) && (NOOR)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian; } if ((NOVR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryfarms; } if ((NOOR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegetarian + "&" + queryfarms; } if ((NOVR) && (NOOR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian + "&" + queryfarms; } //The Google Places API Text Search Service gplaceurl = gplaceurl + "&location=" + latitude + "," + longitude + "&radius=10&key=AIzaSyA_fzl-7ZkF4EINWhuQ0bcXp3zkdAXZc5o"; //Call Asynch process Api new restAPICall().execute(usdaurl, gplaceurl); } map.setInfoWindowAdapter(new CustomToast(this, null)); // map.setOnInfoWindowClickListener((OnInfoWindowClickListener) map.setMyLocationEnabled(true); CameraUpdate zoom = CameraUpdateFactory.zoomTo(12); map.animateCamera(zoom); }
From source file:com.kaiserdev.android.clima.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); firstTime = getPreferences(MODE_PRIVATE).getBoolean(FIRST_TIME_SETUP, true); //create the adapter for the views mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); new StatCounter().execute(); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location l = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (l != null) { curr_latitude = (float) l.getLatitude(); curr_longitude = (float) l.getLongitude(); }/* www . j ava2s .c om*/ lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locList); mainAct = this; }
From source file:de.madvertise.android.sdk.MadUtil.java
/** * Try to update current location. Non blocking call. * //from w ww.j a va 2 s . c o m * @param context * application context */ protected static void refreshCoordinates(Context context) { if (PRINT_LOG) Log.d(LOG, "Trying to refresh location"); if (context == null) { if (PRINT_LOG) Log.d(LOG, "Context not set - quit location refresh"); return; } // check if we need a regular update if ((locationUpdateTimestamp + MadUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System.currentTimeMillis()) { if (PRINT_LOG) Log.d(LOG, "It's not time yet for refreshing the location"); return; } synchronized (context) { // recheck, if location was updated by another thread while we paused if ((locationUpdateTimestamp + MadUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System .currentTimeMillis()) { if (PRINT_LOG) Log.d(LOG, "Another thread updated the loation already"); return; } boolean permissionCoarseLocation = context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED; boolean permissionFineLocation = context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; // return (null) if we do not have any permissions if (!permissionCoarseLocation && !permissionFineLocation) { if (PRINT_LOG) Log.d(LOG, "No permissions for requesting the location"); return; } // return (null) if we can't get a location manager LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (locationManager == null) { if (PRINT_LOG) Log.d(LOG, "Unable to fetch a location manger"); return; } String provider = null; Criteria criteria = new Criteria(); criteria.setCostAllowed(false); // try to get coarse location first if (permissionCoarseLocation) { criteria.setAccuracy(Criteria.ACCURACY_COARSE); provider = locationManager.getBestProvider(criteria, true); } // try to get gps location if coarse locatio did not work if (provider == null && permissionFineLocation) { criteria.setAccuracy(Criteria.ACCURACY_FINE); provider = locationManager.getBestProvider(criteria, true); } // still no provider, return (null) if (provider == null) { if (PRINT_LOG) Log.d(LOG, "Unable to fetch a location provider"); return; } // create a finalized reference to the location manager, in order to // access it in the inner class final LocationManager finalizedLocationManager = locationManager; locationUpdateTimestamp = System.currentTimeMillis(); locationManager.requestLocationUpdates(provider, 0, 0, new LocationListener() { public void onLocationChanged(Location location) { if (PRINT_LOG) Log.d(LOG, "Refreshing location"); currentLocation = location; locationUpdateTimestamp = System.currentTimeMillis(); // stop draining battery life finalizedLocationManager.removeUpdates(this); } // not used yet public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }, context.getMainLooper()); } }
From source file:com.SecUpwN.AIMSICD.service.AimsicdService.java
public void onCreate() { //TelephonyManager provides system details tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mContext = getApplicationContext();// w w w .j a v a 2s .c om PHONE_TYPE = tm.getPhoneType(); prefs = this.getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0); prefs.registerOnSharedPreferenceChangeListener(this); loadPreferences(); if (!CELL_TABLE_CLEANSED) { dbHelper.open(); dbHelper.cleanseCellTable(); dbHelper.close(); Editor prefsEditor; prefsEditor = prefs.edit(); prefsEditor.putBoolean(this.getString(R.string.pref_cell_table_cleansed), true); prefsEditor.apply(); } mDevice.refreshDeviceInfo(tm, this); //Telephony Manager setNotification(); mRequestExecutor = new SamsungMulticlientRilExecutor(); mRilExecutorDetectResult = mRequestExecutor.detect(); if (!mRilExecutorDetectResult.available) { mMultiRilCompatible = false; Log.e(TAG, "Samsung multiclient ril not available: " + mRilExecutorDetectResult.error); mRequestExecutor = null; } else { mRequestExecutor.start(); mMultiRilCompatible = true; //Sumsung MultiRil Initialization mHandlerThread = new HandlerThread("ServiceModeSeqHandler"); mHandlerThread.start(); Looper l = mHandlerThread.getLooper(); if (l != null) { mHandler = new Handler(l, new MyHandler()); } } //Register receiver for Silent SMS Interception Notification mContext.registerReceiver(mMessageReceiver, new IntentFilter(SILENT_SMS)); mMonitorCell = new Cell(); Log.i(TAG, "Service launched successfully"); }
From source file:com.cmput301w17t07.moody.CreateMoodActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_mood); UserController userController = new UserController(); userName = userController.readUsername(CreateMoodActivity.this).toString(); setUpMenuBar(this); location = null;/*w w w .ja v a 2 s.com*/ date = new Date(); Intent intent = getIntent(); locationText = (TextView) findViewById(R.id.locationText); Description = (EditText) findViewById(R.id.Description); mImageView = (ImageView) findViewById(R.id.editImageView); //try to get picklocation, if it is equal to 1 that means, user just back from map not //other activities try { pickLocation = (int) intent.getExtras().getInt("pickLocation"); } catch (Exception e) { e.printStackTrace(); } if (pickLocation == 1) { tempMood = (Mood) intent.getSerializableExtra("editMood"); bitmap = (Bitmap) intent.getParcelableExtra("bitmapback"); latitude = tempMood.getLatitude(); longitude = tempMood.getLongitude(); address = tempMood.getDisplayLocation(); locationText.setText(address); Description.setText(tempMood.getMoodMessage()); mImageView.setImageBitmap(bitmap); date = tempMood.getDate(); displayAttributes(); } /** * Spinner dropdown logic taken from http://stackoverflow.com/questions/13377361/how-to-create-a-drop-down-list <br> * Author: Nicolas Tyler, 2013/07/15 8:47 <br> * taken by Xin Huang 2017/03/10 <br> */ //Spinner for emotion and socialsituatuion if (pickLocation == 0) { Spinner dropdown = (Spinner) findViewById(R.id.Emotion); String[] items = new String[] { "anger", "confusion", "disgust", "fear", "happiness", "sadness", "shame", "surprise" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setAdapter(adapter); dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { EmotionText = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(CreateMoodActivity.this, "Please pick a feeling!", Toast.LENGTH_SHORT).show(); } }); Spinner dropdown_SocialSituation = (Spinner) findViewById(R.id.SocialSituation); String[] item_SocialSituation = new String[] { "", "alone", "with one other person", "with two people", "with several people", "with a crowd" }; ArrayAdapter<String> adapter_SocialSituation = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, item_SocialSituation); dropdown_SocialSituation.setAdapter(adapter_SocialSituation); dropdown_SocialSituation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SocialSituation = parent.getItemAtPosition(position).toString(); TextView sizeView = (TextView) findViewById(R.id.SocialText); sizeView.setText(" " + SocialSituation); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } ImageButton chooseButton = (ImageButton) findViewById(R.id.Camera); ImageButton locationButton = (ImageButton) findViewById(R.id.location); ImageButton PickerButton = (ImageButton) findViewById(R.id.Picker); //click on PickerButton, call the datetimePicker PickerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { innit(); TimeDialog.show(); } }); chooseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 1); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } } }); chooseButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { try { Intent intent = new Intent("android.intent.action.PICK"); intent.setType("image/*"); startActivityForResult(intent, 0); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } return true; } }); locationButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //check available tools List<String> locationList = locationManager.getProviders(true); if (locationList.contains(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } else if (locationList.contains(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else { Toast.makeText(getApplicationContext(), "Please check application permissions", Toast.LENGTH_LONG).show(); } //check the permission if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling Toast.makeText(getApplicationContext(), "Get location failed, Please check the Permission", Toast.LENGTH_SHORT).show(); return; } location = locationManager.getLastKnownLocation(provider); if (location == null) { latitude = 0; longitude = 0; } else { latitude = location.getLatitude(); longitude = location.getLongitude(); } Geocoder gcd = new Geocoder(CreateMoodActivity.this, Locale.getDefault()); try { List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) address = " " + addresses.get(0).getFeatureName() + " " + addresses.get(0).getThoroughfare() + ", " + addresses.get(0).getLocality() + ", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryCode(); locationText.setText(address); } catch (Exception e) { e.printStackTrace(); } } }); //pass users' changes to map, will be passed back locationButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { int fromCreate = 123; moodMessage_text = Description.getText().toString(); tempMood = new Mood(EmotionText, userName, moodMessage_text, latitude, longitude, null, SocialSituation, date, address); Intent editLocation = new Intent(CreateMoodActivity.this, EditLocation.class); editLocation.putExtra("EditMood", tempMood); editLocation.putExtra("fromCreate", fromCreate); editLocation.putExtra("bitmap", compress(bitmap)); startActivity(editLocation); return true; } }); Button submitButton = (Button) findViewById(R.id.button5); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { moodMessage_text = Description.getText().toString(); MoodController moodController = new MoodController(); // --------------------------- achievements ------------------------------------- AchievementManager.initManager(CreateMoodActivity.this); AchievementController achievementController = new AchievementController(); achievements = achievementController.getAchievements(); achievements.moodCount += 1; achievementController.incrementMoodCounter(EmotionText); achievementController.saveAchievements(); // ------------------------------------------------------------------------------ if (location != null || pickLocation == 1) { //todo can remove these if/else statements that toast message too long. They could // be handled in the controller if (!MoodController.createMood(EmotionText, userName, moodMessage_text, latitude, longitude, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } else { if (!MoodController.createMood(EmotionText, userName, moodMessage_text, 0, 0, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } } }); }
From source file:com.mitre.holdshort.MainActivity.java
private void startUp() { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); checkGPSSettings(); }
From source file:com.metinkale.prayerapp.compass.Main.java
@Override protected void onResume() { super.onResume(); mSensorManager.unregisterListener(mMagAccel); mSensorManager.registerListener(mMagAccel, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(mMagAccel, mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_GAME); if (mSelCity == null) { mSelCity = (TextView) findViewById(R.id.selcity); mSelCity.setOnClickListener(new OnClickListener() { @Override//from www . j av a 2s.c o m public void onClick(View arg0) { if (App.isOnline()) { startActivity(new Intent(Main.this, LocationPicker.class)); } else { Toast.makeText(Main.this, R.string.noConnection, Toast.LENGTH_LONG).show(); } } }); } if (PermissionUtils.get(this).pLocation) { LocationManager locMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE); List<String> providers = locMan.getProviders(true); for (String provider : providers) { locMan.requestLocationUpdates(provider, 0, 0, this); Location lastKnownLocation = locMan.getLastKnownLocation(provider); if (lastKnownLocation != null) { calcQiblaAngel(lastKnownLocation); } } } if (Prefs.getCompassLat() != 0) { Location loc = new Location("custom"); loc.setLatitude(Prefs.getCompassLat()); loc.setLongitude(Prefs.getCompassLng()); calcQiblaAngel(loc); } }
From source file:au.gov.ga.worldwind.androidremote.client.Remote.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Normally one shouldn't instantiate all these objects in the onCreate method, //as onCreate is called every time a configuration change occurs (orientation, //keyboard hidden, screen size, etc). But we are handling configuration changes //ourselves./*from w w w. ja va 2 s .co m*/ //hide the status bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //get local Bluetooth adapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter == null) { Toast.makeText(this, R.string.bluetooth_unavailable, Toast.LENGTH_LONG).show(); finish(); return; } communicator = new AndroidCommunicator(this, bluetoothAdapter); communicator.addListener(this); remoteViewCommunicator = new SocketAndroidCommunicator(this); DatasetModelState datasetsState = new DatasetModelState(communicator, this); LayerModelState layersState = new LayerModelState(communicator, this); PlaceModelState placesState = new PlaceModelState(communicator, this); ItemModelState[] states = new ItemModelState[] { datasetsState, layersState, placesState }; for (ItemModelState state : states) { itemModelStates.put(state.getModel().getId(), state); ItemModelFragmentMenuProvider menuProvider = new EmptyMenuProvider(); if (state == placesState) { menuProvider = new PlacesMenuProvider(communicator); } menuProviders.put(state.getModel().getId(), menuProvider); } controlFragment = ControlFragment.newInstance(remoteViewCommunicator); datasetsFragment = ItemModelFragment.newInstance(datasetsState.getModel().getId(), false); layersFragment = ItemModelFragment.newInstance(layersState.getModel().getId(), false); flatLayersFragment = ItemModelFragment.newInstance(layersState.getModel().getId(), true); placesFragment = ItemModelFragment.newInstance(placesState.getModel().getId(), false); tabFragments = new Fragment[] { controlFragment, datasetsFragment, layersFragment, flatLayersFragment, placesFragment }; //create the tabs getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); int[] tabIds = new int[] { R.string.controls_tab, R.string.datasets_tab, R.string.layers_tab, R.string.flat_layers_tab, R.string.places_tab }; for (int i = 0; i < tabIds.length; i++) { ActionBar.Tab tab = getSupportActionBar().newTab(); tab.setTag(tabIds[i]); tab.setText(tabIds[i]); tab.setTabListener(this); getSupportActionBar().addTab(tab); } getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setHomeButtonEnabled(true); //setup the shake sensor sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensorListener.setOnShakeListener(new ShakeEventListener.OnShakeListener() { @Override public void onShake() { communicator.sendMessage(new ShakeMessage()); } }); // Acquire a reference to the system Location Manager LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { if (isSendLocation()) { communicator.sendMessage(new LocationMessage(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy(), location.getBearing())); } } public void onStatusChanged(String provider, int status, Bundle extras) { } public void onProviderEnabled(String provider) { } public void onProviderDisabled(String provider) { } }; locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); //locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); }
From source file:com.prey.activities.CheckPasswordActivity.java
@Override protected void onResume() { super.onResume(); bindPasswordControls();/* w w w. ja v a2s . c o m*/ TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text); final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password); Button password_btn_login = (Button) findViewById(R.id.password_btn_login); EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt); TextView textView1 = (TextView) findViewById(R.id.textView1); TextView textView2 = (TextView) findViewById(R.id.textView2); Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Regular.ttf"); Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Bold.ttf"); Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(), "fonts/MagdaClean/magdacleanmono-regular.ttf"); textView1.setTypeface(magdacleanmonoRegular); textView2.setTypeface(magdacleanmonoRegular); device_ready_h2_text.setTypeface(titilliumWebRegular); textForgotPassword.setTypeface(titilliumWebBold); password_btn_login.setTypeface(titilliumWebBold); password_pass_txt.setTypeface(magdacleanmonoRegular); try { textForgotPassword.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); } catch (Exception e) { } } }); } catch (Exception e) { } TextView textView5_1 = (TextView) findViewById(R.id.textView5_1); TextView textView5_2 = (TextView) findViewById(R.id.textView5_2); textView5_1.setTypeface(magdacleanmonoRegular); textView5_2.setTypeface(titilliumWebBold); TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall); LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour); textViewUninstall.setTypeface(titilliumWebBold); if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) { linearLayoutTour.setVisibility(View.GONE); textViewUninstall.setVisibility(View.VISIBLE); textViewUninstall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); finish(); } }); } else { linearLayoutTour.setVisibility(View.VISIBLE); textViewUninstall.setVisibility(View.GONE); try { linearLayoutTour.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), TourActivity1.class); Bundle b = new Bundle(); b.putInt("id", 1); intent.putExtras(b); startActivity(intent); finish(); } }); } catch (Exception e) { } } boolean showLocation = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this); boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this); boolean canAccessCamera = PreyPermission.canAccessCamera(this); boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this); boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this); if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState || !canAccessReadExternalStorage) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final FrameLayout frameView = new FrameLayout(this); builder.setView(frameView); final AlertDialog alertDialog = builder.create(); LayoutInflater inflater = alertDialog.getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.warning, frameView); TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title); TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body); warning_title.setTypeface(magdacleanmonoRegular); warning_body.setTypeface(titilliumWebBold); Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok); Button button_close = (Button) dialoglayout.findViewById(R.id.button_close); button_ok.setTypeface(titilliumWebBold); button_close.setTypeface(titilliumWebBold); final Activity thisActivity = this; button_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("askForPermission"); askForPermission(); alertDialog.dismiss(); } }); button_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("close ask"); alertDialog.dismiss(); } }); alertDialog.show(); showLocation = false; } else { showLocation = true; } } else { showLocation = true; } if (showLocation) { LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (isGpsEnabled || isNetworkEnabled) { PreyLogger.d("isGpsEnabled || isNetworkEnabled"); } else { PreyLogger.d("no gps ni red"); AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog alertDialog = builder.create(); TextView textview = new TextView(this); textview.setText(getString(R.string.location_settings)); textview.setMaxLines(10); textview.setTextSize(18F); textview.setPadding(20, 0, 20, 20); textview.setTextColor(Color.BLACK); builder.setView(textview); builder.setPositiveButton(getString(R.string.go_to_settings), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); return; } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); } }); builder.create().show(); } } }