美文网首页
如何使用

如何使用

作者: sunger | 来源:发表于2017-11-07 12:30 被阅读7次

如何使用


第一步获取依赖

compile 'com.zto.common:chooselocation:1.0.0'
#其他依赖
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'
compile "io.reactivex.rxjava2:rxjava:2.1.6"
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.33'

第二步初始化

  • 将百度平台获取的key,在你的项目清单文件里配置,将“百度平台申请的key”替换成你所申请的key
<meta-data
    android:name="com.baidu.lbsapi.API_KEY"
    android:value="百度平台申请的key" />

第三步获取位置

  • 启动选择位置页面,并且设置requestCode
Intent intent = new Intent(MainActivity.this,LocationActivity.class);
startActivityForResult(intent, REQUEST_CODE);
  • 获取定位参数
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == REQUEST_CODE ) {
                     ReverseGeoCodeResult reverseGeoCodeResult = data.getParcelableExtra(RESULT_SELECTED_POSITION);
        }
    }

相关文章

网友评论

      本文标题:如何使用

      本文链接:https://www.haomeiwen.com/subject/xdqrmxtx.html