项目:q-mail
文件:CertificateErrorNotifications.java
public void showCertificateErrorNotification(Account account,boolean incoming) {
int notificationId = NotificationIds.getCertificateErrorNotificationId(account,incoming);
Context context = controller.getContext();
PendingIntent editServerSettingsPendingIntent = createContentIntent(context,account,incoming);
String title = context.getString(R.string.notification_certificate_error_title,account.getDescription());
String text = context.getString(R.string.notification_certificate_error_text);
NotificationCompat.Builder builder = controller.createNotificationBuilder()
.setSmallIcon(getCertificateErrorNotificationIcon())
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setTicker(title)
.setContentTitle(title)
.setContentText(text)
.setContentIntent(editServerSettingsPendingIntent)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setCategory(NotificationCompat.CATEGORY_ERROR);
controller.configureNotification(builder,null,NOTIFICATION_LED_FAILURE_COLOR,NOTIFICATION_LED_BLINK_FAST,true);
getnotificationmanager().notify(notificationId,builder.build());
}
项目:XERUNG
文件:ContactSync.java
private void backupFound(){
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
if(jbBackupM.toString().trim().length()>0){
Intent dialogIntent = new Intent(this,AddToContactList.class);
dialogIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
dialogIntent.putExtra("data",jbBackupM.toString());
PendingIntent intent = PendingIntent.getActivity(this,dialogIntent,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(intent);
}
mBuilder.setSmallIcon(R.drawable.ic_custom_notification);
mBuilder.setAutoCancel(true);
mBuilder.setContentTitle("Contact Sync!!");
mBuilder.setContentText("You have lost some contact,we have backup");
notificationmanager mnotificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
// notificationID allows you to update the notification later on.
mnotificationmanager.notify(notificaitonId,mBuilder.build());
}
项目:CurrentActivity
文件:FloatViewService.java
private Notification notificationMethod() {
Notification notification;
PendingIntent pendingIntent = PendingIntent.getService(this,new Intent(this,FloatViewService.class).setAction(ACTION_FLOAT_VIEW_SHOW),0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,getClass().getSimpleName())
.setContentTitle("当前应用包名,点击查看详细")
.setContentText(currentActivity.getCurrentActivity())
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher);
Intent exitIntent = new Intent(this,FloatViewService.class).setAction(ACTION_FLOAT_VIEW_SERVICE_STOP);
builder.addAction(R.drawable.ic_action_exit,getString(R.string.notification_action_exit),PendingIntent.getService(this,exitIntent,0));
notification = builder.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
return notification;
}
项目:chromium-for-android-56-debug-video
文件:Incognitonotificationmanager.java
/**
* Shows the close all incognito notification.
*/
public static void showIncognitoNotification() {
Context context = ContextUtils.getApplicationContext();
String actionMessage =
context.getResources().getString(R.string.close_all_incognito_notification);
String title = context.getResources().getString(R.string.app_name);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentIntent(
IncognitoNotificationService.getRemoveAllIncognitoTabsIntent(context))
.setContentText(actionMessage)
.setongoing(true)
.setVisibility(Notification.VISIBILITY_SECRET)
.setSmallIcon(R.drawable.incognito_statusbar)
.setShowWhen(false)
.setLocalOnly(true);
notificationmanager nm =
(notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(INCOGNITO_TABS_OPEN_TAG,INCOGNITO_TABS_OPEN_ID,builder.build());
}
项目:2017.1-Trezentos
文件:ExamActivity.java
private void sendEvaluationNotification(){
NotificationCompat.Builder mBuilder =
(NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.trezentos_icon)
.setContentTitle("Avaliação")
.setContentText("Você tem avaliações à serem feitas!")
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.trezentos_icon));
Intent resultIntent = new Intent(this,MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
notificationmanager mnotificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
mnotificationmanager.notify(0,mBuilder.build());
}
项目:Android-Wear-Projects
文件:WearStepService.java
private void updateNotification() {
// Create a notification builder that's compatible with platforms >= version 4
NotificationCompat.Builder builder =
new NotificationCompat.Builder(getApplicationContext());
// Set the title,text,and icon
builder.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_step_icon);
builder.setContentText("steps: " + StepsTaken.getSteps());
// Get an instance of the Notification Manager
notificationmanager notifyManager = (notificationmanager)
getSystemService(Context.NOTIFICATION_SERVICE);
// Build the notification and post it
notifyManager.notify(0,builder.build());
}
项目:1617PROJ1Bloeddonatie-app
文件:MyFirebaseMessagingService.java
/**
* display the notification
* @param body
*/
public void sendNotification(String body) {
Intent intent = new Intent(this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0/*Request code*/,intent,PendingIntent.FLAG_ONE_SHOT);
//Set sound of notification
Uri notificationSound = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_bloeddonatie_logo_notification)
.setContentTitle("Bloeddonatie")
.setContentText(body)
.setAutoCancel(true)
.setSound(notificationSound)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager = (notificationmanager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0 /*ID of notification*/,notifiBuilder.build());
}
/**
* Create and show a simple notification containing the received FCM message.
*
* @param messageBody FCM message body received.
*/
private void sendNotification(String messageBody) {
Intent intent = new Intent(this,quakeActivity.class);//**The activity that you want to open when the notification is clicked
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0 /* Request code */,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_error_outline_white_24dp)
.setContentTitle("FCM Message")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0 /* ID of notification */,notificationBuilder.build());
}
项目:Automata
文件:FCM.java
private void sendNotification(String messageBody) {
Intent intent = new Intent(this,Main.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Automata")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0 /* ID of notification */,notificationBuilder.build());
}
项目:MovingGdufe-Android
文件:DrcomService.java
private void showNotification() {
notificationmanager mNotifyMgr =
(notificationmanager) getSystemService(NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(
this,1,DrcomActivity.class),0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Dr.com正常运行中")
.setContentText("能看到我就说明有网络")
.setTicker("Dr.com运行中")
.setWhen(System.currentTimeMillis())
.setongoing(false) //用户无法滑动删除通知栏
.setContentIntent(contentIntent);
Notification notification = mBuilder.build();
startForeground(FOREGROUND_ID,notification); //前台,防止被系统kill
mNotifyMgr.notify(FOREGROUND_ID,notification);
}
项目:three-things-today
文件:NotificationIntentService.java
@Override
protected void onHandleIntent(Intent intent) {
// Todo(smcgruer): Skip if today is already done.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("Three Things Today")
.setContentText("Record what happened today!")
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setSmallIcon(R.drawable.ic_stat_name);
Intent notifyIntent = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
this,notifyIntent,PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
Notification notificationCompat = builder.build();
notificationmanagerCompat managerCompat = notificationmanagerCompat.from(this);
managerCompat.notify(NOTIFICATION_ID,notificationCompat);
}
项目:XERUNG
文件:MyFirebaseMessagingService.java
private void sendMultilineNotification(String title,String messageBody) {
//Log.e("DADA","ADAD---"+title+"---message---"+messageBody);
int notificationId = 0;
Intent intent = new Intent(this,MainDashboard.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,notificationId,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_custom_notification)
.setLargeIcon(largeIcon)
.setContentTitle(title/*"Firebase Push Notification"*/)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(messageBody))
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(notificationId,notificationBuilder.build());
}
项目:BizareChat
文件:NotificationUtils.java
public void showNotificationMessage(String title,String message,String timeStamp,Intent intent) {
if (TextUtils.isEmpty(message)) {
return;
}
if (!CurrentUser.getInstance().isNotificationsOn()) {
return;
}
int icon = R.mipmap.ic_launcher;
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
context,PendingIntent.FLAG_CANCEL_CURRENT
);
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
showSmallNotification(notifBuilder,icon,title,message,timeStamp,resultPendingIntent);
}
项目:PeSanKita-android
文件:CallNotificationBuilder.java
private static NotificationCompat.Action getServiceNotificationAction(Context context,String action,int iconResId,int titleResId) {
Intent intent = new Intent(context,WebRtcCallService.class);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getService(context,0);
return new NotificationCompat.Action(iconResId,context.getString(titleResId),pendingIntent);
}
项目:Goalie_Android
文件:MessagingService.java
private void showNotification(String title,String description,Intent intent) {
String channelID = getNotificationChannelID();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap largeNotificationImage = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,channelID)
.setContentIntent(pendingIntent)
.setContentTitle(title)
.setContentText(description)
.setDefaults(Notification.DEFAULT_ALL)
.setLargeIcon(largeNotificationImage)
.setSmallIcon(R.drawable.ic_logo);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
builder.setColor(ContextCompat.getColor(this,R.color.colorPrimary));
Notification notification = builder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Get the notification manager & publish the notification
notificationmanager notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(Constants.ID_NOTIFICATION_broADCAST,notification);
}
项目:FLFloatingButton
文件:CustomFloatingViewService.java
/**
* 通知を表示します。
*/
private Notification createNotification() {
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setWhen(System.currentTimeMillis());
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle(getString(R.string.mail_content_title));
builder.setContentText(getString(R.string.content_text));
builder.setongoing(true);
builder.setPriority(NotificationCompat.PRIORITY_MIN);
builder.setCategory(NotificationCompat.CATEGORY_SERVICE);
// PendingIntent作成
final Intent notifyIntent = new Intent(this,DeleteActionActivity.class);
PendingIntent notifyPendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(notifyPendingIntent);
return builder.build();
}
项目:Clases-2017c1
文件:MyFirebaseMessagingService.java
private void sendNotification(String messageBody) {
Intent intent = new Intent(this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
int requestCode = 0;
PendingIntent pendingIntent = PendingIntent.getActivity(this,requestCode,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_action_name)
.setContentTitle("FCM Message")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager =
(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
int notificationId = 0;
notificationmanager.notify(notificationId,notificationBuilder.build());
}
项目:oma-riista-android
文件:RiistaFirebaseMessagingService.java
private void sendNotification(String title,String messageBody) {
Intent intent = new Intent(this,LoginActivity.class);
intent.putExtra(LoginActivity.SHOW_ANNOUNCEMENTS_EXTRA,true);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setContentIntent(pendingIntent);
notificationmanager notificationmanager = (notificationmanager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0,notificationBuilder.build());
}
项目:MKAPP
文件:ServiceSinkhole.java
private void showAutoStartNotification() {
Intent main = new Intent(this,ActivityMain.class);
main.putExtra(ActivityMain.EXTRA_APPROVE,true);
PendingIntent pi = PendingIntent.getActivity(this,NOTIFY_AUTOSTART,main,PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOff,tv,true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_error_white_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.msg_autostart))
.setContentIntent(pi)
.setColor(tv.data)
.setongoing(false)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_autostart));
notificationmanagerCompat.from(this).notify(NOTIFY_AUTOSTART,notification.build());
}
项目:Beach-Android
文件:NotificationUtils.java
private void showBigNotification(Bitmap bitmap,NotificationCompat.Builder mBuilder,int icon,String title,PendingIntent resultPendingIntent,Uri alarmSound) {
NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
bigPictureStyle.setBigContentTitle(title);
bigPictureStyle.setSummaryText(Html.fromHtml(message).toString());
bigPictureStyle.bigPicture(bitmap);
Notification notification;
notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(alarmSound)
.setStyle(bigPictureStyle)
.setWhen(DateUtils.currentTimeInMiles())
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(),icon))
.setContentText(message)
.build();
notificationmanager notificationmanager = (notificationmanager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(ApplicationProps.NOTIFICATION_ID_BIG_IMAGE,notification);
}
项目:Botanist
文件:FertilizerReceiver.java
/**
* Receiver received an update
* @param context - current app context
* @param intent - intent that updated height
*/
@Override
public void onReceive(Context context,Intent intent) {
String name = intent.getExtras().getString("name");
String plantId = intent.getExtras().getString("plant_id");
int notificationId = intent.getExtras().getInt("id");
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_botanist_big);
Intent resultIntent = new Intent(context,LoginActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context,resultIntent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context,"default").setSmallIcon(R.drawable.ic_poop_notification)
.setLargeIcon(largeIcon)
.setDefaults(Notification.DEFAULT_SOUND).setContentTitle(name + " May Need Fertilizer")
.setContentText("Keep track of " + name + " fertilization record")
.setAutoCancel(true).setContentIntent(resultPendingIntent);
notificationmanager mNotifyMgr = (notificationmanager) context.getSystemService(NOTIFICATION_SERVICE);
if (mNotifyMgr != null) {
mNotifyMgr.notify(notificationId,mBuilder.build());
}
DatabaseManager.getInstance().updateNotificationTime(plantId,"lastFertilizerNotification");
}
项目:GitHub
文件:NotificationMinSetActivity.java
private NotificationItem(int id,String desc) {
super(id,desc);
Intent[] intents = new Intent[2];
intents[0] = Intent.makeMainActivity(new ComponentName(DemoApplication.CONTEXT,MainActivity.class));
intents[1] = new Intent(DemoApplication.CONTEXT,NotificationSampleActivity.class);
this.pendingIntent = PendingIntent.getActivities(DemoApplication.CONTEXT,intents,PendingIntent.FLAG_UPDATE_CURRENT);
builder = new NotificationCompat.
Builder(FileDownloadHelper.getAppContext());
builder.setDefaults(Notification.DEFAULT_LIGHTS)
.setongoing(true)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setContentTitle(getTitle())
.setContentText(desc)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher);
}
项目:AndroidProgramming3e
文件:MockWalkerService.java
@Override
public void onCreate() {
super.onCreate();
Intent shutdownIntent = new Intent(this,ShutdownReceiver.class);
PendingIntent shutdownPI = PendingIntent.getbroadcast(
this,PENDING_SHUTDOWN_ID,shutdownIntent,0
);
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(android.R.drawable.ic_dialog_map)
.setContentTitle(getString(R.string.notification_title))
.setContentText(getString(R.string.notification_text))
.setTicker(getString(R.string.app_name))
.setContentIntent(shutdownPI)
.build();
startForeground(NOTIFICATION_ID,notification);
MockWalker.get(this).setStarted(true);
}
项目:GitHub
文件:PicassoSampleAdapter.java
@Override public void launch(Activity activity) {
RemoteViews remoteViews =
new RemoteViews(activity.getPackageName(),R.layout.notification_view);
Intent intent = new Intent(activity,SampleGridViewActivity.class);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(activity).setSmallIcon(R.drawable.icon)
.setContentIntent(PendingIntent.getActivity(activity,-1,0))
.setContent(remoteViews);
Notification notification = builder.getNotification();
notificationmanager notificationmanager =
(notificationmanager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(NOTIFICATION_ID,notification);
// Now load an image for this notification.
Picasso.with() //
.load(Data.URLS[new Random().nextInt(Data.URLS.length)]) //
.resizeDimen(R.dimen.notification_icon_width_height,R.dimen.notification_icon_width_height) //
.into(remoteViews,R.id.photo,NOTIFICATION_ID,notification);
}
项目:PlusGram
文件:ShowNotification.java
public void show() {
String msg = "";
try {
msg = URLDecoder.decode(this.message,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printstacktrace();
msg = this.message;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
builder.setSmallIcon(R.drawable.ic_telegram_logo);
builder.setLargeIcon(BitmapFactory.decodeResource(ApplicationLoader.applicationContext.getResources(),R.drawable.ic_telegram_logo));
builder.setContentTitle(this.title);
builder.setContentText(msg);
notificationmanager notificationmanager = (notificationmanager) ApplicationLoader.applicationContext.getSystemService(NOTIFICATION_SERVICE);
notificationmanager.notify(NOTIFICATION_ID,builder.build());
User.PlayDing(ApplicationLoader.applicationContext);
}
项目:mobile-store
文件:UpdateService.java
@Override
public void onCreate() {
super.onCreate();
notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_refresh_white)
.setongoing(true)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setContentTitle(getString(R.string.update_notification_title));
appUpdateStatusManager = AppUpdateStatusManager.getInstance(this);
// Android docs are a little sketchy,however it seems that Gingerbread is the last
// sdk that made a content intent mandatory:
//
// http://stackoverflow.com/a/20032920
//
if (Build.VERSION.SDK_INT <= 10) {
Intent pendingIntent = new Intent(this,MainActivity.class);
pendingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationBuilder.setContentIntent(PendingIntent.getActivity(this,pendingIntent,PendingIntent.FLAG_UPDATE_CURRENT));
}
}
项目:OpenYOLO-Android
文件:CredentialStorageService.java
private void becomeForeground() {
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.unlocked_notification_icon)
.setContentTitle(getString(R.string.unlocked_notification_title))
.setContentText(getString(R.string.unlocked_notification_text))
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setContentIntent(PendingIntent.getActivity(
this,CredentialListActivity.class),0))
.addAction(
R.drawable.lock_notification_icon,getString(R.string.unlocked_notification_lock_action),PendingIntent.getActivity(
this,LockActivity.class),0
))
.setLocalOnly(true)
.setAutoCancel(false)
.setongoing(true)
.setonlyAlertOnce(true)
.build();
startForeground(UNLOCKED_NOTIFICATION_ID,notification);
}
private void screenAlertMessage(Context context,String msg) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Relax your eyes a little bit.")
.setPriority(Notification.PRIORITY_HIGH)
.setVibrate(new long[0])
.setAutoCancel(true)
.setContentText(msg);
int mNotificationId = 001;
notificationmanager mNotifyMgr =
(notificationmanager) context.getSystemService(context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId,mBuilder.build());
}
项目:android-mobile-engage-sdk
文件:MessagingServiceUtilsTest.java
@Test
@SdkSuppress(minSdkVersion = LOLLIPOP)
public void createNotification_withBigTextStyle_withTitleAndBody() {
Map<String,String> input = new HashMap<>();
input.put("title",TITLE);
input.put("body",BODY);
android.app.Notification result = MessagingServiceUtils.createNotification(context,input,disabledOreoConfig);
assertEquals(TITLE,result.extras.getString(NotificationCompat.EXTRA_TITLE));
assertEquals(TITLE,result.extras.getString(NotificationCompat.EXTRA_TITLE_BIG));
assertEquals(BODY,result.extras.getString(NotificationCompat.EXTRA_TEXT));
assertEquals(BODY,result.extras.getString(NotificationCompat.EXTRA_BIG_TEXT));
assertNull(result.extras.getString(NotificationCompat.EXTRA_SUMMARY_TEXT));
}
项目:AppsTimeline
文件:MessageService.java
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map<String,String> data = remoteMessage.getData();
if (data.size() > 0) {
Intent resultIntent = new Intent(this,MainActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(
this,PendingIntent.FLAG_UPDATE_CURRENT
);
// 这个是应用在前台的时候出现的通知,应用在后台不会调用,这个并不能把应用拉起来的
Uri notificationSound = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
Notification n = new NotificationCompat.Builder(this,"channel.fcm")
.setContentIntent(resultPendingIntent)
.setContentTitle(data.get("title"))
.setContentText(data.get("content"))
.setSound(notificationSound)
.setSmallIcon(R.drawable.ic_launcher)
.build();
notificationmanager notificationmanager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE);
if (notificationmanager != null) notificationmanager.notify(1,n);
}
}
项目:Show_Chat
文件:FriendChatService.java
public void createNotify(String name,String content,int id,Bitmap icon,boolean isGroup) {
Intent activityIntent = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,activityIntent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setLargeIcon(icon)
.setContentTitle(name)
.setContentText(content)
.setContentIntent(pendingIntent)
.setVibrate(new long[] { 1000,1000})
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setAutoCancel(true);
if (isGroup) {
notificationBuilder.setSmallIcon(R.drawable.ic_tab_group);
} else {
notificationBuilder.setSmallIcon(R.drawable.ic_tab_person);
}
notificationmanager notificationmanager =
(notificationmanager) this.getSystemService(
Context.NOTIFICATION_SERVICE);
notificationmanager.cancel(id);
notificationmanager.notify(id,notificationBuilder.build());
}
static protected void showNotificationWithUrl(Context context,String notificationText,String url) {
// Todo Auto-generated method stub
NotificationCompat.Builder build = new NotificationCompat.Builder(
context);
build.setSmallIcon(OnesheeldApplication.getNotificationIcon());
build.setContentTitle(title);
build.setContentText(notificationText);
build.setTicker(notificationText);
build.setWhen(System.currentTimeMillis());
Intent notificationIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent intent = PendingIntent.getActivity(context,notificationIntent,0);
build.setContentIntent(intent);
Notification notification = build.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_ALL;
notificationmanager notificationmanager = (notificationmanager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(2,notification);
}
项目:immersify
文件:ToggleNotification.java
public static void show(Context context) {
// Build toggle action
Intent notificationServiceIntent = new Intent(context,NotificationService.class);
notificationServiceIntent.setAction(ACTION_TOGGLE);
PendingIntent notificationPendingIntent = PendingIntent.getService(context,notificationServiceIntent,0);
NotificationCompat.Action toggleAction = new NotificationCompat.Action(
R.drawable.ic_border_clear_black_24dp,"Toggle",notificationPendingIntent
);
// Build notification
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_zoom_out_map_black_24dp)
.setContentTitle("Immersify")
.setContentText("Tap to toggle immersive mode")
.setContentIntent(notificationPendingIntent)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.addAction(toggleAction)
.setongoing(true);
// Clear existing notifications
ToggleNotification.cancel(context);
// Notify the notification manager to create the notification
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0,builder.build());
}
项目:Android-ProgressNotification
文件:ApplyPremiumAccountService.java
private void showServiceFailedNotification(String userId) {
Intent intent = new Intent(this,ApplyAccountActivity.class);
intent.putExtra(EXTRA_USER_ID,userId);
intent.setFlags(Intent.FLAG_ACTIVITY_broUGHT_TO_FRONT);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(getApplicationContext(),GROUP_ID)
.setSmallIcon(R.drawable.ic_request_Failed_small)
.setContentTitle(getString(R.string.notification_your_request_has_been_denied))
.setContentText(getString(R.string.notification_click_here_to_try_again_in_the_app))
.setTicker(getString(R.string.notification_request_Failed))
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
.build();
notificationmanagerCompat.from(this).notify(NOTIFICATION_ID_RESULT,notification);
}
项目:DailyStudy
文件:NotificationActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
Intent intent = new Intent(this,SpannableStringActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0);
notificationmanager manager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("this is content title") // 标题
.setContentText("this is content text") // 正文内容
.setWhen(System.currentTimeMillis()) // 创建的时间
.setSmallIcon(R.mipmap.ic_launcher) // 通知的小图标,显示在系统状态栏
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher)) // 通知大图标
.setContentIntent(pendingIntent)
.setTicker("this is content text") // 显示在系统状内容
.setAutoCancel(true)
.setSound(Uri.fromFile(new File("/system/media/audio/ringtones/Luna.ogg")))// 指定通知声音
.setVibrate(new long[] {0,1000,1000}) // 设置震动 ,权限VINRATE
.setLights(Color.GREEN,1000) // 设置led灯闪烁
// .setDefaults(NotificationCompat.DEFAULT_ALL) // 设置系统默认属性
.build();
manager.notify(1,notification);
}
项目:Beach-Android
文件:NotificationUtils.java
private static void buildNotification(String message,PendingIntent contentIntent,String name,Context mContext) {
notificationmanager mnotificationmanager = (notificationmanager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
Uri alarmSound = ringtoneManager
.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(name)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentText(message)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSound(alarmSound).setonlyAlertOnce(true).setTicker(message)
.setWhen(System.currentTimeMillis()).setAutoCancel(true);
mBuilder.setContentIntent(contentIntent);
mnotificationmanager.notify(ApplicationProps.NOTIFICATION_ID,mBuilder.build());
}
项目:Android-music-player
文件:musicPlayer.java
public void statusBar(){
Intent intent = new Intent(this,Ui.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
android.app.PendingIntent pi = android.app.PendingIntent.getActivity(this,android.app.PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setTicker("Doodle handler starting.. \n Spidre Inc.");
builder.setContentText("Open musicPlayer");
builder.setContentIntent(pi);
builder.setongoing(true);
notification = builder.build();
// optionally set a custom view
startForeground(1,notification);
}
项目:decoy
文件:AVChatNotification.java
private Notification makeNotification(PendingIntent pendingIntent,String tickerText,int iconId,boolean ring,boolean vibrate) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(title)
.setContentText(content)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setTicker(tickerText)
.setSmallIcon(iconId);
int defaults = Notification.DEFAULT_LIGHTS;
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (ring) {
defaults |= Notification.DEFAULT_SOUND;
}
builder.setDefaults(defaults);
return builder.build();
}
项目:Pole-Beacon-Android-SDK
文件:PoleNotificationService.java
public static void createNotification(String title,String item_id,String item_type,Context mContext) {
try {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
Integer notificationId = Integer.valueOf(String.valueOf((System.currentTimeMillis() % 4234)));
Intent resultIntent = new Intent(mContext,FeedbackSDKActivity.class);
resultIntent.putExtra("item_id",item_id);
resultIntent.putExtra("item_type",item_type);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext,0);
Bitmap icon = BitmapFactory.decodeResource(mContext.getResources(),R.drawable.brandlog);
mBuilder.setSmallIcon(R.drawable.small_icon)
.setLargeIcon(icon)
.setContentTitle(title)
.setContentText(content)
.setonlyAlertOnce(true);
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle()
.setBigContentTitle(title)
.bigText(content);
mBuilder.setStyle(bigTextStyle);
SharedPreferences pref = mContext.getSharedPreferences("polePref",Context.MODE_PRIVATE);
int totalNotificationCount = pref.getInt("totalNotificationCount",0);
SharedPreferences.Editor editor = pref.edit();
editor.putInt("totalNotificationCount",totalNotificationCount+1);
editor.apply();
mBuilder.setContentIntent(pendingIntent);
notificationmanager mnotificationmanager = (notificationmanager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder.setVibrate(new long[]{100});
mBuilder.setAutoCancel(true);
mnotificationmanager.notify(notificationId,mBuilder.build());
} catch (Exception e){
Log.e("NOtification Error","Dsdsf");
}
}
项目:q-mail
文件:SyncNotifications.java
public void showFetchingMailNotification(Account account,Folder folder) {
String accountName = account.getDescription();
String folderName = folder.getId();
Context context = controller.getContext();
String tickerText = context.getString(R.string.notification_bg_sync_ticker,accountName,folderName);
String title = context.getString(R.string.notification_bg_sync_title);
//Todo: Use format string from resources
String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName;
int notificationId = NotificationIds.getFetchingMailNotificationId(account);
PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(
account,folderName,notificationId);
NotificationCompat.Builder builder = controller.createNotificationBuilder()
.setSmallIcon(R.drawable.ic_notify_check_mail)
.setWhen(System.currentTimeMillis())
.setongoing(true)
.setTicker(tickerText)
.setContentTitle(title)
.setContentText(text)
.setContentIntent(showMessageListPendingIntent)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setCategory(NotificationCompat.CATEGORY_SERVICE);
if (NOTIFICATION_LED_WHILE_SYNCING) {
controller.configureNotification(builder,account.getNotificationSetting().getLedColor(),true);
}
getnotificationmanager().notify(notificationId,builder.build());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。