在我的Android应用程序中,我有以下代码:
Notification notification = new Notification(icon, tickerText, when);
context = context.getApplicationContext();
CharSequence contentTitle = "UK Radio Guide";
CharSequence contentText = title + " on " + channel_id + " at " + start;
Intent notificationIntent = new Intent(context, ViewSchedules.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.sound = Uri.parse("android.resource://com.robinwilson.radioguide/" +R.raw.chimes);
notification.vibrate = new long[] { 0, 300, 200, 300, 400, 300 };
// Actually send the notification
nm.notify(0, notification);
据我所知,我已按照文档中的步骤将其设置为从资源文件夹播放声音,并闪烁灯光。但是,这些都不会发生。然而,它按照指示振动。
任何想法我在这里做错了什么?我已经查看了我可以在AndroidManifest.xml文件中为应用程序提供的权限,但我看不到让它闪烁灯光或发出声音的权限。
答案 0 :(得分:1)
我假设你有
NotificationManager nm = ( NotificationManager ) getSystemService( NOTIFICATION_SERVICE );
我尝试之前没有答案,但之前我有过闪光LED。我建议你一次尝试一件(LED /声音/振动)。