尝试获取当前位置时出现Surface和Nativecrypto错误

时间:2018-08-10 14:25:03

标签: android kotlin kotlin-android-extensions create-react-kotlin-app

我遇到了错误:

E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7fc080e0
E/NativeCrypto: ssl=0x7f5ec8fc00 cert_verify_callback x509_store_ctx=0x7f5d8f0270 arg=0x0
E/NativeCrypto: ssl=0x7f5ec8fc00 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
E/MPlugin: Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport

当试图在kotlin android中获取当前位置时。

我尝试使用android 6和android 8,仍然出现错误,但我无法在地图上获取当前位置,空白地图打开

任何人都可以帮助我解决这里的问题吗,几天以来我一直困扰于这个问题?

这是我获取当前地图位置的代码:

class MapActivity : FragmentActivity(), OnMapReadyCallback,GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener,com.google.android.gms.location.LocationListener {
    private var service: LocationManager? = null
    private var enabled: Boolean? = null
    private var mCurrLocationMarker: Marker? = null
    private lateinit var mMap: GoogleMap
    private lateinit var mGoogleApiClient:GoogleApiClient
    private lateinit var mLastLocation:Location

    private lateinit var mLocationRequest:LocationRequest

    override fun onLocationChanged(location: Location) {

        mLastLocation = location
        val latLng=LatLng(location.latitude,location.longitude)

        val markerOptions = MarkerOptions()
        markerOptions.position(latLng)
        markerOptions.title("Current Position")
        markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA))
        mCurrLocationMarker = mMap.addMarker(markerOptions)
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15f))

    }
    override fun onConnected(bundle: Bundle?) {
        Log.d("sasas:","im here")

        mLocationRequest=LocationRequest()
        mLocationRequest.interval = 1000
        mLocationRequest.fastestInterval = 1000
        mLocationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY

        if (!enabled!!) {
            val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
        // Check if permission is granted or not
        if (ContextCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this)
        }
//        LocationServices.getFusedLocationProviderClient(this)
    }
    override fun onConnectionSuspended(p0: Int) {

    }

    override fun onConnectionFailed(p0: ConnectionResult) {

    }

    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_map)
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        service = this.getSystemService(LOCATION_SERVICE) as LocationManager
        enabled = service!!.isProviderEnabled(LocationManager.GPS_PROVIDER)
        val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
        mapFragment.getMapAsync(this)
    }


    override fun onMapReady(googleMap: GoogleMap) {
        mMap = googleMap
        mMap.mapType = GoogleMap.MAP_TYPE_NORMAL
        if (ActivityCompat.checkSelfPermission
                (this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return
        }
        buildGoogleApiClient()
        mMap.isMyLocationEnabled = true

    }
    @Synchronized
    fun buildGoogleApiClient(){
        mGoogleApiClient = GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build()
        mGoogleApiClient.connect()
    }

    }

上面的代码有什么问题?为什么我会得到这些错误?为什么显示空白地图而不显示当前位置?

0 个答案:

没有答案