android 通知 可横幅展示的哦
生活随笔
收集整理的這篇文章主要介紹了
android 通知 可横幅展示的哦
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
找了好多個資源都不能橫幅展示用,終于弄出來了!老鐵們記得開啟通知橫幅權限。
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);NotificationCompat.Builder notifyBuilder =new NotificationCompat.Builder( this ).setContentTitle( "title" ).setContentText( "ContentText" ).setSmallIcon( R.drawable.icon )// 點擊消失.setAutoCancel( true )// 設置該通知優先級.setPriority( Notification.PRIORITY_MAX ).setLargeIcon( BitmapFactory.decodeResource( this.getResources(), R.drawable.icon ) ) // .setTicker( mTicker )// 通知首次出現在通知欄,帶上升動畫效果的.setWhen( System.currentTimeMillis() )// 通知產生的時間,會在通知信息里顯示// 向通知添加聲音、閃燈和振動效果的最簡單、最一致的方式是使用當前的用戶默認設置,使用defaults屬性,可以組合:.setDefaults( Notification.DEFAULT_VIBRATE | Notification.DEFAULT_ALL | Notification.DEFAULT_SOUND );Intent XuanIntent = new Intent();XuanIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);XuanIntent.setClass(this, MainActivity.class);PendingIntent resultPendingIntent =PendingIntent.getActivity( this, 0, XuanIntent, PendingIntent.FLAG_UPDATE_CURRENT );notifyBuilder.setContentIntent( resultPendingIntent );mNotificationManager.notify( 0, notifyBuilder.build() );?
總結
以上是生活随笔為你收集整理的android 通知 可横幅展示的哦的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: p1863
- 下一篇: 骨传导耳机损伤大脑?具有不伤耳优点的骨传