위치정보 가져오기

This commit is contained in:
JUNGGWAN KIM 2024-09-12 17:16:23 +09:00
parent 4eaf93bca8
commit af9da4c8ce
3 changed files with 38 additions and 4 deletions

View File

@ -90,6 +90,7 @@ dependencies {
implementation ("org.jsoup:jsoup:1.18.1") implementation ("org.jsoup:jsoup:1.18.1")
implementation ("org.apache.commons:commons-text:1.12.0") implementation ("org.apache.commons:commons-text:1.12.0")
implementation("com.squareup.okhttp:okhttp:2.7.5") 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 ("androidx.window:window:1.0.0")
// implementation("io.github.vaneproject:hanguleditor:1.0.0") // implementation("io.github.vaneproject:hanguleditor:1.0.0")
} }

View File

@ -150,9 +150,9 @@ internal class LauncherActivity : AppCompatActivity() {
val COMIC_WORK_TAG = "ComicGetter" val COMIC_WORK_TAG = "ComicGetter"
val COMIC2_WORK_TAG = "ComicGetter2" val COMIC2_WORK_TAG = "ComicGetter2"
val REDDIT_WORK_TAG = "RedditGetter" val REDDIT_WORK_TAG = "RedditGetter"
val shortTimePeriod = 20L val shortTimePeriod = 200L
val longTimePeriod = 60L val longTimePeriod = 600L
val midTimePeriod = 30L val midTimePeriod = 300L
var isOpendFold = false var isOpendFold = false
@JvmStatic var lActivity: LauncherActivity? = null @JvmStatic var lActivity: LauncherActivity? = null

View File

@ -1,20 +1,29 @@
package rasel.lunar.launcher.workers package rasel.lunar.launcher.workers
import android.Manifest
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import androidx.core.app.ActivityCompat
import androidx.work.WorkerParameters 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 import rasel.lunar.launcher.utils.BLog
class OpenWeatherGetter : BaseGetter { class OpenWeatherGetter : BaseGetter {
companion object { companion object {
val TAG = "OpenWeatherGetter" val TAG = "OpenWeatherGetter"
} }
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {}
override fun realWork(): Result { override fun realWork(): Result {
BLog.LOGE("${TAG} realWork() ") BLog.LOGE("${TAG} realWork() ")
//위치 정보 {위 경도 가져오자} //위치 정보 {위 경도 가져오자}
getLocation()
//87cd0810b7e4b4debd31a6ef98b98154 //87cd0810b7e4b4debd31a6ef98b98154
//{https://home.openweathermap.org/api 에서 정보를 조회 하자} //{https://home.openweathermap.org/api 에서 정보를 조회 하자}
@ -24,4 +33,28 @@ class OpenWeatherGetter : BaseGetter {
return Result.success() 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
// }
}
} }