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:com.forrestguice.suntimeswidget.getfix.GetFixHelper.java
public static boolean isGPSProviderEnabled(Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); }
From source file:com.eeshana.icstories.activities.UploadVideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this will copy the license file and the demo video file. // to the videokit work folder location. // without the license file the library will not work. //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded(); setContentView(R.layout.upload_video_activity); height = SignInActivity.getScreenHeight(UploadVideoActivity.this); width = SignInActivity.getScreenWidth(UploadVideoActivity.this); mProgressDialog = new ProgressDialog(UploadVideoActivity.this); pDialog = new ProgressDialog(UploadVideoActivity.this); showCustomToast = new ShowCustomToast(); connectionDetector = new ConnectionDetector(UploadVideoActivity.this); // mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT); // mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast); prefs = getSharedPreferences("PREF", MODE_PRIVATE); regId = prefs.getString("regid", "NA"); SharedPreferences pref = getSharedPreferences("DB", 0); userid = pref.getString("userid", "1"); SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0); assignment_id = assign_prefs.getString("ASSIGN_ID", ""); videoPath = getIntent().getStringExtra("VIDEOPATH"); // iCTextView=(TextView) findViewById(R.id.tvIC); // iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD); // storiesTextView=(TextView) findViewById(R.id.tvStories); // storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD); // watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory); // watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC); // logoImageView=(ImageView) findViewById(R.id.ivLogo); // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5)); // lp.addRule(RelativeLayout.CENTER_HORIZONTAL); // lp.setMargins(0, 0, 0, 0); // logoImageView.setLayoutParams(lp); uploadtTextView = (TextView) findViewById(R.id.tvUpload); uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); // extension=getIntent().getStringExtra("EXTENSION"); // folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder"; // if (!FileUtils.checkIfFolderExists(folderPath)) { // boolean isFolderCreated = FileUtils.createFolder(folderPath); // Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated); // if (isFolderCreated) { ///*from ww w .jav a 2s .com*/ // } // } //command for rotating video 90 degree //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension; //Change Video Resolution: //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension; //command for compressing video // String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension; // setCommand(commandStr); // runTranscoing(); thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND); System.out.println("THUMB IMG in uplaod== " + thumb); titleEditText = (EditText) findViewById(R.id.etTitle); titleEditText.setTypeface(CaptureVideoActivity.stories_typeface); descriptionEditText = (EditText) findViewById(R.id.etDescripton); descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface); locationEditText = (EditText) findViewById(R.id.etLocation); locationEditText.setTypeface(CaptureVideoActivity.stories_typeface); isAssignmentButton = (Button) findViewById(R.id.buttonCheck); isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface); isAssignmentButton.setOnClickListener(this); dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment); dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); uploadButton = (Button) findViewById(R.id.buttonUpload); uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload); RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17); lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment); lp9.setMargins(width / 7, 30, width / 7, 0); uploadRelativeLayout.setLayoutParams(lp9); uploadButton.setOnClickListener(this); //bottom bar homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome); homeRelativeLayout.setBackgroundResource(R.drawable.press_border); homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome); homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); homeTextView.setTextColor(Color.parseColor("#fffffe")); RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5); lp4.addRule(RelativeLayout.ALIGN_LEFT); homeRelativeLayout.setLayoutParams(lp4); homeRelativeLayout.setOnClickListener(this); wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall); wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall); wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5); lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome); wallRelativeLayout.setLayoutParams(lp5); wallRelativeLayout.setOnClickListener(this); settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings); settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings); settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD); RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5); lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall); settingsRelativeLayout.setLayoutParams(lp6); settingsRelativeLayout.setOnClickListener(this); // current location locationDialog = new Dialog(UploadVideoActivity.this); locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); locationDialog.setContentView(R.layout.location_dialog); locationDialog.setCancelable(true); LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1); okButton = (Button) dialogLayout.findViewById(R.id.OkBtn); okButton.setOnClickListener(this); cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn); cancelButton.setOnClickListener(this); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (network_enabled) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); } else { showCustomToast.showToast(UploadVideoActivity.this, "Could not find current location. Please enable location services of your device."); } // else if(gps_enabled == false){ // locationDialog.show(); // } }
From source file:com.forrestguice.suntimeswidget.getfix.GetFixHelper.java
public static boolean isNetProviderEnabled(Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); }
From source file:be.artoria.belfortapp.fragments.MapFragment.java
private GeoPoint getCurrentLocation() { // Get the location manager final LocationManager locationManager = (LocationManager) getActivity().getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the locatioin provider -> use // default/*from w w w. j a va 2 s . c o m*/ final Criteria criteria = new Criteria(); final String provider = locationManager.getBestProvider(criteria, false); final Location loc = locationManager.getLastKnownLocation(provider); if (loc != null) { return new GeoPoint(loc.getLatitude(), loc.getLongitude()); } else { return new GeoPoint(DataManager.BELFORT_LAT, DataManager.BELFORT_LON); } }
From source file:com.forrestguice.suntimeswidget.getfix.GetFixHelper.java
public static boolean isPassiveProviderEnabled(Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER); }
From source file:com.bangz.smartmute.services.LocationMuteService.java
private boolean addGeofences(List<Geofence> geofences) { ConnectionResult connresult = mGoogleApiClient.blockingConnect(); if (connresult.isSuccess() == false) { LogUtils.LOGE(TAG, "GoogleApiClient.blockingConnect failed! message: " + connresult.toString()); return false; }// w w w .j a va 2s .com GeofencingRequest gR = new GeofencingRequest.Builder().addGeofences(geofences) .setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_DWELL | GeofencingRequest.INITIAL_TRIGGER_EXIT) .build(); PendingIntent pi = getGeofencesPendingIntent(this); Status rs = LocationServices.GeofencingApi.addGeofences(mGoogleApiClient, gR, pi).await(); boolean bret = false; if (rs.isSuccess()) { LogUtils.LOGD(TAG, "Add Geofence successful."); PrefUtils.Geofencing(this, true); ReceUtils.enableReceiver(this, LocationProviderChangedReceiver.class, false); bret = true; } else { int errcode = rs.getStatusCode(); bret = false; LogUtils.LOGD(TAG, "Add Geofence failed! errorcode = " + errcode + "Message:" + rs.getStatusMessage()); if (errcode == GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE) { LocationManager lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER) || lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { LogUtils.LOGD(TAG, "GPS or Network Provider is enabled. " + "Notification User to try add again late?"); } else { ReceUtils.enableReceiver(this, LocationProviderChangedReceiver.class, true); } NotificationUserFailed(); } } mGoogleApiClient.disconnect(); return bret; }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
public void onProviderDisabled(String provider) { unregisterLocationListener(); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); getBestProvider(lm); }
From source file:de.madvertise.android.sdk.MadvertiseUtil.java
/** * Try to update current location. Non blocking call. * /*from w w w .j a v a 2s. c om*/ * @param context * application context */ public static void refreshCoordinates(final Context context) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Trying to refresh location"); if (context == null) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Context not set - quit location refresh"); return; } // check if we need a regular update if ((sLocationUpdateTimestamp + MadvertiseUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System .currentTimeMillis()) { MadvertiseUtil.logMessage(null, Log.DEBUG, "It's not time yet for refreshing the location"); return; } synchronized (context) { // recheck, if location was updated by another thread while we // paused if ((sLocationUpdateTimestamp + MadvertiseUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System .currentTimeMillis()) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Another thread updated the loation already"); return; } boolean permissionCoarseLocation = MadvertiseUtil .checkPermissionGranted(android.Manifest.permission.ACCESS_COARSE_LOCATION, context); boolean permissionFineLocation = MadvertiseUtil .checkPermissionGranted(android.Manifest.permission.ACCESS_FINE_LOCATION, context); // return (null) if we do not have any permissions if (!permissionCoarseLocation && !permissionFineLocation) { MadvertiseUtil.logMessage(null, Log.DEBUG, "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) { MadvertiseUtil.logMessage(null, Log.DEBUG, "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) { MadvertiseUtil.logMessage(null, Log.DEBUG, "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; sLocationUpdateTimestamp = System.currentTimeMillis(); locationManager.requestLocationUpdates(provider, 0, 0, new LocationListener() { @Override public void onLocationChanged(Location location) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Refreshing location"); sCurrentLocation = location; sLocationUpdateTimestamp = System.currentTimeMillis(); // stop draining battery life finalizedLocationManager.removeUpdates(this); } // not used yet @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }, context.getMainLooper()); } }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
public void onProviderEnabled(String provider) { unregisterLocationListener(); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); getBestProvider(lm); }
From source file:com.google.android.dialer.provider.DialerProvider.java
private Location getLastLocation() { LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); locationManager.requestSingleUpdate(new Criteria(), new LocationListener() { @Override//w ww .j av a2s . c om public void onLocationChanged(Location location) { if (Log.isLoggable("DialerProvider", Log.VERBOSE)) { Log.v("DialerProvider", "onLocationChanged: " + location); } } @Override public void onProviderDisabled(String provider) { if (Log.isLoggable("DialerProvider", Log.VERBOSE)) { Log.v("DialerProvider", "onProviderDisabled: " + provider); } } @Override public void onProviderEnabled(String provider) { if (Log.isLoggable("DialerProvider", Log.VERBOSE)) { Log.v("DialerProvider", "onProviderEnabled: " + provider); } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { if (Log.isLoggable("DialerProvider", Log.VERBOSE)) { Log.v("DialerProvider", "onStatusChanged: " + provider + ", " + status + ", " + extras); } } }, DialerProvider.mLooper); return locationManager.getLastLocation(); }