0 Followers
0 Following
0 Posts

NY times has confirmed that Putin has stated multiple times

https://lemmy.world/post/12479312

NY times has confirmed that Putin has stated multiple times - Lemmy.World

in justifications of SMO.

How to obtain a) cached b) live GPS location properly? What's the right approach?

https://lemmy.world/post/12239416

How to obtain a) cached b) live GPS location properly? What's the right approach? - Lemmy.World

I have an app which polls a remote server by sending to it its cache GPS location. Sometimes a remote server will ask for live location and an app must send it to it. — object MyLocationManager { val providers = listOf( LocationManager.GPS_PROVIDER, "fused", LocationManager.NETWORK_PROVIDER, LocationManager.PASSIVE_PROVIDER, ) fun getCached(ctx: Context, locationManager: LocationManager): Location? { for (provider in providers) { when (provider) { "fused" -> { val fusedLocationClient = LocationServices.getFusedLocationProviderClient(ctx) val fusedLocationTask = fusedLocationClient.lastLocation val fusedLocation = getTaskResult(fusedLocationTask) if (fusedLocation != null) { return fusedLocation } } else -> { if (locationManager.isProviderEnabled(provider)) { val lastKnownLocation = locationManager.getLastKnownLocation(provider) Log.d( TAG, "Provider: $provider, Last Known Location: $lastKnownLocation" ) if (lastKnownLocation != null) { return lastKnownLocation } } } } } return null } fun getLive(ctx: Context, locationManager: LocationManager): Location? { val locationListener = object : LocationListener { override fun onLocationChanged(location: Location) { //This works correctly! // //1) how to save its result? How to save it into cache? //2) or how to return it from here? Log.d(TAG, "onLocationChanged: ${location.latitude}, ${location.longitude}") stopLocationUpdates() } private fun stopLocationUpdates() { val fusedLocationClient = LocationServices.getFusedLocationProviderClient(ctx) try { // Stop location updates fusedLocationClient.removeLocationUpdates(locationCallback) Log.d(TAG, "Location updates stopped") } catch (e: SecurityException) { Log.e(TAG, "SecurityException while stopping location updates: ${e.message}") } } private val locationCallback = object : LocationCallback() { override fun onLocationResult(locationResult: LocationResult) { super.onLocationResult(locationResult) val location = locationResult.lastLocation if (location != null) { onLocationChanged(location) } else { Log.e(TAG, "Received null location in onLocationResult") } } } } for (provider in providers) { when (provider) { LocationManager.GPS_PROVIDER -> { //obsolete, in the last Android versions val _locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(0) .setFastestInterval(0) val fusedLocationClient = LocationServices.getFusedLocationProviderClient(ctx) val locationResult: Task = fusedLocationClient.getLocationAvailability() if (!Tasks.await(locationResult).isLocationAvailable) { return null } val locationTask: Task = fusedLocationClient.getCurrentLocation( LocationRequest.PRIORITY_HIGH_ACCURACY, null ) return Tasks.await(locationTask) } "fused" -> { val apiAvailability = GoogleApiAvailability.getInstance() val resultCode = apiAvailability.isGooglePlayServicesAvailable(ctx) if (resultCode == ConnectionResult.SUCCESS) { val fusedLocationClient = LocationServices.getFusedLocationProviderClient(ctx) val fusedLocationTask = fusedLocationClient.lastLocation val fusedLocation = getTaskResult(fusedLocationTask) if (fusedLocation != null) { return fusedLocation } } else { Log.w(TAG, " Google Play Services aren't available, can't use fused") } } else -> { if (locationManager.isProviderEnabled(provider)) { locationManager.requestSingleUpdate( provider, locationListener, Looper.getMainLooper() ) val lastKnownLocation = locationManager.getLastKnownLocation(provider) if (lastKnownLocation != null) { return lastKnownLocation } } } } } return null } } — An issue is that the code for obtaining GPS location doesn’t work properly. Firstly, I don’t know whether the approach in the code is correct. Secondly, I don’t know how to properly to return the GPS coordinates from a callback – see the comments. Thirdly, I don’t know how to force it to store the latest coordinates that it’s obtained into cache. And there’re some functions that’s been derprecated in the latest versions of Android, particularly in Android 10. How to do all of this? My device is rooted.

How to make my Android service run forever? On a rooted phone

https://lemmy.world/post/11987458

How to make my Android service run forever? On a rooted phone - Lemmy.World

I have a rooted Android 10. And I’ve written a service (off the class Service) which I want to run under too, in background. A service uses a microphone and location. It’s written in Kotlin. I’ve not found any information of how to run a service on a rooted device under root. I’ve found some, about running some commands in a service (code) itself under root, though, but it may be only a part of what I need. How to do it? Essentially, I want my service to run forever, with elevated preveligies, get it restarted if it fails, gets killed by Android. — Also, I’ve tried to copy it into /system and /system/init directories, but I haven’t been able to, due to “read-only file system”. Nor have I been able to remount it to make it writteable. I’ve managed to make the / writteable, but it didn’t allow me to copy my service in /system nonetheless.

Send 1 mln requests - strategy

https://lemmy.world/post/8957850

Send 1 mln requests - strategy - Lemmy.World

One needs to send 1 mln HTTP requests concurrently, in batches, and read the responses. No more than 100 requests at a time. Which way will it be better, recommended, idiomatic? * 1) Send 100 ones, wait for them to finish, send another 100, wait for them to finish… and so on * 2) Send 100 ones. And then keep adding new ones into the pool as requests in the pool finish. “Done - add a new one. Done - add a new one”.

Russia's economic growth shows Western sanctions effective - for Russia

https://lemmy.world/post/8957167

Russia's economic growth shows Western sanctions effective - for Russia - Lemmy.World

Putin has told you so

Europe's Biggest Nuclear Reactor Goes Offline Again

https://lemmy.world/post/8946277

Europe's Biggest Nuclear Reactor Goes Offline Again - Lemmy.World

The Putin keeps shutting Finland down

Russia's economic growth shows Western sanctions exceptionally effective - for Russia

https://lemmy.world/post/8896487

Russia's economic growth shows Western sanctions exceptionally effective - for Russia - Lemmy.World

It’s Time to End Magical Thinking About Russia’s Defeat

https://lemmy.world/post/8656324

It’s Time to End Magical Thinking About Russia’s Defeat - Lemmy.World

Essay | It’s Time to End Magical Thinking About Russia’s Defeat

https://lemmy.world/post/8650199

Essay | It’s Time to End Magical Thinking About Russia’s Defeat - Lemmy.World

How the West is Laundering Lies Through "Experts" to Target Gaza

https://lemmy.world/post/7637621

How the West is Laundering Lies Through "Experts" to Target Gaza - Lemmy.World