MCPcopy Index your code
hub / github.com/ZTFtrue/My-note / init

Method init

android/AndroidGPS.java:23–57  ·  view source on GitHub ↗
(Activity activity, Handler handler)

Source from the content-addressed store, hash-verified

21 static boolean continueListener = true;
22
23 public Location init(Activity activity, Handler handler) {
24 String bestP = LocationManager.GPS_PROVIDER;
25 if (locationManager == null) {
26 locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
27
28 if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)
29 != PackageManager.PERMISSION_GRANTED &&
30 ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION)
31 != PackageManager.PERMISSION_GRANTED) {
32 return null;
33 }
34
35 locationManager.addGpsStatusListener(new GpsStatus.Listener() {
36 @Override
37 public void onGpsStatusChanged(int event) {
38
39 }
40 });
41 bestP = locationManager.getBestProvider(getCri(), true);
42 String finalBestP = bestP;
43 handler.postDelayed(new Runnable() {
44 @SuppressLint("MissingPermission")
45 @Override
46 public void run() {
47 locationManager.requestLocationUpdates(finalBestP, 1000, 1, locationListener);
48 if (continueListener) {
49 handler.postDelayed(this, 1000 * 20);
50 }
51 }
52 }, 1000 * 20);
53 locationManager.requestLocationUpdates(bestP, 1000, 100, locationListener);
54 }
55 location = locationManager.getLastKnownLocation(bestP);
56 return location;
57 }
58
59 @SuppressLint("MissingPermission")
60 public static Location getLocation() {

Callers 7

encryptMethod · 0.80
decryptMethod · 0.80
getUnsafeOkHttpClientMethod · 0.80
encryptMethod · 0.80
decryptMethod · 0.80
encryptFileMethod · 0.80
decryptFileMethod · 0.80

Calls 1

getCriMethod · 0.95

Tested by

no test coverage detected