strings = FileIOUtils.readFile2List(file);
+//// for (int i = 0; i < strings.size(); i++) {
+//// MapPosition bena = gson.fromJson(strings.get(i), type);
+//// pos.add(bena);
+//// }
+//// MapPosition current = new MapPosition();
+//// current.setCreateTime(TimeUtils.getNowString());
+//// current.setLatitude(bdLocation.getLatitude());
+//// current.setLongitude(bdLocation.getLongitude());
+//// String s = gson.toJson(pos);
+//// uploadLocation(s);
+//// } catch (Exception e) {
+//// e.printStackTrace();
+//// }
+//// }
+// // /**
+//// * 本地数据删除
+//// */
+//// private void deleteLocalCache() {
+//// String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "backlocation.txt";
+//// File locationFile = new File(filePath);
+//// if (locationFile.exists()) {
+//// locationFile.delete();
+//// }
+//// }
+// /**
+// * 开启socket
+// */
+//// private void startSocket() {
+//// initSocketManager();
+//// }
+//
+//// /**
+//// * 初始化SocketManager
+//// */
+//// private void initSocketManager() {
+//// Handler handler = new Handler();
+//// mInfo = new ConnectionInfo(BaseUrlApi.SOCKET_IP, 8080);
+//// mOkOptions = new OkSocketOptions.Builder()
+//// .setReconnectionManager(OkSocketOptions.getDefault().getReconnectionManager())//重连
+//// .setConnectTimeoutSecond(10)
+//// .setCallbackThreadModeToken(new OkSocketOptions.ThreadModeToken() {
+//// @Override
+//// public void handleCallbackEvent(ActionDispatcher.ActionRunnable runnable) {
+//// handler.post(runnable);
+//// }
+//// })
+//// .build();
+//// mManager = OkSocket.open(mInfo).option(mOkOptions);
+//// mManager.registerReceiver(socketListener);
+//// mManager.connect();
+//// }
}
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/Utils.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/Utils.java
index 68f7e38..7342e92 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/Utils.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/Utils.java
@@ -41,41 +41,41 @@ public class Utils {
// private final static String PRIMARY_CHANNEL = "default";
private final static String PRIMARY_CHANNEL = "txrealtimelocation";
- public synchronized static String getLocationStr(BDLocation location) {
- if (null == location) {
- return null;
- }
- StringBuffer sb = new StringBuffer();
- if (location != null) {
- sb.append("定位成功" + "\n");
- sb.append("定位类型: " + location.getLocType() + "\n");
- sb.append("经 度 : " + location.getLongitude() + "\n");
- sb.append("纬 度 : " + location.getLatitude() + "\n");
- sb.append("精 度 : " + location.getRadius() + "米" + "\n");
-
- sb.append("海 拔 : " + location.getAltitude() + "米" + "\n");
- sb.append("速 度 : " + location.getSpeed() + "米/秒" + "\n");
- sb.append("角 度 : " + location.getDirection() + "\n");
-
- //逆地理信息
- sb.append("国 家 : " + location.getCountry() + "\n");
- sb.append("省 : " + location.getProvince() + "\n");
- sb.append("市 : " + location.getCity() + "\n");
- sb.append("城市编码 : " + location.getCityCode() + "\n");
- sb.append("区 : " + location.getDistrict() + "\n");
- sb.append("区域 码 : " + location.getAdCode() + "\n");
- sb.append("地 址 : " + location.getAddress() + "\n");
- //定位完成的时间
- sb.append("定位时间: " + location.getTime() + "\n");
-
- } else {
- //定位失败
- sb.append("定位失败" + location.toString() + "\n");
- }
- //定位之后的回调时间
- sb.append("回调时间: " + formatUTC(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss") + "\n");
- return sb.toString();
- }
+// public synchronized static String getLocationStr(BDLocation location) {
+// if (null == location) {
+// return null;
+// }
+// StringBuffer sb = new StringBuffer();
+// if (location != null) {
+// sb.append("定位成功" + "\n");
+// sb.append("定位类型: " + location.getLocType() + "\n");
+// sb.append("经 度 : " + location.getLongitude() + "\n");
+// sb.append("纬 度 : " + location.getLatitude() + "\n");
+// sb.append("精 度 : " + location.getRadius() + "米" + "\n");
+//
+// sb.append("海 拔 : " + location.getAltitude() + "米" + "\n");
+// sb.append("速 度 : " + location.getSpeed() + "米/秒" + "\n");
+// sb.append("角 度 : " + location.getDirection() + "\n");
+//
+// //逆地理信息
+// sb.append("国 家 : " + location.getCountry() + "\n");
+// sb.append("省 : " + location.getProvince() + "\n");
+// sb.append("市 : " + location.getCity() + "\n");
+// sb.append("城市编码 : " + location.getCityCode() + "\n");
+// sb.append("区 : " + location.getDistrict() + "\n");
+// sb.append("区域 码 : " + location.getAdCode() + "\n");
+// sb.append("地 址 : " + location.getAddress() + "\n");
+// //定位完成的时间
+// sb.append("定位时间: " + location.getTime() + "\n");
+//
+// } else {
+// //定位失败
+// sb.append("定位失败" + location.toString() + "\n");
+// }
+// //定位之后的回调时间
+// sb.append("回调时间: " + formatUTC(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss") + "\n");
+// return sb.toString();
+// }
public synchronized static String formatUTC(long l, String strPattern) {
if (TextUtils.isEmpty(strPattern)) {
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/ExampleUtil.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/ExampleUtil.java
index d715eb8..4c21ba0 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/ExampleUtil.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/ExampleUtil.java
@@ -1,134 +1,134 @@
-package com.sucstepsoft.txrealtimelocation.services.jpush;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Bundle;
-import android.os.Looper;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.widget.Toast;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.helper.Logger;
-
-public class ExampleUtil {
- public static final String PREFS_NAME = "JPUSH_EXAMPLE";
- public static final String PREFS_DAYS = "JPUSH_EXAMPLE_DAYS";
- public static final String PREFS_START_TIME = "PREFS_START_TIME";
- public static final String PREFS_END_TIME = "PREFS_END_TIME";
- public static final String KEY_APP_KEY = "JPUSH_APPKEY";
-
- public static boolean isEmpty(String s) {
- if (null == s)
- return true;
- if (s.length() == 0)
- return true;
- if (s.trim().length() == 0)
- return true;
- return false;
- }
- /**
- * 只能以 “+” 或者 数字开头;后面的内容只能包含 “-” 和 数字。
- * */
- private final static String MOBILE_NUMBER_CHARS = "^[+0-9][-0-9]{1,}$";
- public static boolean isValidMobileNumber(String s) {
- if(TextUtils.isEmpty(s)) return true;
- Pattern p = Pattern.compile(MOBILE_NUMBER_CHARS);
- Matcher m = p.matcher(s);
- return m.matches();
- }
- // 校验Tag Alias 只能是数字,英文字母和中文
- public static boolean isValidTagAndAlias(String s) {
- Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
- Matcher m = p.matcher(s);
- return m.matches();
- }
-
- // 取得AppKey
- public static String getAppKey(Context context) {
- Bundle metaData = null;
- String appKey = null;
- try {
- ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
- context.getPackageName(), PackageManager.GET_META_DATA);
- if (null != ai)
- metaData = ai.metaData;
- if (null != metaData) {
- appKey = metaData.getString(KEY_APP_KEY);
- if ((null == appKey) || appKey.length() != 24) {
- appKey = null;
- }
- }
- } catch (NameNotFoundException e) {
-
- }
- return appKey;
- }
-
- // 取得版本号
- public static String GetVersion(Context context) {
- try {
- PackageInfo manager = context.getPackageManager().getPackageInfo(
- context.getPackageName(), 0);
- return manager.versionName;
- } catch (NameNotFoundException e) {
- return "Unknown";
- }
- }
-
- public static void showToast(final String toast, final Context context)
- {
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- Looper.prepare();
- Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
- Looper.loop();
- }
- }).start();
- }
-
- public static boolean isConnected(Context context) {
- ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo info = conn.getActiveNetworkInfo();
- return (info != null && info.isConnected());
- }
-
- public static String getImei(Context context, String imei) {
- String ret = null;
- try {
- TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- ret = telephonyManager.getDeviceId();
- } catch (Exception e) {
- Logger.e(ExampleUtil.class.getSimpleName(), e.getMessage());
- }
- if (isReadableASCII(ret)){
- return ret;
- } else {
- return imei;
- }
- }
-
- private static boolean isReadableASCII(CharSequence string){
- if (TextUtils.isEmpty(string)) return false;
- try {
- Pattern p = Pattern.compile("[\\x20-\\x7E]+");
- return p.matcher(string).matches();
- } catch (Throwable e){
- return true;
- }
- }
-
- public static String getDeviceId(Context context) {
- return JPushInterface.getUdid(context);
- }
-}
+//package com.sucstepsoft.txrealtimelocation.services.jpush;
+//
+//import android.content.Context;
+//import android.content.pm.ApplicationInfo;
+//import android.content.pm.PackageInfo;
+//import android.content.pm.PackageManager;
+//import android.content.pm.PackageManager.NameNotFoundException;
+//import android.net.ConnectivityManager;
+//import android.net.NetworkInfo;
+//import android.os.Bundle;
+//import android.os.Looper;
+//import android.telephony.TelephonyManager;
+//import android.text.TextUtils;
+//import android.widget.Toast;
+//
+//import java.util.regex.Matcher;
+//import java.util.regex.Pattern;
+//
+//import cn.jpush.android.api.JPushInterface;
+//import cn.jpush.android.helper.Logger;
+//
+//public class ExampleUtil {
+// public static final String PREFS_NAME = "JPUSH_EXAMPLE";
+// public static final String PREFS_DAYS = "JPUSH_EXAMPLE_DAYS";
+// public static final String PREFS_START_TIME = "PREFS_START_TIME";
+// public static final String PREFS_END_TIME = "PREFS_END_TIME";
+// public static final String KEY_APP_KEY = "JPUSH_APPKEY";
+//
+// public static boolean isEmpty(String s) {
+// if (null == s)
+// return true;
+// if (s.length() == 0)
+// return true;
+// if (s.trim().length() == 0)
+// return true;
+// return false;
+// }
+// /**
+// * 只能以 “+” 或者 数字开头;后面的内容只能包含 “-” 和 数字。
+// * */
+// private final static String MOBILE_NUMBER_CHARS = "^[+0-9][-0-9]{1,}$";
+// public static boolean isValidMobileNumber(String s) {
+// if(TextUtils.isEmpty(s)) return true;
+// Pattern p = Pattern.compile(MOBILE_NUMBER_CHARS);
+// Matcher m = p.matcher(s);
+// return m.matches();
+// }
+// // 校验Tag Alias 只能是数字,英文字母和中文
+// public static boolean isValidTagAndAlias(String s) {
+// Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
+// Matcher m = p.matcher(s);
+// return m.matches();
+// }
+//
+// // 取得AppKey
+// public static String getAppKey(Context context) {
+// Bundle metaData = null;
+// String appKey = null;
+// try {
+// ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
+// context.getPackageName(), PackageManager.GET_META_DATA);
+// if (null != ai)
+// metaData = ai.metaData;
+// if (null != metaData) {
+// appKey = metaData.getString(KEY_APP_KEY);
+// if ((null == appKey) || appKey.length() != 24) {
+// appKey = null;
+// }
+// }
+// } catch (NameNotFoundException e) {
+//
+// }
+// return appKey;
+// }
+//
+// // 取得版本号
+// public static String GetVersion(Context context) {
+// try {
+// PackageInfo manager = context.getPackageManager().getPackageInfo(
+// context.getPackageName(), 0);
+// return manager.versionName;
+// } catch (NameNotFoundException e) {
+// return "Unknown";
+// }
+// }
+//
+// public static void showToast(final String toast, final Context context)
+// {
+// new Thread(new Runnable() {
+//
+// @Override
+// public void run() {
+// Looper.prepare();
+// Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
+// Looper.loop();
+// }
+// }).start();
+// }
+//
+// public static boolean isConnected(Context context) {
+// ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+// NetworkInfo info = conn.getActiveNetworkInfo();
+// return (info != null && info.isConnected());
+// }
+//
+// public static String getImei(Context context, String imei) {
+// String ret = null;
+// try {
+// TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+// ret = telephonyManager.getDeviceId();
+// } catch (Exception e) {
+// Logger.e(ExampleUtil.class.getSimpleName(), e.getMessage());
+// }
+// if (isReadableASCII(ret)){
+// return ret;
+// } else {
+// return imei;
+// }
+// }
+//
+// private static boolean isReadableASCII(CharSequence string){
+// if (TextUtils.isEmpty(string)) return false;
+// try {
+// Pattern p = Pattern.compile("[\\x20-\\x7E]+");
+// return p.matcher(string).matches();
+// } catch (Throwable e){
+// return true;
+// }
+// }
+//
+// public static String getDeviceId(Context context) {
+// return JPushInterface.getUdid(context);
+// }
+//}
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/MyReceiver.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/MyReceiver.java
index 9f4d1cc..8b6d1b6 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/MyReceiver.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/MyReceiver.java
@@ -1,128 +1,128 @@
-package com.sucstepsoft.txrealtimelocation.services.jpush;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.content.LocalBroadcastManager;
-import android.text.TextUtils;
-
-import com.sucstepsoft.txrealtimelocation.activitys.base.MainActivity;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.Iterator;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.helper.Logger;
-
-/**
- * 自定义接收器
- *
- * 如果不定义这个 Receiver,则:
- * 1) 默认用户会打开主界面
- * 2) 接收不到自定义消息
- */
-public class MyReceiver extends BroadcastReceiver {
- private static final String TAG = "JIGUANG-Example";
-
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- Bundle bundle = intent.getExtras();
- Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
-
- if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
- String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
- Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
- //send the Registration Id to your server...
-
- } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
- processCustomMessage(context, bundle);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
- int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
-// //打开自定义的Activity
-// Intent i = new Intent(context, MainActivity.class);
-// i.putExtras(bundle);
-// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-// context.startActivity(i);
- } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
- //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
- } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
- boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
- Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
- } else {
- Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
- }
- } catch (Exception e) {
-
- }
-
- }
-
- // 打印所有的 intent extra 数据
- private static String printBundle(Bundle bundle) {
- StringBuilder sb = new StringBuilder();
- for (String key : bundle.keySet()) {
- if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
- sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
- } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
- sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
- } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
- if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
- Logger.i(TAG, "This message has no Extra data");
- continue;
- }
-
- try {
- JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
- Iterator it = json.keys();
-
- while (it.hasNext()) {
- String myKey = it.next();
- sb.append("\nkey:" + key + ", value: [" +
- myKey + " - " + json.optString(myKey) + "]");
- }
- } catch (JSONException e) {
- Logger.e(TAG, "Get message extra JSON error!");
- }
-
- } else {
- sb.append("\nkey:" + key + ", value:" + bundle.get(key));
- }
- }
- return sb.toString();
- }
-
- //send msg to MainActivity
- private void processCustomMessage(Context context, Bundle bundle) {
- if (MainActivity.isForeground) {
- String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
- String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
- Intent msgIntent = new Intent(MainActivity.MESSAGE_JPUSH);
- msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
- if (!ExampleUtil.isEmpty(extras)) {
- try {
- JSONObject extraJson = new JSONObject(extras);
- if (extraJson.length() > 0) {
- msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
- }
- } catch (JSONException e) {
-
- }
-
- }
- LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
- }
- }
-}
+//package com.sucstepsoft.txrealtimelocation.services.jpush;
+//
+//import android.content.BroadcastReceiver;
+//import android.content.Context;
+//import android.content.Intent;
+//import android.os.Bundle;
+//import android.support.v4.content.LocalBroadcastManager;
+//import android.text.TextUtils;
+//
+//import com.sucstepsoft.txrealtimelocation.activitys.base.MainActivity;
+//
+//import org.json.JSONException;
+//import org.json.JSONObject;
+//
+//import java.util.Iterator;
+//
+//import cn.jpush.android.api.JPushInterface;
+//import cn.jpush.android.helper.Logger;
+//
+///**
+// * 自定义接收器
+// *
+// * 如果不定义这个 Receiver,则:
+// * 1) 默认用户会打开主界面
+// * 2) 接收不到自定义消息
+// */
+//public class MyReceiver extends BroadcastReceiver {
+// private static final String TAG = "JIGUANG-Example";
+//
+// @Override
+// public void onReceive(Context context, Intent intent) {
+// try {
+// Bundle bundle = intent.getExtras();
+// Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
+//
+// if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
+// String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
+// Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
+// //send the Registration Id to your server...
+//
+// } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
+// Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
+// processCustomMessage(context, bundle);
+//
+// } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
+// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
+// int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
+// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
+//
+// } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
+// Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
+//// //打开自定义的Activity
+//// Intent i = new Intent(context, MainActivity.class);
+//// i.putExtras(bundle);
+//// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+//// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+//// context.startActivity(i);
+// } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
+// Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
+// //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
+// } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
+// boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
+// Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
+// } else {
+// Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
+// }
+// } catch (Exception e) {
+//
+// }
+//
+// }
+//
+// // 打印所有的 intent extra 数据
+// private static String printBundle(Bundle bundle) {
+// StringBuilder sb = new StringBuilder();
+// for (String key : bundle.keySet()) {
+// if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
+// sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
+// } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
+// sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
+// } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
+// if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
+// Logger.i(TAG, "This message has no Extra data");
+// continue;
+// }
+//
+// try {
+// JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
+// Iterator it = json.keys();
+//
+// while (it.hasNext()) {
+// String myKey = it.next();
+// sb.append("\nkey:" + key + ", value: [" +
+// myKey + " - " + json.optString(myKey) + "]");
+// }
+// } catch (JSONException e) {
+// Logger.e(TAG, "Get message extra JSON error!");
+// }
+//
+// } else {
+// sb.append("\nkey:" + key + ", value:" + bundle.get(key));
+// }
+// }
+// return sb.toString();
+// }
+//
+// //send msg to MainActivity
+// private void processCustomMessage(Context context, Bundle bundle) {
+// if (MainActivity.isForeground) {
+// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
+// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
+// Intent msgIntent = new Intent(MainActivity.MESSAGE_JPUSH);
+// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
+// if (!ExampleUtil.isEmpty(extras)) {
+// try {
+// JSONObject extraJson = new JSONObject(extras);
+// if (extraJson.length() > 0) {
+// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
+// }
+// } catch (JSONException e) {
+//
+// }
+//
+// }
+// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
+// }
+// }
+//}
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushMessageReceiver.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushMessageReceiver.java
index 3c2a934..7499761 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushMessageReceiver.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushMessageReceiver.java
@@ -1,138 +1,138 @@
-package com.sucstepsoft.txrealtimelocation.services.jpush;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.content.LocalBroadcastManager;
-import android.util.Log;
-
-import com.sucstepsoft.txrealtimelocation.activitys.base.LoginActivity;
-import com.sucstepsoft.txrealtimelocation.activitys.base.MainActivity;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import cn.jpush.android.api.CmdMessage;
-import cn.jpush.android.api.CustomMessage;
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.api.JPushMessage;
-import cn.jpush.android.api.NotificationMessage;
-import cn.jpush.android.service.JPushMessageReceiver;
-
-public class PushMessageReceiver extends JPushMessageReceiver{
- private static final String TAG = "PushMessageReceiver";
- @Override
- public void onMessage(Context context, CustomMessage customMessage) {
- Log.e(TAG,"[onMessage] "+customMessage);
- processCustomMessage(context,customMessage);
- }
-
- @Override
- public void onNotifyMessageOpened(Context context, NotificationMessage message) {
- Log.e(TAG,"[onNotifyMessageOpened] "+message);
- try{
- //打开自定义的Activity
- Intent i = new Intent(context, LoginActivity.class);
- Bundle bundle = new Bundle();
- bundle.putString(JPushInterface.EXTRA_NOTIFICATION_TITLE,message.notificationTitle);
- bundle.putString(JPushInterface.EXTRA_ALERT,message.notificationContent);
- i.putExtras(bundle);
- //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
- context.startActivity(i);
- }catch (Throwable throwable){
-
- }
- }
-
- @Override
- public void onMultiActionClicked(Context context, Intent intent) {
- Log.e(TAG, "[onMultiActionClicked] 用户点击了通知栏按钮");
- String nActionExtra = intent.getExtras().getString(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA);
-
- //开发者根据不同 Action 携带的 extra 字段来分配不同的动作。
- if(nActionExtra==null){
- Log.d(TAG,"ACTION_NOTIFICATION_CLICK_ACTION nActionExtra is null");
- return;
- }
- if (nActionExtra.equals("my_extra1")) {
- Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮一");
- } else if (nActionExtra.equals("my_extra2")) {
- Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮二");
- } else if (nActionExtra.equals("my_extra3")) {
- Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮三");
- } else {
- Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮未定义");
- }
- }
-
- @Override
- public void onNotifyMessageArrived(Context context, NotificationMessage message) {
- Log.e(TAG,"[onNotifyMessageArrived] "+message);
- }
-
- @Override
- public void onNotifyMessageDismiss(Context context, NotificationMessage message) {
- Log.e(TAG,"[onNotifyMessageDismiss] "+message);
- }
-
- @Override
- public void onRegister(Context context, String registrationId) {
- Log.e(TAG,"[onRegister] "+registrationId);
- }
-
- @Override
- public void onConnected(Context context, boolean isConnected) {
- Log.e(TAG,"[onConnected] "+isConnected);
- }
-
- @Override
- public void onCommandResult(Context context, CmdMessage cmdMessage) {
- Log.e(TAG,"[onCommandResult] "+cmdMessage);
- }
-
- @Override
- public void onTagOperatorResult(Context context,JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
- super.onTagOperatorResult(context, jPushMessage);
- }
- @Override
- public void onCheckTagOperatorResult(Context context,JPushMessage jPushMessage){
- TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
- super.onCheckTagOperatorResult(context, jPushMessage);
- }
- @Override
- public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
- super.onAliasOperatorResult(context, jPushMessage);
- }
-
- @Override
- public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
- TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
- super.onMobileNumberOperatorResult(context, jPushMessage);
- }
-
- //send msg to MainActivity
- private void processCustomMessage(Context context, CustomMessage customMessage) {
- if (MainActivity.isForeground) {
- String message = customMessage.message;
- String extras = customMessage.extra;
- Intent msgIntent = new Intent(MainActivity.MESSAGE_JPUSH);
- msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
- if (!ExampleUtil.isEmpty(extras)) {
- try {
- JSONObject extraJson = new JSONObject(extras);
- if (extraJson.length() > 0) {
- msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
- }
- } catch (JSONException e) {
-
- }
-
- }
- LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
- }
- }
-
-}
+//package com.sucstepsoft.txrealtimelocation.services.jpush;
+//
+//import android.content.Context;
+//import android.content.Intent;
+//import android.os.Bundle;
+//import android.support.v4.content.LocalBroadcastManager;
+//import android.util.Log;
+//
+//import com.sucstepsoft.txrealtimelocation.activitys.base.LoginActivity;
+//import com.sucstepsoft.txrealtimelocation.activitys.base.MainActivity;
+//
+//import org.json.JSONException;
+//import org.json.JSONObject;
+//
+//import cn.jpush.android.api.CmdMessage;
+//import cn.jpush.android.api.CustomMessage;
+//import cn.jpush.android.api.JPushInterface;
+//import cn.jpush.android.api.JPushMessage;
+//import cn.jpush.android.api.NotificationMessage;
+//import cn.jpush.android.service.JPushMessageReceiver;
+//
+//public class PushMessageReceiver extends JPushMessageReceiver{
+// private static final String TAG = "PushMessageReceiver";
+// @Override
+// public void onMessage(Context context, CustomMessage customMessage) {
+// Log.e(TAG,"[onMessage] "+customMessage);
+// processCustomMessage(context,customMessage);
+// }
+//
+// @Override
+// public void onNotifyMessageOpened(Context context, NotificationMessage message) {
+// Log.e(TAG,"[onNotifyMessageOpened] "+message);
+// try{
+// //打开自定义的Activity
+// Intent i = new Intent(context, LoginActivity.class);
+// Bundle bundle = new Bundle();
+// bundle.putString(JPushInterface.EXTRA_NOTIFICATION_TITLE,message.notificationTitle);
+// bundle.putString(JPushInterface.EXTRA_ALERT,message.notificationContent);
+// i.putExtras(bundle);
+// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
+// context.startActivity(i);
+// }catch (Throwable throwable){
+//
+// }
+// }
+//
+// @Override
+// public void onMultiActionClicked(Context context, Intent intent) {
+// Log.e(TAG, "[onMultiActionClicked] 用户点击了通知栏按钮");
+// String nActionExtra = intent.getExtras().getString(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA);
+//
+// //开发者根据不同 Action 携带的 extra 字段来分配不同的动作。
+// if(nActionExtra==null){
+// Log.d(TAG,"ACTION_NOTIFICATION_CLICK_ACTION nActionExtra is null");
+// return;
+// }
+// if (nActionExtra.equals("my_extra1")) {
+// Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮一");
+// } else if (nActionExtra.equals("my_extra2")) {
+// Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮二");
+// } else if (nActionExtra.equals("my_extra3")) {
+// Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮三");
+// } else {
+// Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮未定义");
+// }
+// }
+//
+// @Override
+// public void onNotifyMessageArrived(Context context, NotificationMessage message) {
+// Log.e(TAG,"[onNotifyMessageArrived] "+message);
+// }
+//
+// @Override
+// public void onNotifyMessageDismiss(Context context, NotificationMessage message) {
+// Log.e(TAG,"[onNotifyMessageDismiss] "+message);
+// }
+//
+// @Override
+// public void onRegister(Context context, String registrationId) {
+// Log.e(TAG,"[onRegister] "+registrationId);
+// }
+//
+// @Override
+// public void onConnected(Context context, boolean isConnected) {
+// Log.e(TAG,"[onConnected] "+isConnected);
+// }
+//
+// @Override
+// public void onCommandResult(Context context, CmdMessage cmdMessage) {
+// Log.e(TAG,"[onCommandResult] "+cmdMessage);
+// }
+//
+// @Override
+// public void onTagOperatorResult(Context context,JPushMessage jPushMessage) {
+// TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
+// super.onTagOperatorResult(context, jPushMessage);
+// }
+// @Override
+// public void onCheckTagOperatorResult(Context context,JPushMessage jPushMessage){
+// TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
+// super.onCheckTagOperatorResult(context, jPushMessage);
+// }
+// @Override
+// public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
+// TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
+// super.onAliasOperatorResult(context, jPushMessage);
+// }
+//
+// @Override
+// public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
+// TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
+// super.onMobileNumberOperatorResult(context, jPushMessage);
+// }
+//
+// //send msg to MainActivity
+// private void processCustomMessage(Context context, CustomMessage customMessage) {
+// if (MainActivity.isForeground) {
+// String message = customMessage.message;
+// String extras = customMessage.extra;
+// Intent msgIntent = new Intent(MainActivity.MESSAGE_JPUSH);
+// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
+// if (!ExampleUtil.isEmpty(extras)) {
+// try {
+// JSONObject extraJson = new JSONObject(extras);
+// if (extraJson.length() > 0) {
+// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
+// }
+// } catch (JSONException e) {
+//
+// }
+//
+// }
+// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
+// }
+// }
+//
+//}
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushService.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushService.java
index f3d2cd0..569a0c2 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushService.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/PushService.java
@@ -1,8 +1,11 @@
package com.sucstepsoft.txrealtimelocation.services.jpush;
-import cn.jpush.android.service.JCommonService;
+//import cn.jpush.android.service.JCommonService;
-public class PushService extends JCommonService {
+public class PushService {
}
+//public class PushService extends JCommonService {
+//
+//}
\ No newline at end of file
diff --git a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/TagAliasOperatorHelper.java b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/TagAliasOperatorHelper.java
index b342ef9..2ba610b 100755
--- a/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/TagAliasOperatorHelper.java
+++ b/app/src/main/java/com/sucstepsoft/txrealtimelocation/services/jpush/TagAliasOperatorHelper.java
@@ -1,378 +1,378 @@
-package com.sucstepsoft.txrealtimelocation.services.jpush;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.Message;
-import android.util.SparseArray;
-
-import com.sucstepsoft.cm_utils.utils.LogUtils;
-import com.sucstepsoft.cm_utils.utils.UserLgUtils;
-
-import java.util.Locale;
-import java.util.Set;
-
-import cn.jpush.android.api.JPushInterface;
-import cn.jpush.android.api.JPushMessage;
-import cn.jpush.android.helper.Logger;
-
-/**
- * 处理tagalias相关的逻辑
- */
-public class TagAliasOperatorHelper {
- private static final String TAG = "JIGUANG-TagAliasHelper";
- public static int sequence = 1;
- /**
- * 增加
- */
- public static final int ACTION_ADD = 1;
- /**
- * 覆盖
- */
- public static final int ACTION_SET = 2;
- /**
- * 删除部分
- */
- public static final int ACTION_DELETE = 3;
- /**
- * 删除所有
- */
- public static final int ACTION_CLEAN = 4;
- /**
- * 查询
- */
- public static final int ACTION_GET = 5;
-
- public static final int ACTION_CHECK = 6;
-
- public static final int DELAY_SEND_ACTION = 1;
-
- public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
-
- private Context context;
-
- private static TagAliasOperatorHelper mInstance;
-
- private TagAliasOperatorHelper() {
- }
-
- public static TagAliasOperatorHelper getInstance() {
- if (mInstance == null) {
- synchronized (TagAliasOperatorHelper.class) {
- if (mInstance == null) {
- mInstance = new TagAliasOperatorHelper();
- }
- }
- }
- return mInstance;
- }
-
- public void init(Context context) {
- if (context != null) {
- this.context = context.getApplicationContext();
- }
- }
-
- private SparseArray