我处理具有Unicode字符特殊编码的JSON响应。
例如:
private NotificationManager notificationManager;
public void sendNotification(String title,String message) {
//create intent
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
int uniqueInt = (int) (System.currentTimeMillis() & 0xfffffff);
//pending intent
PendingIntent pendingIntent = PendingIntent.getActivity(this, uniqueInt, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//Setting up Notification channels for android O and above.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
//create notification channel
int importance = NotificationManager.IMPORTANCE_HIGH;
assert notificationManager != null;
NotificationChannel mChannel = notificationManager.getNotificationChannel(channelId);
if (mChannel == null) {
mChannel = new NotificationChannel(channelId, title, importance);
mChannel.enableVibration(false);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
notificationManager.createNotificationChannel(mChannel);
}
}
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
.setContentTitle(title) // required
.setSmallIcon(R.mipmap.ic_launcher)// required
.setContentText(message) // required
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true) //dismisses the notification on click
.setContentIntent(pendingIntent)
.setSound(defaultSoundUri)
.setPriority(Notification.PRIORITY_HIGH);
if (android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
|| android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
notificationBuilder.setColor(getResources().getColor(R.color.notification_color));
notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.notification_large_icon));
}
int notificationId = new Random().nextInt(10000);
assert notificationManager != null;
notificationManager.notify(notificationId /* ID of notification */, notificationBuilder.build());
}
这种编码是什么?
如何在python中解码对传统\uffffffc3\uffffffab = ë
的响应?
谢谢