我试过&搜索了很多次,但我的代码中没有弄到这里有什么问题。有些设备播放声音,但有些设备没有。例如:三星Note 3,三星on5,lecco le s2。我正在使用9.4 GCM API。
错误:
10-24 21:30:03.396 6813-6813/apk.apk.com E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
10-24 21:30:03.397 6813-6813/apk.apk.com E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found
代码:
Intent intent = new Intent(this,Splash_Activity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
int requestCode = 0;
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode, intent, PendingIntent.FLAG_ONE_SHOT);
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder noBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.n_logo)
.setContentText(message)
.setAutoCancel(true)
.setSound(sound)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setContentTitle(getResources().getString(R.string.app_name))
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, noBuilder.build()); //0 = ID of notification