|
|
@@ -2,6 +2,10 @@ package com.usai.redant.apexdrivers;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
import android.app.Application;
|
|
|
+import android.app.Notification;
|
|
|
+import android.app.NotificationChannel;
|
|
|
+import android.app.NotificationManager;
|
|
|
+import android.app.PendingIntent;
|
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
@@ -14,6 +18,7 @@ import android.location.Location;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
+import android.support.v4.app.NotificationCompat;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
@@ -25,6 +30,8 @@ import com.usai.redant.rautils.receiver.RABroadcast;
|
|
|
import com.usai.redant.rautils.utils.AESUtil;
|
|
|
import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
public class ApexDriverApplication extends Application {
|
|
|
@@ -141,10 +148,10 @@ public class ApexDriverApplication extends Application {
|
|
|
|
|
|
loadBackgroundReportType();
|
|
|
|
|
|
- if (user != null) {
|
|
|
- // 上传Token
|
|
|
- Network.uploadToken(RAUtil.getDeviceId(getApplicationContext()));
|
|
|
- }
|
|
|
+// if (user != null) {
|
|
|
+// // 上传Token
|
|
|
+// Network.uploadToken(RAUtil.getDeviceId(getApplicationContext()));
|
|
|
+// }
|
|
|
|
|
|
Log.d("ApexDriverApplication", "onCreate: u:"+user+" p:"+password);
|
|
|
mServiceConnection = new ServiceConnection() {
|
|
|
@@ -538,4 +545,44 @@ public class ApexDriverApplication extends Application {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void receiveNotification(JSONObject notification) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void popLocalNotification(String title, String msg) {
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent = new Intent();
|
|
|
+ PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
|
|
|
+
|
|
|
+ //1.获取系统通知的管理者
|
|
|
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
|
+
|
|
|
+ Notification noti = null;
|
|
|
+
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
+
|
|
|
+ NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_NONE);
|
|
|
+ nm.createNotificationChannel(channel);
|
|
|
+
|
|
|
+ noti = new NotificationCompat.Builder(this, CHANNEL_ID)
|
|
|
+ .setContentTitle("我是大的标题")
|
|
|
+ .setContentText("我是内容")
|
|
|
+ .setSmallIcon(R.drawable.icon_50)
|
|
|
+ .setContentIntent(contentIntent)
|
|
|
+ .build();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ noti = new Notification.Builder(this)
|
|
|
+ .setContentTitle("我是大的标题")
|
|
|
+ .setContentText("我是内容")
|
|
|
+ .setSmallIcon(R.drawable.icon_50)
|
|
|
+ .setContentIntent(contentIntent)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ nm.notify(1, noti);
|
|
|
+ }
|
|
|
}
|