try {
val adresstext= findViewById(R.id.editText3)as TextView
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
fusedLocationClient.lastLocation.addOnSuccessListener {
location -> location
var locationx=location.longitude
var locationy=location.latitude
val name = findViewById(R.id.textView) as TextView
name.text=(locationx.toString()+" "+locationy.toString())
var geocoder: Geocoder
var listadress :List<Address>
geocoder = Geocoder(this, Locale.getDefault());
listadress =geocoder.getFromLocation(locationy,locationx,1)
var adress=listadress[0].getAddressLine(0)
var city =listadress[0].locality.get(0)
var state = listadress[0].adminArea.get(0)
var country = listadress[0].getCountryName()
var postalCode = listadress[0].getPostalCode()
var knownName = listadress[0].getFeatureName()
adresstext.text=(adress+city+state+country+postalCode+knownName)
}
}
catch (e: java.lang.Exception)
{
Toast.makeText(this,e.toString(),Toast.LENGTH_LONG).show()
}
这是我的代码,当ı在模拟器中运行它时,它工作得很好,没有错误,但当我用我的手机(ı连接到我的pc)运行它时,按钮不起作用,它说:
V/AudioManager: querySoundEffectsEnabled...
D/AwareBitmapCacher: handleInit switch not opened pid=19134
在此之前,当程序在我的手机中打开时,run seciton如下:
E/: APS:IFLoad:importExternalFunctions, search function createNewHwApsUtils failed, dlsym err:undefined symbol: createNewHwApsUtils
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@6c8edde
E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@3bb1bbf
这3个是红色的,我该怎么解决这个问题呢?
发布于 2020-02-20 20:02:09
您应该转到手机设置并找到您的应用程序。允许Check location服务。如果不允许的话。接受这个事实吧。
https://stackoverflow.com/questions/60319177
复制相似问题