项目:PeSanKita-android
文件:ExpirationListener.java
public static void setAlarm(Context context,long waitTimeMillis) {
Intent intent = new Intent(context,ExpirationListener.class);
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,intent,0);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + waitTimeMillis,pendingIntent);
}
项目:Clipcon-AndroidClient
文件:NotificationService.java
@Override
public void handleMessage(android.os.Message msg) {
notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
intent = new Intent(getApplicationContext(),GroupActivity.class);
intent.putExtra("History","test");
intent.setAction("Now");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
LocalbroadcastManager.getInstance(getApplicationContext()).sendbroadcast(intent);
pendingIntent = PendingIntent.getActivity(getApplicationContext(),PendingIntent.FLAG_CANCEL_CURRENT);
builder = new Notification.Builder(getApplicationContext());
builder.setSmallIcon(R.drawable.icon_logo);
builder.setTicker("new Clipcon"); //** 이 부분은 확인 필요
builder.setWhen(System.currentTimeMillis());
builder.setContentTitle("Clipcon Alert"); //** 큰 텍스트로 표시
builder.setContentText("History data is updated"); //** 작은 텍스트로 표시
builder.setAutoCancel(true);
builder.setPriority(Notification.PRIORITY_MAX); //** MAX 나 HIGH로 줘야 가능함
builder.setDefaults(Notification.DEFAULT_SOUND | Notification.FLAG_ONLY_ALERT_ONCE);
builder.setContentIntent(pendingIntent);
notificationmanager.notify(id,builder.build());
}
项目:phonk
文件:SchedulerManager.java
public void addAlarm(Date date,int id,String data,int interval,boolean repeating,boolean wakeUpScreen) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
SimpleDateFormat format = new SimpleDateFormat("EEEE,MMMM d,yyyy 'at' h:mm a");
// intent
Intent intent = new Intent(c,AlarmReceiver.class);
intent.putExtra(ALARM_INTENT,data);
intent.putExtra(Project.SETTINGS_SCREEN_WAKEUP,wakeUpScreen);
intent.putExtra(Project.NAME,mProject.getName());
intent.putExtra(Project.FOLDER,mProject.getFolder());
PendingIntent sender = PendingIntent.getbroadcast(c,id,PendingIntent.FLAG_UPDATE_CURRENT);
// Set Alarm
if (repeating) mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),interval,sender);
else mAlarmManager.set(AlarmManager.RTC_WAKEUP,sender);
// add to a global alarm thingie
addTask(new Task(id,mProject,Task.TYPE_ALARM,cal,repeating,wakeUpScreen));
}
项目: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);
}
项目:MuslimMateAndroid
文件:Alarms.java
/**
* Function to set alarm notification every day
*
* @param context Application context
* @param hour Hour of alarm
* @param min Min of alarm
* @param id ID of alarm
*/
public static void setAlarmForAzkar(Context context,int hour,int min,String type) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY,hour);
calendar.set(Calendar.MINUTE,min);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Bundle details = new Bundle();
details.putString("Azkar",type);
Intent alarmReceiver = new Intent(context,Azkaralarm.class);
alarmReceiver.putExtras(details);
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,alarmReceiver,PendingIntent.FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// kitkat...
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pendingIntent);
} else {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,1000 * 60 * 60 * 24,pendingIntent);
}
}
项目: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());
}
项目:remotedroid
文件:SMSUtils.java
public void sendSMS(String address,String content) {
lastSentSMsstatus = -1;
SmsManager smsManager = SmsManager.getDefault();
PendingIntent sentPI = PendingIntent.getbroadcast(mContext,new Intent("SMS_SENT"),0);
mContext.registerReceiver(new broadcastReceiver() {
@Override
public void onReceive(Context context,Intent intent) {
lastSentSMsstatus = getResultCode();
Toast.makeText(mContext,"message sent",Toast.LENGTH_LONG).show();
}
},new IntentFilter("SMS_SENT"));
smsManager.sendTextMessage("tel:".concat(address),null,content,sentPI,null);
}
项目:zabbkit-android
文件:NotificationUpdateService.java
private void sendNotification(String title,String content) {
// this intent will open the activity when the user taps the "open" action on the notification
Intent viewIntent = new Intent(this,MainActivity.class);
PendingIntent pendingViewIntent = PendingIntent.getActivity(this,viewIntent,0);
// this intent will be sent when the user swipes the notification to dismiss it
Intent dismissIntent = new Intent(ZabbkitConstants.NOTIFICATION_disMISS);
PendingIntent pendingDeleteIntent = PendingIntent.getService(this,dismissIntent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setContentText(content)
.setGroup(GROUP_KEY)
.setDeleteIntent(pendingDeleteIntent)
.setContentIntent(pendingViewIntent);
Notification notification = builder.build();
notificationmanagerCompat notificationmanagerCompat = notificationmanagerCompat.from(this);
notificationmanagerCompat.notify(notificationId++,notification);
}
项目: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());
}
项目:AutoScrollr
文件:CustomTabs.java
/**
* Method used to set the Action Button
* @param icon The icon you've to show
* @param description The description of the action
* @param pendingIntent The pending intent it executes
* @param tint True if you want to tint the icon,false if not.
*/
public Style setActionButton(@DrawableRes int icon,String description,PendingIntent
pendingIntent,boolean tint) {
this.actionButton = new ActionButton
(BitmapFactory.decodeResource(context.getResources(),icon),description,pendingIntent,tint);
return this;
}
项目:AutoVolume
文件:MainActivity.java
private void notification() {
notification = new NotificationCompat.Builder(this);
notification.setSmallIcon(R.drawable.sound);
notification.setLargeIcon(BitmapFactory.decodeResource(this.getResources(),R.drawable.sound));
notification.setTicker("Auto Volume");
notification.setongoing(true);
notification.setContentTitle("Go to Auto Volume");
notification.setWhen(System.currentTimeMillis());
Intent intent = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
notification.setContentIntent(pendingIntent);
notificationmanager nm = (notificationmanager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(uniqueID,notification.build());
}
项目:container
文件:GetIntentSender.java
@Override
public Object call(Object who,Method method,Object... args) throws Throwable {
String creator = (String) args[1];
args[1] = getHostPkg();
String[] resolvedTypes = (String[]) args[6];
int type = (int) args[0];
if (args[5] instanceof Intent[]) {
Intent[] intents = (Intent[]) args[5];
if (intents.length > 0) {
Intent intent = intents[intents.length - 1];
if (resolvedTypes != null && resolvedTypes.length > 0) {
intent.setDataAndType(intent.getData(),resolvedTypes[resolvedTypes.length - 1]);
}
Intent proxyIntent = redirectIntentSender(type,creator,intent);
if (proxyIntent != null) {
intents[intents.length - 1] = proxyIntent;
}
}
}
if (args.length > 7 && args[7] instanceof Integer) {
args[7] = PendingIntent.FLAG_UPDATE_CURRENT;
}
IInterface sender = (IInterface) method.invoke(who,args);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && sender != null && creator != null) {
VActivityManager.get().addPendingIntent(sender.asBinder(),creator);
}
return sender;
}
项目:ulogger-android
文件:LoggerService.java
/**
* Show notification
*
* @param mId Notification Id
*/
private void showNotification(int mId) {
if (Logger.DEBUG) { Log.d(TAG,"[showNotification " + mId + "]"); }
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_notify_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(String.format(getString(R.string.is_running),getString(R.string.app_name)));
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);
mnotificationmanager.notify(mId,mBuilder.build());
}
项目:Android-Scrapper
文件:DashPagerPresenterImpl.java
@Override
public void onChildAdded(final Game game) {
if (DatabaseContract.checkGameValidity(game,mMapper.getPosition())) {
if (mDashAdapter != null)
mDashAdapter.addGame(game);
// Start score scraper
if (new DateTime(game.getGameDateTime(),DateTimeZone.getDefault()).plusMinutes(game.getLeagueType().getAvgTime()).isBeforeNow() && // If Game has already started
game.getGameStatus() == GameStatus.NEUTRAL
&& !(game.getFirstTeam().getAcronym().equals(DefaultFactory.Team.ACRONYM) || game.getSecondTeam().getAcronym().equals(DefaultFactory.Team.ACRONYM)) // if teams are initialized
) {
Intent gameIntent = new Intent(mView.getActivity(),GameUpdateReceiver.class);
Log.i(TAG,"onChildAdded: Should Have completed game " + game.getId());
gameIntent.putExtra("game",game.getId());
PendingIntent pendingIntent = PendingIntent.getbroadcast(mView.getActivity(),(int) game.getId(),gameIntent,PendingIntent.FLAG_CANCEL_CURRENT);
long interval = game.getLeagueType().getRefreshInterval() * 60 * 1000L;
AlarmManager manager = (AlarmManager) mView.getActivity().getSystemService(Context.ALARM_SERVICE);
manager.setRepeating(AlarmManager.RTC_WAKEUP,new DateTime().getMillis(),pendingIntent);
}
}
}
项目:Minitask
文件:MyDateTimeUtils.java
public void ScheduleNotification(Notification notification,Context context,int notificationID,String dateTime) {
Intent notificationIntent = new Intent(context,NotificationPublisher.class);
notificationIntent.putExtra(NOTIFICATION_ID,notificationID);
notificationIntent.putExtra(NOTIFICATION,notification);
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
// parse string parameter to milliseconds for later alarm set
Date futureInMillis = null;
try {
futureInMillis = dateTimeFormatter.parse(dateTime);
} catch (ParseException e) {
e.printstacktrace();
}
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,futureInMillis.getTime(),pendingIntent);
}
项目:NovaMusicPlayer
文件:Novanotificationmanager.java
public Novanotificationmanager(MusicService service) throws remoteexception {
mService = service;
updateSessionToken();
mnotificationmanager = (notificationmanager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
createNotificationChannelForAndroidO();
String pkgName = mService.getPackageName();
mPlayIntent = PendingIntent.getbroadcast(mService,REQUEST_CODE,new Intent(ACTION_PLAY).setPackage(pkgName),PendingIntent.FLAG_CANCEL_CURRENT);
mPauseIntent = PendingIntent.getbroadcast(mService,new Intent(ACTION_PAUSE).setPackage(pkgName),PendingIntent.FLAG_CANCEL_CURRENT);
mPrevIntent = PendingIntent.getbroadcast(mService,new Intent(ACTION_PREV).setPackage(pkgName),PendingIntent.FLAG_CANCEL_CURRENT);
mNextIntent = PendingIntent.getbroadcast(mService,new Intent(ACTION_NEXT).setPackage(pkgName),PendingIntent.FLAG_CANCEL_CURRENT);
if (mnotificationmanager != null) {
mnotificationmanager.cancelAll();
}
}
项目:Brevent
文件:BreventIntentService.java
private static void showNoBrevent(Context context,boolean exit) {
UILog.i("no brevent,exit: " + exit);
Notification.Builder builder = buildNotification(context);
builder.setAutoCancel(true);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setSmallIcon(BuildConfig.IC_STAT);
int title = exit ? R.string.brevent_status_stopped : R.string.brevent_status_unkNown;
builder.setContentTitle(context.getString(title));
File file = AppsActivityHandler.fetchLogs(context);
if (BuildConfig.RELEASE && file != null) {
builder.setContentText(context.getString(R.string.brevent_status_report));
Intent intent = new Intent(context,BreventActivity.class);
intent.setAction(BreventIntent.ACTION_FeedBACK);
intent.putExtra(BreventIntent.EXTRA_PATH,file.getPath());
builder.setContentIntent(PendingIntent.getActivity(context,PendingIntent.FLAG_UPDATE_CURRENT));
}
Notification notification = builder.build();
getnotificationmanager(context).notify(ID2,notification);
if (exit) {
BreventActivity.cancelAlarm(context);
}
}
static void showUpdateNotAvailableNotification(Context context,String title,String content,int smallIconResourceId) {
PendingIntent contentIntent = PendingIntent.getActivity(context,context.getPackageManager().getLaunchIntentForPackage(UtilsLibrary.getAppPackageName(context)),PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentIntent(contentIntent)
.setContentTitle(title)
.setContentText(content)
.setStyle(new NotificationCompat.BigTextStyle().bigText(content))
.setSmallIcon(smallIconResourceId)
.setSound(ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION))
.setonlyAlertOnce(true)
.setAutoCancel(true);
notificationmanager notificationmanager = (notificationmanager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(0,builder.build());
}
项目:orgzly-android
文件:ListWidgetProvider.java
private static void scheduleUpdate(Context context) {
/*
schedule updates via AlarmManager,because we don't want to wake the device on every update
see https://developer.android.com/guide/topics/appwidgets/index.html#MetaData
*/
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
PendingIntent intent = getAlarmIntent(context);
alarmManager.cancel(intent);
/* repeat after every full hour because results of search can change on new day
because of timezones repeat every hour instead of every day */
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.HOUR_OF_DAY,1);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,1);
alarmManager.setInexactRepeating(AlarmManager.RTC,AlarmManager.INTERVAL_HOUR,intent);
}
项目:chromium-for-android-56-debug-video
文件:IntentHandler.java
/**
* @param intent An Intent to be checked.
* @param context A context.
* @return Whether an intent originates from Chrome or a first-party app.
*/
public static boolean isIntentChromeOrFirstParty(Intent intent,Context context) {
if (intent == null) return false;
PendingIntent token = fetchAuthenticationTokenFromIntent(intent);
if (token == null) return false;
// Do not ignore a valid URL Intent if the sender is Chrome. (If the PendingIntents are
// equal,we kNow that the sender was us.)
if (isChrometoken(token,context)) {
return true;
}
if (ExternalAuthUtils.getInstance().isGoogleSigned(
context,ApiCompatibilityUtils.getCreatorPackage(token))) {
return true;
}
return false;
}
项目: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,0 /* Request code */,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());
}
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,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);
}
项目:q-mail
文件:MessageListWidgetProvider.java
private void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.message_list_widget_layout);
views.setTextViewText(R.id.folder,context.getString(R.string.integrated_inBox_title));
Intent intent = new Intent(context,MessageListWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(R.id.listView,intent);
PendingIntent viewAction = viewActionTemplatePendingIntent(context);
views.setPendingIntentTemplate(R.id.listView,viewAction);
PendingIntent composeAction = composeActionPendingIntent(context);
views.setonClickPendingIntent(R.id.new_message,composeAction);
appWidgetManager.updateAppWidget(appWidgetId,views);
}
项目:JavaIsFun
文件:Notification_receiver.java
@Override
public void onReceive(Context context,Intent intent) {
notificationmanager notificationmanager = (notificationmanager) context.getSystemService
(context.NOTIFICATION_SERVICE);
Intent repeating_intent = new Intent(context,MainActivity.class);
repeating_intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context,100,repeating_intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setSmallIcon(R.drawable.microchip);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setPriority(1);
builder.setVibrate(new long[]{1000,1000});
builder.setContentIntent(pendingIntent);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle("Não esqueça de praticar!");
builder.setContentText("Que tal dar uma praticada no bom e velho Java?");
// builder.setAutoCancel(true);
notificationmanager.notify(100,builder.build());
} else {
builder.setSmallIcon(R.drawable.microchip);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setPriority(1);
builder.setVibrate(new long[]{1000,builder.build());
}
// NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
}
项目:Saiy-PS
文件:NotificationHelper.java
/**
* Show a computing notification.
*
* @param ctx the application context
*/
public static void createComputingNotification(@NonNull final Context ctx) {
if (DEBUG) {
MyLog.i(CLS_NAME,"createComputingNotification");
}
try {
final Intent actionIntent = new Intent(NotificationService.INTENT_CLICK);
actionIntent.setPackage(ctx.getPackageName());
actionIntent.putExtra(NotificationService.CLICK_ACTION,NotificationService.NOTIFICATION_COmpuTING);
final PendingIntent pendingIntent = PendingIntent.getService(ctx,NotificationService.NOTIFICATION_COmpuTING,actionIntent,PendingIntent.FLAG_CANCEL_CURRENT);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx,NOTIFICATION_CHANNEL_INteraCTION);
builder.setContentIntent(pendingIntent).setSmallIcon(android.R.drawable.ic_popup_sync)
.setTicker(ctx.getString(ai.saiy.android.R.string.notification_computing)).setWhen(System.currentTimeMillis())
.setContentTitle(ctx.getString(ai.saiy.android.R.string.app_name))
.setContentText(ctx.getString(ai.saiy.android.R.string.notification_computing) + "... "
+ ctx.getString(ai.saiy.android.R.string.notification_tap_cancel))
.setAutoCancel(true);
final Notification not = builder.build();
final notificationmanager notificationmanager = (notificationmanager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(NotificationService.NOTIFICATION_COmpuTING,not);
} catch (final Exception e) {
if (DEBUG) {
MyLog.e(CLS_NAME,"createComputingNotification failure");
e.printstacktrace();
}
}
}
项目:Android-Programming-BigNerd
文件:PollService.java
@Override
protected void onHandleIntent(@Nullable Intent intent) {
if (!isNetworkAvailableAndConnected()) {
return;
}
String query = QueryPreferences.getStoredQuery(this);
String lastResultId = QueryPreferences.getLastResultId(this);
List<galleryItem> items;
if (query == null) {
items = new FlickrFetchr().fetchRecentPhotos();
} else {
items = new FlickrFetchr().searchPhotos(query);
}
if (items.size() == 0) {
return;
}
String resultId = items.get(0).getId();
if (resultId == null || !resultId.equals(lastResultId)) {
Resources resources = getResources();
Intent i = PhotogalleryActivity.newIntent(this);
PendingIntent pi = PendingIntent.getActivity(this,i,0);
Notification notification = new NotificationCompat.Builder(this)
.setTicker(resources.getString(R.string.new_pictures_title))
.setSmallIcon(android.R.drawable.ic_menu_report_image)
.setContentTitle(resources.getString(R.string.new_pictures_title))
.setContentText(resources.getString(R.string.new_pictures_text))
.setContentIntent(pi)
.setAutoCancel(true)
.build();
QueryPreferences.setLastResultId(this,resultId);
showBackgroundNotification(0,notification);
}
}
项目:puremadrid
文件:MyFirebaseMessagingService.java
private void sendNotification(int id,int color) {
Intent intent = new Intent(this,MainActivity.class);
intent.putExtra(MainActivity.KEY_OPENED_FROM_NOTIFICATION,true);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,"")
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(pendingIntent)
.setColor(color)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setAutoCancel(true)
;
Uri defaultSoundUri = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);
notificationBuilder.setSound(defaultSoundUri);
notificationBuilder.setVibrate(new long[]{1000,1000});
notificationBuilder.setLights(color,1000,1000);
Notification notification = notificationBuilder.build();
notificationmanager notificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationmanager.notify(id,notification);
}
项目:publicProject
文件:DownLoadService.java
private Notification getNotifaction(String title,int progress) {
Intent intent = new Intent(this,DownLoadActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0);
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle(title);
builder.setAutoCancel(true);
builder.setContentIntent(pendingIntent);
if (progress > 0) {
builder.setProgress(100,progress,false);
builder.setContentText(progress + "%");
}
return builder.build();
}
项目:FiveMinsMore
文件:MapsActivity.java
public void removeLocationUpdates() {
// Set intent for Tracking
Intent mServiceIntent = new Intent(this,TrackingService.class);
PendingIntent mPendingIntent = PendingIntent.getService(
this,mServiceIntent,PendingIntent.FLAG_UPDATE_CURRENT);
// End tracking
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleapiclient,mPendingIntent);
unbindService(this);
stopService(mServiceIntent);
}
项目:chromium-for-android-56-debug-video
文件:OmahaClient.java
/**
* Sets a repeating alarm that fires request registration Intents.
* Setting the alarm overwrites whatever alarm is already there,and rebooting
* clears whatever alarms are currently set.
*/
private void scheduleRepeatingalarm() {
Intent registerIntent = createRegisterRequestIntent(this);
PendingIntent pIntent = PendingIntent.getService(this,registerIntent,0);
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
setAlarm(am,pIntent,AlarmManager.RTC,mTimestampForNewRequest);
}
项目:CSipSimple
文件:Compatibility.java
/**
* Wrapper to set alarm at exact time
* @see AlarmManager#setExact(int,long,PendingIntent)
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void setExactAlarm(AlarmManager alarmManager,int alarmType,long firstTime,PendingIntent pendingIntent) {
if(isCompatible(Build.VERSION_CODES.KITKAT)) {
alarmManager.setExact(alarmType,firstTime,pendingIntent);
}else {
alarmManager.set(alarmType,pendingIntent);
}
}
项目:GitHub
文件:PhoneUtils.java
/**
* 发送短信
* <p>需添加权限 {@code <uses-permission android:name="android.permission.SEND_SMS"/>}</p>
*
* @param phoneNumber 接收号码
* @param content 短信内容
*/
public static void sendSmsSilent(final String phoneNumber,final String content) {
if (StringUtils.isEmpty(content)) return;
PendingIntent sentIntent = PendingIntent.getbroadcast(Utils.getApp(),new Intent(),0);
SmsManager smsManager = SmsManager.getDefault();
if (content.length() >= 70) {
List<String> ms = smsManager.divideMessage(content);
for (String str : ms) {
smsManager.sendTextMessage(phoneNumber,str,sentIntent,null);
}
} else {
smsManager.sendTextMessage(phoneNumber,null);
}
}
项目:FastAndroid
文件:BaseCallActivity.java
public void showOnGoingNotification(String title,String content) {
Intent intent = new Intent(getIntent().getAction());
Bundle bundle = new Bundle();
onSaveFloatBoxState(bundle);
intent.putExtra("floatBox",bundle);
intent.putExtra("callAction",RongCallAction.ACTION_RESUME_CALL.getName());
PendingIntent pendingIntent = PendingIntent.getActivity(this,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationUtil.showNotification(this,CALL_NOTIFICATION_ID,Notification.DEFAULT_LIGHTS);
}
项目:treasure
文件:AlarmUtil.java
/**
* 开启轮询服务
*/
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static void startAlarmService(Context context,int triggerAtMillis,Class<?> cls,String action) {
Intent intent = new Intent(context,cls);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getService(context,PendingIntent.FLAG_UPDATE_CURRENT);
startAlarmIntent(context,triggerAtMillis,pendingIntent);
}
项目:react-native-geo-fence
文件:RNGeoFenceModule.java
/**
* Gets a PendingIntent to send with the request to add or remove Geofences. Location Services
* issues the Intent inside this PendingIntent whenever a geofence transition occurs for the
* current list of geofences.
*
* @return A PendingIntent for the IntentService that handles geofence transitions.
*/
private PendingIntent getGeofencePendingIntent() {
// Reuse the PendingIntent if we already have it.
if (mGeofencePendingIntent != null) {
return mGeofencePendingIntent;
}
Intent intent = new Intent(getReactApplicationContext(),GeofenceTransitionsIntentService.class);
// We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling
// addGeofences() and removeGeofences().
return PendingIntent.getService(getReactApplicationContext(),PendingIntent.FLAG_UPDATE_CURRENT);
}
项目:chromium-for-android-56-debug-video
文件:CustomTabIntentDataProvider.java
/**
* Triggers the client-defined action when the user clicks a custom menu item.
* @param menuIndex The index that the menu item is shown in the result of
* {@link #getMenuTitles()}
*/
public void clickMenuItemWithUrl(ChromeActivity activity,int menuIndex,String url) {
Intent addedIntent = new Intent();
addedIntent.setData(Uri.parse(url));
try {
// Media viewers pass in PendingIntents that contain CHOOSER Intents. Setting the data
// in these cases prevents the Intent from firing correctly.
PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second;
pendingIntent.send(
activity,isMediaViewer() ? null : addedIntent,mOnFinished,null);
} catch (CanceledException e) {
Log.e(TAG,"Custom tab in Chrome Failed to send pending intent.");
}
}
项目:Orin
文件:PlayingNotificationImpl24.java
private PendingIntent retrievePlaybackAction(final String action) {
final ComponentName serviceName = new ComponentName(service,MusicService.class);
Intent intent = new Intent(action);
intent.setComponent(serviceName);
return PendingIntent.getService(service,0);
}
项目:Cable-Android
文件:MultipleRecipientNotificationBuilder.java
public MultipleRecipientNotificationBuilder(Context context,NotificationPrivacyPreference privacy) {
super(context,privacy);
setColor(context.getResources().getColor(R.color.textsecure_primary));
setSmallIcon(R.drawable.icon_notification);
setContentTitle(context.getString(R.string.app_name));
setContentIntent(PendingIntent.getActivity(context,new Intent(context,ConversationListActivity.class),0));
setCategory(NotificationCompat.CATEGORY_MESSAGE);
setPriority(TextSecurePreferences.getNotificationPriority(context));
setGroupSummary(true);
}
项目:q-mail
文件:MessageCompose.java
public void launchUserInteractionPendingIntent(PendingIntent pendingIntent,int requestCode) {
requestCode |= REQUEST_MASK_RECIPIENT_PRESENTER;
try {
startIntentSenderForResult(pendingIntent.getIntentSender(),requestCode,0);
} catch (SendIntentException e) {
e.printstacktrace();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。