点击操作不适用于我的Xiamoi设备(牛轧糖),但可以与三星(棒棒糖)一起正常使用
Firebasemessaging服务的代码如下所示
public class FirebaseMessagingService extends
com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
String notification_title = remoteMessage.getNotification().getTitle();
String notification_message = remoteMessage.getNotification().getBody();
long[] v = {500,1000};
NotificationCompat.Builder mBuilder ;
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder = new NotificationCompat.Builder(this, "notify")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(notification_title)
.setContentText(notification_message)
.setSound(uri);
mBuilder.setVibrate(v);
Intent resultIntent = new Intent("MAINACTIVITY");
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
this,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
int mNotificationId = (int) System.currentTimeMillis();
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId, mBuilder.build());
}
}
我在Samsung上进行了测试,效果很好,但对于Xiamoi而言,单击操作没有响应。我不知道错误在哪里。