location

Access LocationManager/ LocationListener from class

六眼飞鱼酱① 提交于 2020-08-25 04:31:31
问题 I'm kinda lost here: In my main activity, I register a LocationManager and connect it to a LocationListener to use myLocation.getLatitude() and such. Now I need to use the Location- methods from another class. I can't use those object from another class because I cant intantiate the main activity. I can't use getters to pass the L.Manager or L.Listener around, because those are non- static again. So, in general, how do i access objects that I created in the main activity? Any hints on how to

I am trying to get location a update it in server in every 30 minutes android

佐手、 提交于 2020-07-23 06:03:27
问题 I am trying to send user location in server. Fast i get the location and save in RoomDatabase and get data from RoomDatabase send to server. but i can't get location every 30 minutes when app in background. //Calling in mainactivity PeriodicWorkRequest periodicWork = new PeriodicWorkRequest.Builder(MyWorker.class, 30, TimeUnit.MINUTES) .addTag(TAG) .build(); WorkManager.getInstance().enqueueUniquePeriodicWork("Location", ExistingPeriodicWorkPolicy.REPLACE, periodicWork); // worker class