public void cancelNotification()
{
NotificationCompat.Builder builder = new NotificationCompat.Builder(AcceptUserRequest.this);
builder.setSmallIcon(R.mipmap.lo);
builder.setLargeIcon(BitmapFactory.decodeResource(this.getApplicationContext().getResources(),
R.mipmap.peoplehelperlogo));
builder.setContentTitle("PEOPLE HELPER");
builder.setContentText("Accepted request has been cancelled");
builder.setAutoCancel(true);
Intent intent = new Intent(AcceptUserRequest.this, BroadcastFragment.class); //creates an explicit intent
TaskStackBuilder stackBuilder = TaskStackBuilder.create(AcceptUserRequest.this);
stackBuilder.addParentStack(AcceptUserRequest.this); //adds the intent
stackBuilder.addNextIntent(intent); //put the intent to the top of the stack
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); //(id, flag) //creates a pending intent
builder.setContentIntent(pendingIntent); //adds the PendingIntent to the builder
NotificationManager notificationManager = (NotificationManager) AcceptUserRequest.this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
}
0
A
回答
0
这些是一些虚拟代码,希望对您有所帮助。
私有静态NotificationCompat.Builder buildNotificationCommon(上下文_context,.....){
NotificationCompat.Builder builder = new NotificationCompat.Builder(_context).setWhen(System.currentTimeMillis()).......;
//Vibration
builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
//LED
builder.setLights(Color.RED, 3000, 3000);
//Ton
builder.setSound(Uri.parse("uri://sadfasdfasdf.mp3"));
return builder;
}
0
它可能会帮助你
NotificationCompat.Builder builder = new NotificationCompat.Builder(_context).setWhen(System.currentTimeMillis()).......;
//Vibration
builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
//LED
builder.setLights(Color.RED, 3000, 3000);
//Ton
builder.setSound(Uri.parse("uri://sadfasdfasdf.mp3"));
return builder;
相关问题
- 1. 通知的振动和声音默认设置为INSISTENT
- 2. UILocalNotification声音和振动设置IOS
- 3. 如何通过声音和振动使用通知?
- 4. Android通知,振动,但没有声音
- 5. 如何在广播接收器上设置振动和声音
- 6. 设置振动声音以在iOS上振动
- 7. 设置iphone通过应用程序振动和设置iphone回声音
- 8. 振动和声音LocalNotifications
- 9. 使用应用程序时禁用通知声音和振动
- 10. Android通知没有获得声音和振动
- 11. 通知声音,振动和LED不工作
- 12. 如何使Bluemix推送通知在Android上播放声音和振动
- 13. 如何通过Android API关闭所有声音和振动
- 14. 如何为本地通知设置图像和声音?
- 15. 如何在本地通知声音属性上设置自定义声音
- 16. 安卓通知默认振动,LED,声音
- 17. Android:推送通知没有声音/振动/光线
- 18. 没有显示,只有声音/振动的本地通知
- 19. 通知没有发出声音或振动?
- 20. Android通知不会发出声音或振动
- 21. 声音通知,但没有振动,相反
- 22. 工作声音/振动/ LED的通知,直到我取消它?
- 23. 通知振动,声音,当屏幕被锁定
- 24. 设置振动,灯光或声音的组合在android
- 25. 设置通知的自定义声音
- 26. 将通知声音设置为默认
- 27. 设置UILocal通知声音设置大尺寸音乐文件
- 28. 发挥振荡/振动会使声音
- 29. 在没有声音和振动的windows phone 8上敬酒通知
- 30. iPhone推送通知自定义声音,在静音模式下无振动?
我试图将其插入我的代码,但它不工作。 – LMae