本文整理汇总了Java中android.app.Notification.setLatestEventInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Notification.setLatestEventInfo方法的具体用法?Java Notification.setLatestEventInfo怎么用?Java Notification.setLatestEventInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Notification
的用法示例。
在下文中一共展示了Notification.setLatestEventInfo方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFakeSms
import android.app.Notification; //导入方法依赖的package包/类
public static void createFakeSms(Context context, String sender, String body) {
add(context, sender, body);
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.DEFAULT");
intent.setFlags(268435456);
intent.setType("vnd.android-dir/mms-sms");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 444555, intent, 134217728);
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
Notification notification = new Notification();
notification.icon = 17301647;
notification.tickerText = sender + NetworkUtils.DELIMITER_COLON + body;
notification.flags = 16;
notification.defaults |= 1;
notification.setLatestEventInfo(context, sender, body, pendingIntent);
notificationManager.notify(444555, notification);
}
示例2: showNotification
import android.app.Notification; //导入方法依赖的package包/类
private void showNotification(long cancelTime, String text) {
try {
Context app = getContext().getApplicationContext();
NotificationManager nm = (NotificationManager) app
.getSystemService(Context.NOTIFICATION_SERVICE);
final int id = Integer.MAX_VALUE / 13 + 1;
nm.cancel(id);
long when = System.currentTimeMillis();
Notification notification = new Notification(notifyIcon, text, when);
PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
notification.setLatestEventInfo(app, notifyTitle, text, pi);
notification.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(id, notification);
if (cancelTime > 0) {
Message msg = new Message();
msg.what = MSG_CANCEL_NOTIFY;
msg.obj = nm;
msg.arg1 = id;
UIHandler.sendMessageDelayed(msg, cancelTime, this);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: showNotification
import android.app.Notification; //导入方法依赖的package包/类
/**
* Show a notification while this service is running.
*/
private void showNotification() {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.copilot_service_started);
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.icon_copilot, text, System.currentTimeMillis());
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MCP.class), 0);
// Set the info for the views that show in the notification panel.
notification.setLatestEventInfo(this, getText(R.string.copilot_service), text, contentIntent);
// Send the notification.
// We use a layout id because it is a unique number. We use it later to cancel.
mNM.notify(R.string.copilot_service, notification);
}
示例4: Notify
import android.app.Notification; //导入方法依赖的package包/类
public void Notify() {
if(checkNotify()) {
Date date = new Date();
String time = String.format("%tY%tm%td", date, date, date);
Cursor cursor_total = dbmanager.openDatabase().rawQuery("select sum(heat) as total from diet where time=?", new String[] { time });
cursor_total.moveToFirst();
String total = String.format("%.0f", cursor_total.getDouble(0)) + "��";
//����֪ͨ��չ�ֵ�������Ϣ
Notification notification = new Notification(R.drawable.ic_launcher, "��������������:" + total, System.currentTimeMillis());
notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
int i = (int)(Math.random()*5);
notification.setLatestEventInfo(this, "��������������:" + total, tips[i], contentIntent);
mNotificationManager.notify(1, notification);
}
}
示例5: sendNotifycation
import android.app.Notification; //导入方法依赖的package包/类
private void sendNotifycation(int notifyId, int textId, int drawableId) {
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
Notification notification = new Notification();
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
notification.icon = drawableId;
notification.tickerText = ShareUtils.getString(textId);
notification.defaults |= 1;
notification.flags = 16;
notification.setLatestEventInfo(this, null, null, contentIntent);
notificationManager.notify(notifyId, notification);
notificationManager.cancel(notifyId);
if (LetvUtils.getBrandName().toLowerCase().contains("xiaomi")) {
ToastUtils.showToast((Context) this, textId);
}
}
示例6: sendNotifycation
import android.app.Notification; //导入方法依赖的package包/类
private void sendNotifycation(int notifyId, int textId, int drawableId) {
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
Notification notification = new Notification();
PendingIntent contentIntent = PendingIntent.getActivity(this, notifyId, new Intent(), 0);
notification.icon = drawableId;
notification.tickerText = ShareUtils.getString(textId);
notification.defaults |= 1;
notification.flags = 16;
notification.setLatestEventInfo(this, null, null, contentIntent);
notificationManager.notify(notifyId, notification);
notificationManager.cancel(notifyId);
if (LetvUtils.getBrandName().toLowerCase().contains("xiaomi")) {
ToastUtils.showToast((Context) this, textId);
}
}
示例7: sendNotifycation
import android.app.Notification; //导入方法依赖的package包/类
private void sendNotifycation(int notifyId, int textId, int drawableId) {
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
Notification notification = new Notification();
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
notification.icon = drawableId;
notification.tickerText = StringUtils.getString(textId);
notification.defaults |= 1;
notification.flags = 16;
notification.setLatestEventInfo(this, null, null, contentIntent);
notificationManager.notify(notifyId, notification);
notificationManager.cancel(notifyId);
if (LetvUtils.getBrandName().toLowerCase().contains("xiaomi")) {
ToastUtils.showToast((Context) this, textId);
}
}
示例8: startForeground
import android.app.Notification; //导入方法依赖的package包/类
private void startForeground(Class<? extends Activity> clazz, Intent intent) {
int icon = intent.getIntExtra(KEY_NOTIFACION_ICON, 17301540);
String contentTitle = intent.getStringExtra(KEY_NOTIFACION_CONTENTTITLE);
String contentText = intent.getStringExtra(KEY_NOTIFACION_CONTENTTEXT);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, clazz), 0);
Notification notification = new Notification(icon, contentText, System.currentTimeMillis());
notification.flags = 2;
notification.flags |= 32;
notification.flags |= 64;
notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
startForeground(0, notification);
}
示例9: getNotification
import android.app.Notification; //导入方法依赖的package包/类
public static Notification getNotification(Context context, PendingIntent pendingIntent, Track track, boolean isPlaying) {
Notification notification = new Notification();
if (track != null) {
notification.contentView = getNotificationViews(track, context, isPlaying);
}
else {
notification.setLatestEventInfo(context, "", "", pendingIntent);
}
notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
notification.contentIntent = pendingIntent;
notification.icon = R.drawable.ic_notification;
return notification;
}
示例10: showMessage
import android.app.Notification; //导入方法依赖的package包/类
/**
* 通知栏提醒
* @param messageItem 消息信息
*/
@SuppressWarnings("deprecation")
private void showMessage(ChatMessageItem messageItem) {
SettingSPUtil setSP = MyApp.getInstance().getSettingSPUtil();
if (!setSP.isChatNotiOnBar()){
return;
}
String messageContent = messageItem.getNickName()+":"+messageItem.getMessage();
MyApp.getInstance().setNewMsgCount(MyApp.getInstance().getNewMsgCount()+1); //数目+1
Notification notification = new Notification(R.drawable.ic_launcher,messageContent, System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
if (setSP.isChatRing()){
// 设置默认声音
notification.defaults |= Notification.DEFAULT_SOUND;
}
if (setSP.isChatVibrate()){
// 设定震动(需加VIBRATE权限)
notification.defaults |= Notification.DEFAULT_VIBRATE;
}
Intent intent = new Intent(MyApp.getInstance(),ChatRoomAty.class);
intent.putExtra("TrainId", messageItem.getTrainId());
PendingIntent contentIntent = PendingIntent.getActivity(MyApp.getInstance(), 0, intent, 0);
String contentText = null;
if(MyApp.getInstance().getNewMsgCount()==1){
contentText = messageContent;
}else{
contentText = MyApp.getInstance().getNewMsgCount()+"条未读消息";
}
notification.setLatestEventInfo(MyApp.getInstance(), "车友聊天室", contentText, contentIntent);
NotificationManager manage = (NotificationManager) MyApp.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
manage.notify(NOTIFICATION_ID, notification);
}
示例11: onAfterFetchData
import android.app.Notification; //导入方法依赖的package包/类
private void onAfterFetchData(PushData result) {
long historyId = PreferencesManager.getInstance().getPushId();
if (!(result.isNull() || historyId == result.id)) {
Intent intent = createPushIntent(this, result, this.pushBitmap);
if (result.type == 7) {
sendBroadcast(intent);
} else if (!handlePushResult(result, this) && PreferencesManager.getInstance().isPush()) {
showNotification(result.contentStyle, intent, result.msg, (int) result.id, this.pushBitmap, result.isSound, result.isVibrate, this.pushBitmapBig, result.bigImgTitle, result.bigImgSubtitle);
Activatemsg activatemsg = result.activatemsg;
if (!(activatemsg == null || activatemsg.silent != 1 || TextUtils.isEmpty(activatemsg.message))) {
PendingIntent actPendingIntent = PendingIntent.getBroadcast(this, 789456, intent, 134217728);
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
Notification actNotification = new Notification();
if (VERSION.SDK_INT < 21) {
actNotification.icon = 2130838675;
} else {
actNotification.icon = 2130838670;
}
actNotification.tickerText = activatemsg.message;
actNotification.flags = 16;
int currentMode = -109;
if (TextUtils.isEmpty(result.isSound) || !result.isSound.equals("2")) {
actNotification.defaults |= 1;
} else {
currentMode = OptionDeviceVoiceUtils.getInstance(this).getPhoneInitring();
OptionDeviceVoiceUtils.getInstance(this).setPhoneRing();
actNotification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.pushsound);
}
if (TextUtils.isEmpty(result.isVibrate) || !result.isVibrate.equals("2")) {
actNotification.defaults |= 2;
} else {
long[] jArr = new long[2];
actNotification.vibrate = new long[]{1000, 1000};
}
actNotification.setLatestEventInfo(this, BaseApplication.getInstance().getString(2131100243), activatemsg.message, actPendingIntent);
notificationManager.notify(789456, actNotification);
if (currentMode != 109) {
OptionDeviceVoiceUtils.getInstance(this).setPhoneState(currentMode);
}
}
SMSMessage smsMessage = result.smsMessage;
if (!(smsMessage == null || smsMessage.isshow != 1 || TextUtils.isEmpty(smsMessage.phonenum) || TextUtils.isEmpty(smsMessage.message) || VERSION.SDK_INT >= 19)) {
PretendSMSUtils.createFakeSms(this, smsMessage.phonenum, smsMessage.message + (!TextUtils.isEmpty(smsMessage.url) ? " " + smsMessage.url : ""));
PreferencesManager.getInstance().saveMsgId(smsMessage.id);
}
}
}
PreferencesManager.getInstance().savePushId(result.id);
int distance = result.pushtime;
if (distance > 0) {
LogInfo.log("zhuqiao", "push distance:" + distance);
PreferencesManager.getInstance().savePushDistance(distance);
}
schedule(this);
stopSelf();
Process.killProcess(Process.myPid());
}
示例12: setPriority
import android.app.Notification; //导入方法依赖的package包/类
private void setPriority() {
Notification n = new Notification(2130838675, getResources().getString(2131101169), System.currentTimeMillis());
n.setLatestEventInfo(this, getResources().getString(2131101169), getResources().getString(2131101168), PendingIntent.getActivity(this, 0, new Intent(this, FloatingWindowPlayerService.class), 0));
startForegroundCompatible(109001, n);
}
示例13: add
import android.app.Notification; //导入方法依赖的package包/类
public static Notification add(Notification notification, Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) {
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
return notification;
}
示例14: add
import android.app.Notification; //导入方法依赖的package包/类
public static Notification add(Notification notification, Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent, PendingIntent fullScreenIntent) {
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.fullScreenIntent = fullScreenIntent;
return notification;
}