本文整理了Java中android.app.Notification.setLatestEventInfo()
方法的一些代码示例,展示了Notification.setLatestEventInfo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.setLatestEventInfo()
方法的具体详情如下:
包路径:android.app.Notification
类名称:Notification
方法名:setLatestEventInfo
暂无
代码示例来源:origin: stackoverflow.com
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
Intent notificationIntent = new Intent(context, HomeActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
代码示例来源:origin: stackoverflow.com
private void showRecordingNotification(){
Notification not = new Notification(R.drawable.icon, "Application started", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, main.class), Notification.FLAG_ONGOING_EVENT);
not.flags = Notification.FLAG_ONGOING_EVENT;
not.setLatestEventInfo(this, "Application Name", "Application Description", contentIntent);
mNotificationManager.notify(1, not);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreate() {
NotificationManager mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.notification_icon, "Notify Alarm strart", System.currentTimeMillis());
Intent myIntent = new Intent(this , MyActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "Notify label", "Notify text", contentIntent);
mNM.notify(NOTIFICATION, notification);
}
代码示例来源:origin: stackoverflow.com
Intent intent = new Intent(this, cls);
intent.putExtra("extra", extra);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), id, intent, PendingIntent.FLAG_ONE_SHOT);
notifyDetails.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
mNotificationManager.notify(id, notifyDetails);
代码示例来源:origin: robolectric/robolectric
@Test
public void setLatestEventInfo__shouldCaptureContentIntent() throws Exception {
PendingIntent pendingIntent = PendingIntent.getActivity(application, 0, new Intent(), 0);
Notification notification = new Notification();
notification.setLatestEventInfo(application, "title", "content", pendingIntent);
assertThat(notification.contentIntent).isSameAs(pendingIntent);
}
}
代码示例来源:origin: stackoverflow.com
Intent notificationIntent = new Intent(mContext, HandleNotificationClickService.class);
PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, notificationIntent, 0);
Notification notification = new Notification(icon, tickerText,System.currentTimeMillis());
notification.setLatestEventInfo(mContext,contentTitle , contentText, pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONGOING_EVENT;
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(CALLER_ID_NOTIFICATION_ID, notification);
代码示例来源:origin: stackoverflow.com
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,
"Hello from service", System.currentTimeMillis());
Intent intent = new Intent(this, MainActivity.class);
notification.setLatestEventInfo(this, "contentTitle", "contentText",
PendingIntent.getActivity(this, 1, intent, 0));
manager.notify(111, notification);
代码示例来源:origin: stackoverflow.com
void fg() {
Notification notification = new Notification(R.drawable.logstatus,
"Logging On", System.currentTimeMillis());
Intent notificationIntent = new Intent(this, LoggerActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.setLatestEventInfo(this, "Logger","Logger Running",
pendingIntent);
startForeground(1, notification);
}
代码示例来源:origin: stackoverflow.com
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, notId + selectedPosition, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, rightNow.getTimeInMillis() - offset, pendingIntent);
Notification notification = new Notification(R.drawable.icon, "TVGuide Υπενθύμιση", System.currentTimeMillis());
NotificationManager manger = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
notification.setLatestEventInfo(context, "Κανάλι: " + b.getString("channel"), "Εκπομπή: " + showname, pendingIntent);
manger.notify(notId, notification);
代码示例来源:origin: stackoverflow.com
public class ReminderService extends IntentService {
private static final int NOTIF_ID = 1;
public ReminderService(){
super("ReminderService");
}
@Override
protected void onHandleIntent(Intent intent) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
long when = System.currentTimeMillis(); // notification time
Notification notification = new Notification(R.drawable.icon, "reminder", when);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(this, YourActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent , 0);
notification.setLatestEventInfo(getApplicationContext(), "It's about time", "You should open the app now", contentIntent);
nm.notify(NOTIF_ID, notification);
}
}
代码示例来源:origin: stackoverflow.com
Notification notification = new Notification(R.drawable.statusbar_icon,
"Rolling text on statusbar", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, YourActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this,
"Notification title", "Notification description", contentIntent);
startForeground(1, notification);
代码示例来源:origin: stackoverflow.com
ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder binder) {
((KillBinder) binder).service.startService(new Intent(
MainActivity.this, KillNotificationsService.class));
Notification notification = new Notification(
R.drawable.ic_launcher, "Text",
System.currentTimeMillis());
Intent notificationIntent = new Intent(MainActivity.this,
Place.class);
PendingIntent contentIntent = PendingIntent.getActivity(
MainActivity.this, 0, notificationIntent, 0);
notification.setLatestEventInfo(getApplicationContext(),
"Text", "Text", contentIntent);
NotificationManager mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNM.notify(KillNotificationsService.NOTIFICATION_ID,
notification);
}
public void onServiceDisconnected(ComponentName className) {
}
};
bindService(new Intent(MainActivity.this,
KillNotificationsService.class), mConnection,
Context.BIND_AUTO_CREATE);
代码示例来源:origin: stackoverflow.com
System.currentTimeMillis());
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(this, HomeScreenActivity.class);
intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
notification.setLatestEventInfo(this, title,
text, contentIntent);
mNM.notify(R.string.app_name, notification);
代码示例来源:origin: stackoverflow.com
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this, YourActivity.class);
Notification notification = new Notification(R.drawable.icon, "Notify", System.currentTimeMillis());
notification.setLatestEventInfo(YourClass.this, "App Name","Description of the notification", PendingIntent.getActivity(this.getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
mManager.notify(APP_ID, notification);
代码示例来源:origin: stackoverflow.com
protected void onMessage(Context context, Intent intent) {
Log.d(TAG, "onMessage - context: " + context);
// Extract the payload from the message
Bundle extras = intent.getExtras();
if (extras != null)
{
boolean foreground = this.isInForeground();
extras.putBoolean("foreground", foreground);
if (foreground){
PushHandlerActivity.sendToApp(extras);
}else{
String message = extras.getString("message");
String title = extras.getString("title");
Notification notif = new Notification(android.R.drawable.btn_star_big_on, message, System.currentTimeMillis() );
notif.flags = Notification.FLAG_AUTO_CANCEL;
notif.defaults |= Notification.DEFAULT_SOUND;
notif.defaults |= Notification.DEFAULT_VIBRATE;
String url = "notify";
Intent notificationIntent = new Intent(context, MyPhoneGapActivity.class);
//here you pass the information
notificationIntent.putExtra ("url",url);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notif.setLatestEventInfo(context, title, message, contentIntent);
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
mNotificationManager.notify(1, notif);
}
}
}
代码示例来源:origin: stackoverflow.com
NotificationManager manger = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon,
"Notification text that will be shown on status bar.", System
.currentTimeMillis());
// The PendingIntent will launch activity if the user selects this
// notification
PendingIntent contentIntent = PendingIntent.getActivity(context,
REQUEST_CODE, new Intent(this, MyActivity.class), 0);
notification.setLatestEventInfo(this, "Content Title", "Content text",
contentIntent);
manger.notify(NOTIFICATION_ID, notification);
代码示例来源:origin: stackoverflow.com
private void displayNotification(String extra, String contentTitle, String contentText, Class<?> cls, int id) {
Notification notifyDetails = new Notification(R.drawable.icon, "New Alert!", System.currentTimeMillis());
Intent intent = new Intent(this, cls);
intent.putExtra("extra", extra);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), id, intent, PendingIntent.FLAG_ONE_SHOT);
notifyDetails.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
mNotificationManager.notify(id, notifyDetails);
}
代码示例来源:origin: stackoverflow.com
Notification notification = new Notification(R.drawable.direction, "Cool Notification",
System.currentTimeMillis());
/********LIKE THIS*********/
notification.number = notificationCount++;
/********LIKE THIS*********/
notification.setLatestEventInfo(context, "Cool Notification Title",
"updated notificaiton message", null);
NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
nm.notify(R.id.my_motification, notification);
代码示例来源:origin: stackoverflow.com
NotificationManager mManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this,test.class);
Notification notification = new Notification(R.drawable.icon, "Notify", System.currentTimeMillis());
notification.setLatestEventInfo(this,"App Name","Description of the notification",
PendingIntent.getActivity(this.getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
mManager.notify(0, notification);
代码示例来源:origin: stackoverflow.com
// Construct the notification and notificationManager objects
final NotificationManager notificationMgr = (NotificationManager) systemService;
final Notification notification = new Notification(R.drawable.ic_launcher, tickerText,
System.currentTimeMillis());
final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.vibrate = new long[] { 0, 100, 200, 300 };
notification.setLatestEventInfo(context, notificationTitle, notificationSubText, contentIntent);
内容来源于网络,如有侵权,请联系作者删除!