获取 gaid
This commit is contained in:
parent
dc4871c8b0
commit
eb85079523
|
|
@ -9,17 +9,19 @@ import android.webkit.WebView
|
|||
import android.webkit.WebViewClient
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||
import com.ama.core.architecture.ext.toast
|
||||
import com.ama.core.architecture.util.AndroidUtil
|
||||
import com.gamedog.vididin.VidiConst
|
||||
import com.viddin.videos.free.R
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.viddin.videos.free.R
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.getValue
|
||||
import com.viddin.videos.free.databinding.ActivityGameBinding as ViewBinding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import com.gamedog.vididin.main.MainUiState as UiState
|
||||
import com.gamedog.vididin.main.MainViewModel as ViewModel
|
||||
import com.viddin.videos.free.databinding.ActivityGameBinding as ViewBinding
|
||||
|
||||
|
||||
@AndroidEntryPoint
|
||||
|
|
@ -27,10 +29,12 @@ class GameCenterActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(),
|
|||
|
||||
override val mViewModel: ViewModel by viewModels()
|
||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||
override var mEnableBannerAd = false
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun ViewBinding.initViews() {
|
||||
|
||||
|
||||
with(binding) {
|
||||
titlebar.setBackIconColor(R.color.black)
|
||||
titlebar.setTitleText(R.string.game_center, R.color.black)
|
||||
|
|
@ -67,9 +71,31 @@ class GameCenterActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(),
|
|||
return true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
webView.loadUrl(String.format(VidiConst.URL_GAME, AndroidUtil.getGaid()))
|
||||
loadGameCenterWeb()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun loadGameCenterWeb() {
|
||||
var gaid: String? = ""
|
||||
|
||||
showLoading(false)
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
gaid = AndroidUtil.getGaid()
|
||||
}
|
||||
|
||||
if (!gaid.isNullOrBlank()) {
|
||||
binding.webView.loadUrl(String.format(VidiConst.URL_GAME, gaid))
|
||||
hideLoading()
|
||||
} else {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,6 @@ dependencies {
|
|||
api 'io.github.pengxurui:modular-eventbus-api:1.0.5'
|
||||
api 'io.github.pengxurui:modular-eventbus-compiler:1.0.5'
|
||||
implementation project(':bill')
|
||||
api 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import android.widget.Toast
|
|||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.graphics.createBitmap
|
||||
import com.ama.core.architecture.BaseApp
|
||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import java.util.UUID
|
||||
|
|
@ -214,7 +215,13 @@ class AndroidUtil private constructor() {
|
|||
}
|
||||
|
||||
fun getGaid(): String? {
|
||||
return "ff498e7d-b737-4f36-b16e-25f1186c12f8"
|
||||
try {
|
||||
val adInfo = AdvertisingIdClient.getAdvertisingIdInfo(BaseApp.appContext())
|
||||
return adInfo.id
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue