新聞中心
1.android3.0版本以上的用法:
NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder nb=new Builder(DownLoadService.this);
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:110"));
PendingIntent pendingIntent=PendingIntent.getActivity(DownLoadService.this, 0, intent, 0);
nb.setContentTitle("標(biāo)題");
nb.setContentText("內(nèi)容");
nb.setSmallIcon(R.drawable.alert_dark_frame);
nb.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.alert_dark_frame));
nb.setContentIntent(pendingIntent);
Notification notification=nb.build();
notification.flags= Notification.FLAG_AUTO_CANCEL;
nm.notify(0, notification);
2.android任何版本通用用法:
NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);Notification notification=new Notification(R.drawable.alert_dark_frame,"",System.currentTimeMillis());
notification.flags= Notification.FLAG_AUTO_CANCEL;
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:110"));
PendingIntent pendingIntent=PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "標(biāo)題", "內(nèi)容", pendingIntent);
nm.notify(0, notification);
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章標(biāo)題:Notification-創(chuàng)新互聯(lián)
新聞來(lái)源:http://ef60e0e.cn/article/djieso.html