Commit 29a62ad3 by cuiliang.shi

一直通知版本

1 parent f8ba8e21
...@@ -86,7 +86,7 @@ public class BirdService extends Service { ...@@ -86,7 +86,7 @@ public class BirdService extends Service {
intent2.addFlags(0x01000000); intent2.addFlags(0x01000000);
sendBroadcast(intent2); sendBroadcast(intent2);
if (DevicePreferences.getInstance(this).getBoolean("is_need_notification", true)){ // if (DevicePreferences.getInstance(this).getBoolean("is_need_notification", true)){
String CHANNEL_ONE_ID = "com.primedu.cn"; String CHANNEL_ONE_ID = "com.primedu.cn";
String CHANNEL_ONE_NAME = "Channel One"; String CHANNEL_ONE_NAME = "Channel One";
...@@ -113,9 +113,9 @@ public class BirdService extends Service { ...@@ -113,9 +113,9 @@ public class BirdService extends Service {
startForeground(1, notification); startForeground(1, notification);
}else{ // }else{
DevicePreferences.getInstance(this).putBoolean("is_need_notification", true); // DevicePreferences.getInstance(this).putBoolean("is_need_notification", true);
} // }
ret_cfgv = DevicePreferences.getInstance(getApplicationContext()).getString("bird_ret_cfgv", "2019031512"); ret_cfgv = DevicePreferences.getInstance(getApplicationContext()).getString("bird_ret_cfgv", "2019031512");
mPath = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH); mPath = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
...@@ -138,7 +138,12 @@ public class BirdService extends Service { ...@@ -138,7 +138,12 @@ public class BirdService extends Service {
if (amapLocation != null) { if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) { if (amapLocation.getErrorCode() == 0) {
mLocationCount++; mLocationCount++;
if (mLocationCount > 10){ Log.d(TAG, "amapLocation.getLatitude(): " + amapLocation.getLatitude()
+ ", amapLocation.getLongitude(): " + amapLocation.getLongitude()
+ ", amapLocation.getAccuracy():"+amapLocation.getAccuracy()
+"amapLocation.getLocationType()" + amapLocation.getLocationType());
if (mLocationCount > 5){
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
mStartTime = dateformat.format(System.currentTimeMillis()); mStartTime = dateformat.format(System.currentTimeMillis());
...@@ -153,14 +158,10 @@ public class BirdService extends Service { ...@@ -153,14 +158,10 @@ public class BirdService extends Service {
} }
} else { } else {
// setAlarm();
Log.e(TAG, "location Error, ErrCode:" Log.e(TAG, "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:" + amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo()); + amapLocation.getErrorInfo());
/* if (mLocationClient != null) {
mLocationClient.stopLocation();
}*/
} }
} else { } else {
Log.d(TAG, "location Error"); Log.d(TAG, "location Error");
...@@ -325,6 +326,7 @@ public class BirdService extends Service { ...@@ -325,6 +326,7 @@ public class BirdService extends Service {
//set model is AMapLocationMode.Battery_Saving //set model is AMapLocationMode.Battery_Saving
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
mLocationOption.setInterval(1000); mLocationOption.setInterval(1000);
mLocationOption.setLocationCacheEnable(false);
mLocationClient.setLocationOption(mLocationOption); mLocationClient.setLocationOption(mLocationOption);
mLocationClient.startLocation(); mLocationClient.startLocation();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!