android 通知 可横幅展示的哦
生活随笔
收集整理的這篇文章主要介紹了
android 通知 可横幅展示的哦
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
找了好多個(gè)資源都不能橫幅展示用,終于弄出來(lái)了!老鐵們記得開(kāi)啟通知橫幅權(quán)限。
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);NotificationCompat.Builder notifyBuilder =new NotificationCompat.Builder( this ).setContentTitle( "title" ).setContentText( "ContentText" ).setSmallIcon( R.drawable.icon )// 點(diǎn)擊消失.setAutoCancel( true )// 設(shè)置該通知優(yōu)先級(jí).setPriority( Notification.PRIORITY_MAX ).setLargeIcon( BitmapFactory.decodeResource( this.getResources(), R.drawable.icon ) ) // .setTicker( mTicker )// 通知首次出現(xiàn)在通知欄,帶上升動(dòng)畫(huà)效果的.setWhen( System.currentTimeMillis() )// 通知產(chǎn)生的時(shí)間,會(huì)在通知信息里顯示// 向通知添加聲音、閃燈和振動(dòng)效果的最簡(jiǎn)單、最一致的方式是使用當(dāng)前的用戶(hù)默認(rèn)設(shè)置,使用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() );?
總結(jié)
以上是生活随笔為你收集整理的android 通知 可横幅展示的哦的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: p1863
- 下一篇: 骨传导耳机损伤大脑?具有不伤耳优点的骨传