Commit 3ddddd9a by TakeItEasyJQ

删除schoolId

parent ab5b9b81
...@@ -19,7 +19,6 @@ import org.json.JSONException; ...@@ -19,7 +19,6 @@ import org.json.JSONException;
import java.util.List; import java.util.List;
/** /**
* This class echoes a string called from JavaScript. * This class echoes a string called from JavaScript.
*/ */
...@@ -68,7 +67,6 @@ public class ONService extends CordovaPlugin { ...@@ -68,7 +67,6 @@ public class ONService extends CordovaPlugin {
Intent intent = new Intent(cordova.getActivity(), NotificationService.class); Intent intent = new Intent(cordova.getActivity(), NotificationService.class);
try { try {
intent.putExtra("idCard", args.getString(0)); intent.putExtra("idCard", args.getString(0));
intent.putExtra("schoolId", args.getString(1));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -92,14 +90,14 @@ public class ONService extends CordovaPlugin { ...@@ -92,14 +90,14 @@ public class ONService extends CordovaPlugin {
// 接触activity与service的绑定(最好在退出时调用) // 接触activity与service的绑定(最好在退出时调用)
if (action.equals("unbindService")) { if (action.equals("unbindService")) {
if (isServiceExisted(NotificationService.class.getName())){ cordova.getActivity().runOnUiThread(new Runnable() {
cordova.getActivity().runOnUiThread(new Runnable() { @Override
@Override public void run() {
public void run() { if (isServiceExisted(NotificationService.class.getName())) {
cordova.getActivity().unbindService(connection); cordova.getActivity().unbindService(connection);
} }
}); }
} });
} }
return false; return false;
} }
...@@ -113,15 +111,15 @@ public class ONService extends CordovaPlugin { ...@@ -113,15 +111,15 @@ public class ONService extends CordovaPlugin {
} }
public boolean isServiceExisted(String className) { public boolean isServiceExisted(String className) {
ActivityManager am = (ActivityManager) cordova.getActivity().getSystemService(Context.ACTIVITY_SERVICE); ActivityManager am = (ActivityManager) cordova.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> serviceList = am.getRunningServices(Integer.MAX_VALUE); List<ActivityManager.RunningServiceInfo> serviceList = am.getRunningServices(Integer.MAX_VALUE);
int myUid = android.os.Process.myUid(); int myUid = android.os.Process.myUid();
for (ActivityManager.RunningServiceInfo runningServiceInfo : serviceList) { for (ActivityManager.RunningServiceInfo runningServiceInfo : serviceList) {
if (runningServiceInfo.uid == myUid && runningServiceInfo.service.getClassName().equals(className)) { if (runningServiceInfo.uid == myUid && runningServiceInfo.service.getClassName().equals(className)) {
return true; return true;
}
} }
return false;
} }
return false;
}
} }
...@@ -97,7 +97,7 @@ public class NotificationService extends Service { ...@@ -97,7 +97,7 @@ public class NotificationService extends Service {
} }
}; };
final String webSocket = "ws://messagesrv.dev.campus.orhonedu.com:31288"; final String webSocket = "ws://messagesrv.dev.campus.orhonedu.com:31288";
final String api = "https://api.dev.campus.orhonedu.com/messagesrv/messagePush/userUnread/%s/%s"; final String api = "https://api.dev.campus.orhonedu.com/messagesrv/messagePush/userUnread/%s";
// --------------------------------------------- // ---------------------------------------------
...@@ -105,9 +105,6 @@ public class NotificationService extends Service { ...@@ -105,9 +105,6 @@ public class NotificationService extends Service {
// 17652 // 17652
private String userId; private String userId;
// 535
private String schoolId;
public static CordovaWebView webView; public static CordovaWebView webView;
public static CordovaInterface cordovaPlugin; public static CordovaInterface cordovaPlugin;
...@@ -156,7 +153,7 @@ public class NotificationService extends Service { ...@@ -156,7 +153,7 @@ public class NotificationService extends Service {
}; };
clientOffline = new OkHttpClient.Builder().build(); clientOffline = new OkHttpClient.Builder().build();
Request request = new Request.Builder().url(String.format(api, userId, schoolId)).build(); Request request = new Request.Builder().url(String.format(api, userId)).build();
if (null == timer) { if (null == timer) {
timer = new Timer(); timer = new Timer();
...@@ -211,7 +208,6 @@ public class NotificationService extends Service { ...@@ -211,7 +208,6 @@ public class NotificationService extends Service {
Intent intentPending; Intent intentPending;
intentPending = new Intent(this, HandleService.class); intentPending = new Intent(this, HandleService.class);
intentPending.putExtra("userId", userId); intentPending.putExtra("userId", userId);
intentPending.putExtra("schoolId", schoolId);
intentPending.putExtra("object", gson.toJson(content)); intentPending.putExtra("object", gson.toJson(content));
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intentPending, PendingIntent pendingIntent = PendingIntent.getService(this, 0, intentPending,
...@@ -237,9 +233,8 @@ public class NotificationService extends Service { ...@@ -237,9 +233,8 @@ public class NotificationService extends Service {
} }
public class MyBinder extends Binder { public class MyBinder extends Binder {
public void setId(String idCard, String schoolId) { public void setId(String idCard) {
NotificationService.this.userId = idCard; NotificationService.this.userId = idCard;
NotificationService.this.schoolId = schoolId;
} }
public void startForeGround() { public void startForeGround() {
...@@ -294,7 +289,6 @@ public class NotificationService extends Service { ...@@ -294,7 +289,6 @@ public class NotificationService extends Service {
Log.e(TAG, "onBind: "); Log.e(TAG, "onBind: ");
NotificationService.this.userId = intent.getStringExtra("idCard"); NotificationService.this.userId = intent.getStringExtra("idCard");
NotificationService.this.schoolId = intent.getStringExtra("schoolId");
client = new OkHttpClient.Builder().readTimeout(3, TimeUnit.SECONDS).writeTimeout(3, TimeUnit.SECONDS) client = new OkHttpClient.Builder().readTimeout(3, TimeUnit.SECONDS).writeTimeout(3, TimeUnit.SECONDS)
.connectTimeout(3, TimeUnit.SECONDS).build(); .connectTimeout(3, TimeUnit.SECONDS).build();
Request request = new Request.Builder().url(webSocket).build(); Request request = new Request.Builder().url(webSocket).build();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment