3 Star 3 Fork 2

CHINASOFT_OHOS / LocationManager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

LocationManager

项目介绍

  • 项目名称:LocationManager
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:LocationManager
  • 项目移植状态:主功能完成
  • 调用差异:无
  • 开发版本:sdk6,DevEco Studio2.2 beta1
  • 基线版本: release 2.4.1

效果演示

安装教程

1.在项目根目录下的build.gradle文件中,


allprojects {

   repositories {

       maven {

           url 'https://s01.oss.sonatype.org/content/repositories/release/'

       }

   }

}

2.在entry模块的build.gradle文件中,


dependencies {

   implementation('com.gitee.chinasoft_ohos:LocationManager:1.0.0')

   ......  

}

在sdk6,DevEco Studio2.2 beta1下项目可直接运行

如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,

并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下

使用说明

LocationManager支持在Ability、AbilitySlice、Fraction、Service中集成定位功能 每种组件对应一个父类,具体如下:

LocationBaseAbility

LocationBaseAbilitySlice

LocationBaseFraction

LocationBaseService

简单集成可以继承以上对应的抽象父类,并且实现其方法,如下:

public abstract LocationConfiguration getLocationConfiguration();

在子类中实现该方法,例如:

@Override
  public LocationConfiguration getLocationConfiguration() {
    return Configurations.defaultConfiguration("Give me the permission!", "Would you mind to turn GPS on?");
  }

在需要的时机调用获取定位的方法:

  getLocation();

提供如下方法处理定位过程和定位结果:

  /**
   * This method will be called whenever the process is changed.
   *
   * @param processType new on going process
   */
  void onProcessTypeChanged(int processType);

  /**
   * This method will be invoked whenever new location update received
   */
  void onLocationChanged(Location location);

  /**
   * When it is not possible to receive location, such as no active provider or no permission etc.
   * It will pass an integer value from {@linkplain FailType}
   * which will help you to determine how did it fail to receive location
   */
  void onLocationFailed(int type);

  /**
   * This method will be invoked when user grants for location permissions,
   * or when you ask for it but the application already had that granted.
   * You can determine if permission is just granted or
   * did the application already have it by checking boolean input of this method.
   */
  void onPermissionGranted(boolean alreadyHadPermission);
  /**
    *
    *
    */
  void onStatusChanged(int status);

 

也提供了定制化接口,例如:

LocationConfiguration awesomeConfiguration = new LocationConfiguration.Builder()
    .keepTracking(false)
    .askForPermission(new PermissionConfiguration.Builder()
        .permissionProvider(new YourCustomPermissionProvider())
        .rationaleMessage("Gimme the permission!")
        .rationaleDialogProvider(new YourCustomDialogProvider())
        .requiredPermissions(new String[] { permission.ACCESS_FINE_LOCATION })
        .build())
    
    .useDefaultProviders(new DefaultProviderConfiguration.Builder()
        .requiredTimeInterval(5 * 60 * 1000)
        .requiredDistanceInterval(0)
        .acceptableAccuracy(5.0f)
        .acceptableTimePeriod(5 * 60 * 1000)
        .gpsMessage("Turn on GPS?")
        .gpsDialogProvider(new YourCustomDialogProvider())
        .setWaitPeriod(ProviderType.GPS, 20 * 1000)
        .build())
    .build();

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 1.0.0
  • 0.0.1-SNAPSHOT

版权和许可信息

Copyright 2016 yayandroid

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

空文件

简介

基于系统原生定位API封装的定位工具,适用于各页面组件中集成定位功能 展开 收起
Java
取消

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/chinasoft_ohos/LocationManager.git
git@gitee.com:chinasoft_ohos/LocationManager.git
chinasoft_ohos
LocationManager
LocationManager
master

搜索帮助