播放铃声&振动电话?

时间:2010-07-07 10:51:45

标签: android

Notification notification = new Notification(icon, tickerText, when); 
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
notification.defaults |= Notification.DEFAULT_SOUND; 
notification.defaults |= Notification.DEFAULT_VIBRATE; 
notification.defaults |= Notification.DEFAULT_LIGHTS; 
notification.flags |= Notification.FLAG_AUTO_CANCEL; 

notification.flags |= Notification.FLAG_SHOW_LIGHTS; 
notification.ledARGB = 0xff00ff00; 
notification.ledOnMS = 300; 
notification.ledOffMS = 1000; 

Change in manifest :
<uses-permission 
        android:name="android.permission.VIBRATE"></uses-permission> 

我添加了上面的代码。它的运行没有错误。但没有看到效果。它是否运行在Android 1.5 ???

1 个答案:

答案 0 :(得分:1)

您需要将此通知设置包装到通知管理器调用中。

查看有关notificationmanager

的一些教程
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mManager.notify(APP_ID, notification);