相关疑难解决方法(0)

如何在Android Marshmallow上的Google地图上显示当前位置?

我想谷歌地图显示用户的位置.我尝试了这段代码,但它在Android 6上无效.

private GoogleMap map;
LocationManager lm;
LocationListener ll;
Location l;

LatLng pos;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.start_layout);

    lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    ll = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            l = (Location) location;
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {}

        @Override
        public void onProviderEnabled(String provider) {}

        @Override
        public void onProviderDisabled(String provider) {}
    };

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.nMap);
    mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
    map = …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-android-api-2

48
推荐指数
2
解决办法
10万
查看次数

使用android融合位置api在MyLocation上不显示蓝点和圆圈

我使用LocationManager跟踪用户当前位置.现在,在将位置管理器更改为FusedLocation API之后,即使在设置之后也不会显示蓝点和圆圈map.setMyLocationEnabled(true).我可以在地图片段的右上角看到当前位置图标,但点击它不会做任何事情.我将我的代码恢复到LocationManager现在我能够看到指向我当前位置的蓝点.使用Fused Location API可能有什么问题.

android google-maps-android-api-2 android-fusedlocation

11
推荐指数
2
解决办法
3万
查看次数

获取错误:无法找到类com.google.android.gms.common.GooglePlayServicesUtil.zza引用的类'android.app.AppOpsManager'

当我尝试在早于API级别22的手机上运行应用程序时,我收到此错误并导致程序崩溃.但是该应用程序在API级别为22的手机上正常工作.原因可能是什么.

这是我的依赖:

dependencies 
{
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'
    compile 'com.google.android.gms:play-services-analytics:7.5.0'

    compile project(':volley')
    compile project(':adjust_SDK')
    compile project(':euromessageLib')
    compile project(':com_viewpagerindicator')

    compile files('libs/adxtag3.2.6.jar')
    compile files('libs/jsoup-1.7.3.jar')
    compile files('libs/CWAC-Adapter.jar')
    compile files('libs/newrelic.android.jar')
    compile files('libs/android-query-full.0.26.8.jar')
    compile files('libs/khandroid-httpclient-4.2.3.jar')
    compile files('libs/GoogleConversionTrackingSdk-2.2.1.jar')

    compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
        transitive = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.deneme"
        minSdkVersion 14
        targetSdkVersion 22
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles 'proguard.cfg'
        }
    }
    productFlavors {
    }
}
Run Code Online (Sandbox Code Playgroud)

感谢帮助

android google-play-services

11
推荐指数
2
解决办法
3万
查看次数