위치정보 가져오기
This commit is contained in:
parent
4eaf93bca8
commit
af9da4c8ce
@ -90,6 +90,7 @@ dependencies {
|
||||
implementation ("org.jsoup:jsoup:1.18.1")
|
||||
implementation ("org.apache.commons:commons-text:1.12.0")
|
||||
implementation("com.squareup.okhttp:okhttp:2.7.5")
|
||||
implementation("com.google.android.gms:play-services-location:21.0.1")
|
||||
// implementation ("androidx.window:window:1.0.0")
|
||||
// implementation("io.github.vaneproject:hanguleditor:1.0.0")
|
||||
}
|
||||
|
||||
@ -150,9 +150,9 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
val COMIC_WORK_TAG = "ComicGetter"
|
||||
val COMIC2_WORK_TAG = "ComicGetter2"
|
||||
val REDDIT_WORK_TAG = "RedditGetter"
|
||||
val shortTimePeriod = 20L
|
||||
val longTimePeriod = 60L
|
||||
val midTimePeriod = 30L
|
||||
val shortTimePeriod = 200L
|
||||
val longTimePeriod = 600L
|
||||
val midTimePeriod = 300L
|
||||
var isOpendFold = false
|
||||
|
||||
@JvmStatic var lActivity: LauncherActivity? = null
|
||||
|
||||
@ -1,20 +1,29 @@
|
||||
package rasel.lunar.launcher.workers
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.location.Location
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.work.WorkerParameters
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.Priority
|
||||
import com.google.android.gms.tasks.CancellationTokenSource
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
|
||||
class OpenWeatherGetter : BaseGetter {
|
||||
companion object {
|
||||
val TAG = "OpenWeatherGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams)
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {}
|
||||
|
||||
override fun realWork(): Result {
|
||||
BLog.LOGE("${TAG} realWork() ")
|
||||
|
||||
|
||||
//위치 정보 {위 경도 가져오자}
|
||||
getLocation()
|
||||
|
||||
//87cd0810b7e4b4debd31a6ef98b98154
|
||||
//{https://home.openweathermap.org/api 에서 정보를 조회 하자}
|
||||
@ -24,4 +33,28 @@ class OpenWeatherGetter : BaseGetter {
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun getLocation() {
|
||||
val fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this.applicationContext)
|
||||
// if (ActivityCompat.checkSelfPermission(
|
||||
// this.applicationContext,
|
||||
// Manifest.permission.ACCESS_FINE_LOCATION
|
||||
// ) == PackageManager.PERMISSION_GRANTED &&
|
||||
// ActivityCompat.checkSelfPermission(
|
||||
// this.applicationContext,
|
||||
// Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
// ) == PackageManager.PERMISSION_GRANTED
|
||||
// ) {
|
||||
fusedLocationProviderClient.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY,CancellationTokenSource().token)
|
||||
.addOnSuccessListener{ success: Location? ->
|
||||
success?.let {
|
||||
BLog.LOGE("Location >>> $it")
|
||||
}
|
||||
}.addOnFailureListener{
|
||||
BLog.LOGE("Location error >>> $it")
|
||||
}
|
||||
return
|
||||
// }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user