0
嗨,伙伴我试图开发一个应用程序,需要在特定时间向用户发送通知。在互联网上,我发现这个代码,但日食说,它已被弃用。 你知道哪个是用我的API来完成它的正确方法吗? (16)已弃用Android状态栏代码
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
int icon = R.drawable.worldmap2;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText,when);
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
final Intent intent1 = new Intent(context, HttpExampleLimits.class);
PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent1, 0);
notification.setLatestEventInfo(context, contentTitle,contentText, pIntent);
nm.notify(1, notification);
非常感谢!