简体   繁体   English

为什么 android 程序在我的手机上不起作用(它在虚拟手机上运行良好)

[英]Why android program doesnt work on my phone( it work on virtual phone fine)

 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()
    }

That is my code, when ı run it in the emulator it works fine with no error But when i run it with my phone( ı connect it to my pc) the button not working and it says :那是我的代码,当我在模拟器中运行它时它可以正常工作,没有错误但是当我用我的手机运行它时(我将它连接到我的电脑)按钮不起作用,它说:

V/AudioManager: querySoundEffectsEnabled...
D/AwareBitmapCacher: handleInit switch not opened pid=19134

Before that when the program opens in my phone the run seciton is like :在此之前,当程序在我的手机中打开时,运行部分如下:

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

this 3 are red How can i solve that problem?这 3 个是红色的 我该如何解决这个问题?

You should go to phone settings and find your application.您应该转到电话设置并找到您的应用程序。 Check location service is allowed.检查位置服务是允许的。 If not allowed.如果不允许。 Accept that.接受这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM