List of usage examples for android.location LocationManager getAllProviders
public List<String> getAllProviders()
From source file:plugin.google.maps.CordovaGoogleMaps.java
private void _onActivityResultLocationPage(Bundle bundle) { String callbackId = bundle.getString("callbackId"); CallbackContext callbackContext = new CallbackContext(callbackId, this.webView); LocationManager locationManager = (LocationManager) this.activity .getSystemService(Context.LOCATION_SERVICE); List<String> providers = locationManager.getAllProviders(); int availableProviders = 0; if (mPluginLayout != null && mPluginLayout.isDebug) { Log.d(TAG, "---debug at getMyLocation(available providers)--"); }//from w ww. j ava2 s. com Iterator<String> iterator = providers.iterator(); String provider; boolean isAvailable; while (iterator.hasNext()) { provider = iterator.next(); isAvailable = locationManager.isProviderEnabled(provider); if (isAvailable) { availableProviders++; } if (mPluginLayout != null && mPluginLayout.isDebug) { Log.d(TAG, " " + provider + " = " + (isAvailable ? "" : "not ") + "available"); } } if (availableProviders == 0) { JSONObject result = new JSONObject(); try { result.put("status", false); result.put("error_code", "not_available"); result.put("error_message", "Since this device does not have any location provider, this app can not detect your location."); } catch (JSONException e) { e.printStackTrace(); } callbackContext.error(result); return; } _inviteLocationUpdateAfterActivityResult(bundle); }
From source file:com.RSMSA.policeApp.OffenceReportForm.java
/** * Start listening and recording locations *//*from w ww .j a va 2 s.c om*/ public void startRecording() { gpsTimer.cancel(); gpsTimer = new Timer(); long checkInterval = 60 * 1000; long minDistance = 1000; // receive updates LocationManager locationManager = (LocationManager) getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); for (String s : locationManager.getAllProviders()) { locationManager.requestLocationUpdates(s, checkInterval, minDistance, new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } @Override public void onLocationChanged(Location location) { // if this is a gps location, we can use it if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) { doLocationUpdate(location, true); } } }); } // start the gps receiver thread gpsTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Location location = getBestLocation(); doLocationUpdate(location, false); } }, 0, checkInterval); }
From source file:org.ohmage.reminders.types.location.LocTrigService.java
private void startGPS() { if (mGPSStarted) { return;/*from ww w .j a va 2 s .c om*/ } if (LocTrigConfig.useMotionDetection) { stopMotionDetection(); } //Get a wake lock for this duty cycle acquireWakeLock(); mNSamples = 0; mPrevSpeed = mCurrSpeed; Log.v(TAG, "LocTrigService: Turning on location updates"); LocationManager locMan = (LocationManager) getSystemService(LOCATION_SERVICE); List<String> providers = locMan.getAllProviders(); if (providers.contains(LocationManager.GPS_PROVIDER)) locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); //Use network location as well if (LocTrigConfig.useNetworkLocation) { if (mWifiLock != null) { if (!mWifiLock.isHeld()) { mWifiLock.acquire(); } } if (providers.contains(LocationManager.NETWORK_PROVIDER)) locMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); } cancelSamplingAlarm(ACTION_ALRM_GPS_SAMPLE); //Set GPS timeout setSamplingAlarm(ACTION_ALRM_GPS_TIMEOUT, GPS_TIMEOUT, 0); mGPSStarted = true; }
From source file:com.lewa.crazychapter11.MainActivity.java
public boolean hasGPSDevice(Context context) { final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (mgr == null) return false; final List<String> providers = mgr.getAllProviders(); if (providers == null) return false; Log.i("algerheGps", "System hasGps=" + providers.contains(LocationManager.GPS_PROVIDER)); return providers.contains(LocationManager.GPS_PROVIDER); }
From source file:com.mobilyzer.util.PhoneUtils.java
/** * Lazily initializes the location manager. * * As a side effect, assigns locationManager and locationProviderName. *///from w ww . j a v a 2s. c om private synchronized void initLocation() { if (locationManager == null) { LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Criteria criteriaCoarse = new Criteria(); /* "Coarse" accuracy means "no need to use GPS". * Typically a gShots phone would be located in a building, * and GPS may not be able to acquire a location. * We only care about the location to determine the country, * so we don't need a super accurate location, cell/wifi is good enough. */ criteriaCoarse.setAccuracy(Criteria.ACCURACY_COARSE); criteriaCoarse.setPowerRequirement(Criteria.POWER_LOW); String providerName = manager.getBestProvider(criteriaCoarse, /*enabledOnly=*/true); List<String> providers = manager.getAllProviders(); for (String providerNameIter : providers) { try { LocationProvider provider = manager.getProvider(providerNameIter); } catch (SecurityException se) { // Not allowed to use this provider Logger.w("Unable to use provider " + providerNameIter); continue; } Logger.i(providerNameIter + ": " + (manager.isProviderEnabled(providerNameIter) ? "enabled" : "disabled")); } /* Make sure the provider updates its location. * Without this, we may get a very old location, even a * device powercycle may not update it. * {@see android.location.LocationManager.getLastKnownLocation}. */ manager.requestLocationUpdates(providerName, /*minTime=*/0, /*minDistance=*/0, new LoggingLocationListener(), Looper.getMainLooper()); locationManager = manager; locationProviderName = providerName; } assert locationManager != null; assert locationProviderName != null; }
From source file:plugin.google.maps.GoogleMaps.java
@SuppressWarnings("unused") private void getMyLocation(final JSONArray args, final CallbackContext callbackContext) throws JSONException { LocationManager locationManager = (LocationManager) this.activity .getSystemService(Context.LOCATION_SERVICE); List<String> providers = locationManager.getAllProviders(); if (providers.size() == 0) { JSONObject result = new JSONObject(); result.put("status", false); result.put("error_code", "not_available"); result.put("error_message", "Since this device does not have any location provider, this app can not detect your location."); callbackContext.error(result);//from w w w . j a va 2 s. com return; } // enableHighAccuracy = true -> PRIORITY_HIGH_ACCURACY // enableHighAccuracy = false -> PRIORITY_BALANCED_POWER_ACCURACY JSONObject params = args.getJSONObject(0); boolean isHigh = false; if (params.has("enableHighAccuracy")) { isHigh = params.getBoolean("enableHighAccuracy"); } final boolean enableHighAccuracy = isHigh; String provider = null; if (enableHighAccuracy == true) { if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else if (locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) { provider = LocationManager.PASSIVE_PROVIDER; } } else { if (locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) { provider = LocationManager.PASSIVE_PROVIDER; } else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } } if (provider == null) { //Ask the user to turn on the location services. AlertDialog.Builder builder = new AlertDialog.Builder(this.activity); builder.setTitle("Improve location accuracy"); builder.setMessage("To enhance your Maps experience:\n\n" + " - Enable Google apps location access\n\n" + " - Turn on GPS and mobile network location"); builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Launch settings, allowing user to make a change Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); activity.startActivity(intent); JSONObject result = new JSONObject(); try { result.put("status", false); result.put("error_code", "open_settings"); result.put("error_message", "User opened the settings of location service. So try again."); } catch (JSONException e) { } callbackContext.error(result); } }); builder.setNegativeButton("Skip", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //No location service, no Activity dialog.dismiss(); JSONObject result = new JSONObject(); try { result.put("status", false); result.put("error_code", "service_denied"); result.put("error_message", "This app has rejected to use Location Services."); } catch (JSONException e) { } callbackContext.error(result); } }); builder.create().show(); return; } Location location = locationManager.getLastKnownLocation(provider); if (location != null) { JSONObject result = PluginUtil.location2Json(location); result.put("status", true); callbackContext.success(result); return; } PluginResult tmpResult = new PluginResult(PluginResult.Status.NO_RESULT); tmpResult.setKeepCallback(true); callbackContext.sendPluginResult(tmpResult); locationClient = new LocationClient(this.activity, new ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { LocationRequest request = new LocationRequest(); int priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; if (enableHighAccuracy) { priority = LocationRequest.PRIORITY_HIGH_ACCURACY; } request.setPriority(priority); locationClient.requestLocationUpdates(request, new LocationListener() { @Override public void onLocationChanged(Location location) { JSONObject result; try { result = PluginUtil.location2Json(location); result.put("status", true); callbackContext.success(result); } catch (JSONException e) { } locationClient.disconnect(); } }); } @Override public void onDisconnected() { } }, new OnConnectionFailedListener() { @Override public void onConnectionFailed(ConnectionResult connectionResult) { int errorCode = connectionResult.getErrorCode(); String errorMsg = GooglePlayServicesUtil.getErrorString(errorCode); PluginResult result = new PluginResult(PluginResult.Status.ERROR, errorMsg); callbackContext.sendPluginResult(result); } }); locationClient.connect(); }
From source file:com.linkbubble.ui.ContentView.java
void showAllowLocationDialog(final String origin, final WebRenderer.GetGeolocationCallback callback) { LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); if (locationManager == null || locationManager.getAllProviders() == null || locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER) == false) { return;// ww w . j ava2s . c om } String originCopy = origin.replace("http://", "").replace("https://", ""); String messageText = String.format(getResources().getString(R.string.requesting_location_message), originCopy); mRequestLocationTextView.setText(messageText); mRequestLocationContainer.setVisibility(View.VISIBLE); mRequestLocationShadow.setVisibility(View.VISIBLE); mRequestLocationYesButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { callback.onAllow(); hideAllowLocationDialog(); } }); }
From source file:com.aware.Aware_Preferences.java
/** * Location module settings UI/*from w ww . j av a2 s.co m*/ */ private void locations() { final CheckBoxPreference location_gps = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_LOCATION_GPS); location_gps.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS).equals("true")); location_gps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE); List<String> providers = localMng.getAllProviders(); if (!providers.contains(LocationManager.GPS_PROVIDER)) { showDialog(DIALOG_ERROR_MISSING_SENSOR); location_gps.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS, location_gps.isChecked()); if (location_gps.isChecked()) { framework.startLocations(); } else { framework.stopLocations(); } return true; } }); final CheckBoxPreference location_network = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_LOCATION_NETWORK); location_network.setChecked(Aware .getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK).equals("true")); location_network.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE); List<String> providers = localMng.getAllProviders(); if (!providers.contains(LocationManager.NETWORK_PROVIDER)) { showDialog(DIALOG_ERROR_MISSING_SENSOR); location_gps.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK, location_network.isChecked()); if (location_network.isChecked()) { framework.startLocations(); } else { framework.stopLocations(); } return true; } }); final EditTextPreference gpsInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LOCATION_GPS); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS).length() > 0) { gpsInterval .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS) + " seconds"); } gpsInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS)); gpsInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS, (String) newValue); gpsInterval.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); final EditTextPreference networkInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LOCATION_NETWORK); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK).length() > 0) { networkInterval.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK) + " seconds"); } networkInterval .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK)); networkInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK, (String) newValue); networkInterval.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); final EditTextPreference gpsAccuracy = (EditTextPreference) findPreference( Aware_Preferences.MIN_LOCATION_GPS_ACCURACY); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY).length() > 0) { gpsAccuracy.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY) + " meters"); } gpsAccuracy.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY)); gpsAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY, (String) newValue); gpsAccuracy.setSummary((String) newValue + " meters"); framework.startLocations(); return true; } }); final EditTextPreference networkAccuracy = (EditTextPreference) findPreference( Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY) .length() > 0) { networkAccuracy.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY) + " meters"); } networkAccuracy.setText( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY)); networkAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY, (String) newValue); networkAccuracy.setSummary((String) newValue + " meters"); framework.startLocations(); return true; } }); final EditTextPreference expirateTime = (EditTextPreference) findPreference( Aware_Preferences.LOCATION_EXPIRATION_TIME); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME).length() > 0) { expirateTime.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME) + " seconds"); } expirateTime.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME)); expirateTime.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME, (String) newValue); expirateTime.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); }
From source file:com.landenlabs.all_devtool.SystemFragment.java
public void updateList() { // Time today = new Time(Time.getCurrentTimezone()); // today.setToNow(); // today.format(" %H:%M:%S") Date dt = new Date(); m_titleTime.setText(m_timeFormat.format(dt)); boolean expandAll = m_list.isEmpty(); m_list.clear();/*from w w w.j a va2s.c o m*/ // Swap colors int color = m_rowColor1; m_rowColor1 = m_rowColor2; m_rowColor2 = color; ActivityManager actMgr = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); try { String androidIDStr = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); addBuild("Android ID", androidIDStr); try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext()); final String adIdStr = adInfo.getId(); final boolean isLAT = adInfo.isLimitAdTrackingEnabled(); addBuild("Ad ID", adIdStr); } catch (IOException e) { // Unrecoverable error connecting to Google Play services (e.g., // the old version of the service doesn't support getting AdvertisingId). } catch (GooglePlayServicesNotAvailableException e) { // Google Play services is not available entirely. } /* try { InstanceID instanceID = InstanceID.getInstance(getContext()); if (instanceID != null) { // Requires a Google Developer project ID. String authorizedEntity = "<need to make this on google developer site>"; instanceID.getToken(authorizedEntity, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); addBuild("Instance ID", instanceID.getId()); } } catch (Exception ex) { } */ ConfigurationInfo info = actMgr.getDeviceConfigurationInfo(); addBuild("OpenGL", info.getGlEsVersion()); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { long heapSize = Debug.getNativeHeapSize(); // long maxHeap = Runtime.getRuntime().maxMemory(); // ConfigurationInfo cfgInfo = actMgr.getDeviceConfigurationInfo(); int largHeapMb = actMgr.getLargeMemoryClass(); int heapMb = actMgr.getMemoryClass(); MemoryInfo memInfo = new MemoryInfo(); actMgr.getMemoryInfo(memInfo); final String sFmtMB = "%.2f MB"; Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("Mem Available (now)", String.format(sFmtMB, (double) memInfo.availMem / MB)); listStr.put("Mem LowWhenOnlyAvail", String.format(sFmtMB, (double) memInfo.threshold / MB)); if (Build.VERSION.SDK_INT >= 16) { listStr.put("Mem Installed", String.format(sFmtMB, (double) memInfo.totalMem / MB)); } listStr.put("Heap (this app)", String.format(sFmtMB, (double) heapSize / MB)); listStr.put("HeapMax (default)", String.format(sFmtMB, (double) heapMb)); listStr.put("HeapMax (large)", String.format(sFmtMB, (double) largHeapMb)); addBuild("Memory...", listStr); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { List<ProcessErrorStateInfo> procErrList = actMgr.getProcessesInErrorState(); int errCnt = (procErrList == null ? 0 : procErrList.size()); procErrList = null; // List<RunningAppProcessInfo> procList = actMgr.getRunningAppProcesses(); int procCnt = actMgr.getRunningAppProcesses().size(); int srvCnt = actMgr.getRunningServices(100).size(); Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("#Processes", String.valueOf(procCnt)); listStr.put("#Proc With Err", String.valueOf(errCnt)); listStr.put("#Services", String.valueOf(srvCnt)); // Requires special permission // int taskCnt = actMgr.getRunningTasks(100).size(); // listStr.put("#Tasks", String.valueOf(taskCnt)); addBuild("Processes...", listStr); } catch (Exception ex) { m_log.e("System-Processes %s", ex.getMessage()); } try { Map<String, String> listStr = new LinkedHashMap<String, String>(); listStr.put("LargeIconDensity", String.valueOf(actMgr.getLauncherLargeIconDensity())); listStr.put("LargeIconSize", String.valueOf(actMgr.getLauncherLargeIconSize())); putIf(listStr, "isRunningInTestHarness", "Yes", ActivityManager.isRunningInTestHarness()); putIf(listStr, "isUserAMonkey", "Yes", ActivityManager.isUserAMonkey()); addBuild("Misc...", listStr); } catch (Exception ex) { m_log.e("System-Misc %s", ex.getMessage()); } // --------------- Locale / Timezone ------------- try { Locale ourLocale = Locale.getDefault(); Date m_date = new Date(); TimeZone tz = TimeZone.getDefault(); Map<String, String> localeListStr = new LinkedHashMap<String, String>(); localeListStr.put("Locale Name", ourLocale.getDisplayName()); localeListStr.put(" Variant", ourLocale.getVariant()); localeListStr.put(" Country", ourLocale.getCountry()); localeListStr.put(" Country ISO", ourLocale.getISO3Country()); localeListStr.put(" Language", ourLocale.getLanguage()); localeListStr.put(" Language ISO", ourLocale.getISO3Language()); localeListStr.put(" Language Dsp", ourLocale.getDisplayLanguage()); localeListStr.put("TimeZoneID", tz.getID()); localeListStr.put(" DayLightSavings", tz.useDaylightTime() ? "Yes" : "No"); localeListStr.put(" In DLS", tz.inDaylightTime(m_date) ? "Yes" : "No"); localeListStr.put(" Short Name", tz.getDisplayName(false, TimeZone.SHORT, ourLocale)); localeListStr.put(" Long Name", tz.getDisplayName(false, TimeZone.LONG, ourLocale)); addBuild("Locale TZ...", localeListStr); } catch (Exception ex) { m_log.e("Locale/TZ %s", ex.getMessage()); } // --------------- Location Services ------------- try { Map<String, String> listStr = new LinkedHashMap<String, String>(); final LocationManager locMgr = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); GpsStatus gpsStatus = locMgr.getGpsStatus(null); if (gpsStatus != null) { listStr.put("Sec ToGetGPS", String.valueOf(gpsStatus.getTimeToFirstFix())); Iterable<GpsSatellite> satellites = gpsStatus.getSatellites(); Iterator<GpsSatellite> sat = satellites.iterator(); while (sat.hasNext()) { GpsSatellite satellite = sat.next(); putIf(listStr, String.format("Azm:%.0f, Elev:%.0f", satellite.getAzimuth(), satellite.getElevation()), String.format("%.2f Snr", satellite.getSnr()), satellite.usedInFix()); } } Location location = null; if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { location = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); } if (null != location) { listStr.put(location.getProvider() + " lat,lng", String.format("%.3f, %.3f", location.getLatitude(), location.getLongitude())); } if (listStr.size() != 0) { List<String> gpsProviders = locMgr.getAllProviders(); int idx = 1; for (String providerName : gpsProviders) { LocationProvider provider = locMgr.getProvider(providerName); if (null != provider) { listStr.put(providerName, (locMgr.isProviderEnabled(providerName) ? "On " : "Off ") + String.format("Accuracy:%d Pwr:%d", provider.getAccuracy(), provider.getPowerRequirement())); } } addBuild("GPS...", listStr); } else addBuild("GPS", "Off"); } catch (Exception ex) { m_log.e(ex.getMessage()); } // --------------- Application Info ------------- ApplicationInfo appInfo = getActivity().getApplicationInfo(); if (null != appInfo) { Map<String, String> appList = new LinkedHashMap<String, String>(); try { appList.put("ProcName", appInfo.processName); appList.put("PkgName", appInfo.packageName); appList.put("DataDir", appInfo.dataDir); appList.put("SrcDir", appInfo.sourceDir); // appList.put("PkgResDir", getActivity().getPackageResourcePath()); // appList.put("PkgCodeDir", getActivity().getPackageCodePath()); String[] dbList = getActivity().databaseList(); if (dbList != null && dbList.length != 0) appList.put("DataBase", dbList[0]); // getActivity().getComponentName(). } catch (Exception ex) { } addBuild("AppInfo...", appList); } // --------------- Account Services ------------- final AccountManager accMgr = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE); if (null != accMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); try { for (Account account : accMgr.getAccounts()) { strList.put(account.name, account.type); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Accounts...", strList); } // --------------- Package Features ------------- PackageManager pm = getActivity().getPackageManager(); FeatureInfo[] features = pm.getSystemAvailableFeatures(); if (features != null) { Map<String, String> strList = new LinkedHashMap<String, String>(); for (FeatureInfo featureInfo : features) { strList.put(featureInfo.name, ""); } addBuild("Features...", strList); } // --------------- Sensor Services ------------- final SensorManager senMgr = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (null != senMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); // Sensor accelerometer = senMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // senMgr.registerListener(foo, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); List<Sensor> listSensor = senMgr.getSensorList(Sensor.TYPE_ALL); try { for (Sensor sensor : listSensor) { strList.put(sensor.getName(), sensor.getVendor()); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Sensors...", strList); } try { if (Build.VERSION.SDK_INT >= 17) { final UserManager userMgr = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); if (null != userMgr) { try { addBuild("UserName", userMgr.getUserName()); } catch (Exception ex) { m_log.e(ex.getMessage()); } } } } catch (Exception ex) { } try { Map<String, String> strList = new LinkedHashMap<String, String>(); int screenTimeout = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT); strList.put("ScreenTimeOut", String.valueOf(screenTimeout / 1000)); int rotate = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); strList.put("RotateEnabled", String.valueOf(rotate)); if (Build.VERSION.SDK_INT >= 17) { // Global added in API 17 int adb = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED); strList.put("AdbEnabled", String.valueOf(adb)); } addBuild("Settings...", strList); } catch (Exception ex) { } if (expandAll) { // updateList(); int count = m_list.size(); for (int position = 0; position < count; position++) m_listView.expandGroup(position); } m_adapter.notifyDataSetChanged(); }