Skip to content

Commit

Permalink
修改对于定位模式的判断
Browse files Browse the repository at this point in the history
增加一个定位模式的判断,当设备处在【仅限设备】的定位模式时,返回DLocationWhat.ONLY_GPS_WORK
  • Loading branch information
D10NGYANG committed Apr 15, 2019
1 parent ed77e0f commit aa7d1cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class DLocationTools {
/**
* 打开Gps设置界面
*/
public static void openGpsSettings(Context context) {
public static void openGpsSettings(Context context, int what) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
((Activity) context).startActivityForResult(intent, what);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,9 @@ public int register(long minTime, long minDistance, OnLocationChangeListener lis
if (providers.contains( LocationManager.NETWORK_PROVIDER )) {
Log.i(TAG, "使用网络定位");
provider = LocationManager.NETWORK_PROVIDER;
} else if (providers.contains( LocationManager.GPS_PROVIDER )) {
Log.i( TAG, "使用GPS定位" );
provider = LocationManager.GPS_PROVIDER;
} else {
Log.i( TAG, "没有可用的位置提供器" );
return DLocationWhat.NO_LOCATIONMANAGER;
Log.i( TAG, "定位模式在仅限设备" );
return DLocationWhat.ONLY_GPS_WORK;
}

// 获取上一次的定位记录
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class DLocationWhat {
*/
public static final int NO_LOCATIONMANAGER = 3;

/**
* 没有定位的系统服务
*/
public static final int ONLY_GPS_WORK = 4;

/**
* 打开位置提供器
*/
Expand Down

0 comments on commit aa7d1cf

Please sign in to comment.