本文整理匯總了Java中android.support.v4.app.NotificationCompat.Builder.setTicker方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.setTicker方法的具體用法?Java Builder.setTicker怎麽用?Java Builder.setTicker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.NotificationCompat.Builder
的用法示例。
在下文中一共展示了Builder.setTicker方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayOpenFileNotification
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void displayOpenFileNotification() {
Intent notificationIntent = getOpenIntent();
int icon = R.mipmap.video2;
CharSequence title = getResources().getText(R.string.open_file);
long when = System.currentTimeMillis();
PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, notificationIntent, 0);
Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setSmallIcon(icon);
notificationBuilder.setTicker(null);
notificationBuilder.setOnlyAlertOnce(true);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(mProcessedFiles.get(0).getName());
notificationBuilder.setContentIntent(contentIntent);
notificationBuilder.setWhen(when);
notificationBuilder.setDefaults(0); // no sound, no light, no vibrate
mNotificationManager.notify(OPEN_NOTIFICATION_ID, notificationBuilder.build());
}
示例2: modifyForConference
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
final Message first = messages.get(0);
final Message last = messages.get(messages.size() - 1);
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
style.setBigContentTitle(conversation.getName());
for(Message message : messages) {
if (message.hasMeCommand()) {
style.addLine(UIHelper.getMessagePreview(mXmppConnectionService,message).first);
} else {
style.addLine(Html.fromHtml("<b>" + UIHelper.getMessageDisplayName(message) + "</b>: " + UIHelper.getMessagePreview(mXmppConnectionService, message).first));
}
}
builder.setContentText((first.hasMeCommand() ? "" :UIHelper.getMessageDisplayName(first)+ ": ") +UIHelper.getMessagePreview(mXmppConnectionService, first).first);
builder.setStyle(style);
if (notify) {
builder.setTicker((last.hasMeCommand() ? "" : UIHelper.getMessageDisplayName(last) + ": ") + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
}
}
示例3: modifyForTextOnly
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForTextOnly(final Builder builder,
final ArrayList<Message> messages, final boolean notify) {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
if (notify) {
builder.setTicker(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(messages.size() - 1)).first);
}
}
示例4: modifyForConference
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
final Message first = messages.get(0);
final Message last = messages.get(messages.size() - 1);
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
style.setBigContentTitle(conversation.getName());
for(Message message : messages) {
style.addLine(Html.fromHtml("<b>"+UIHelper.getMessageDisplayName(message)+"</b> "+UIHelper.getMessagePreview(mXmppConnectionService,message).first));
}
builder.setContentText(UIHelper.getMessageDisplayName(first)+ ": " +UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
builder.setStyle(style);
if (notify) {
builder.setTicker(UIHelper.getMessageDisplayName(last) + ": " + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
}
}
示例5: sendNotification
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void sendNotification(final Notification notification, final boolean sendDetails)
{
final Builder builder = KlyphNotification.getBuilder(service.get(), true);
builder.setContentTitle(notification.getSender_name());
builder.setContentText(notification.getTitle_text());
builder.setTicker(String.format("%1$s\n%2$s", notification.getSender_name(), notification.getTitle_text()));
ImageLoader.loadImage(notification.getSender_pic(), new SimpleFakeImageLoaderListener() {
@Override
public void onBitmapFailed(Drawable drawable)
{
if (sendDetails)
KlyphNotification.sendNotification(service.get(), builder, notification);
else
KlyphNotification.sendNotification(service.get(), builder);
}
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1)
{
builder.setLargeIcon(bitmap);
if (sendDetails)
KlyphNotification.sendNotification(service.get(), builder, notification);
else
KlyphNotification.sendNotification(service.get(), builder);
}
});
}
示例6: modifyForTextOnly
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForTextOnly(final Builder builder,
final ArrayList<Message> messages, final boolean notify) {
builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(getMergedBodies(messages)));
builder.setContentText(getReadableBody(messages.get(0)));
if (notify) {
builder.setTicker(getReadableBody(messages.get(messages.size() - 1)));
}
}
示例7: notifyRegisteredAccounts
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public synchronized void notifyRegisteredAccounts(ArrayList<SipProfileState> activeAccountsInfos, boolean showNumbers) {
if (!isServiceWrapper) {
Log.e(THIS_FILE, "Trying to create a service notification from outside the service");
return;
}
int icon = R.drawable.ic_stat_sipok;
CharSequence tickerText = context.getString(R.string.service_ticker_registered_text);
long when = System.currentTimeMillis();
Builder nb = new Builder(context);
nb.setSmallIcon(icon);
nb.setTicker(tickerText);
nb.setWhen(when);
Intent notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
RegistrationNotification contentView = new RegistrationNotification(context.getPackageName());
contentView.clearRegistrations();
if(!Compatibility.isCompatible(9)) {
contentView.setTextsColor(notificationPrimaryTextColor);
}
contentView.addAccountInfos(context, activeAccountsInfos);
// notification.setLatestEventInfo(context, contentTitle,
// contentText, contentIntent);
nb.setOngoing(true);
nb.setOnlyAlertOnce(true);
nb.setContentIntent(contentIntent);
nb.setContent(contentView);
Notification notification = nb.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
// We have to re-write content view because getNotification setLatestEventInfo implicitly
notification.contentView = contentView;
if (showNumbers) {
// This only affects android 2.3 and lower
notification.number = activeAccountsInfos.size();
}
startForegroundCompat(REGISTER_NOTIF_ID, notification);
}
示例8: showInNotificationBar
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void showInNotificationBar(String title,String ticker, Bitmap iconBitmap,int notificationId,Intent intent) {
logger.d("notification#showInNotificationBar title:%s ticker:%s",title,ticker);
NotificationManager notifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
if (notifyMgr == null) {
return;
}
Builder builder = new NotificationCompat.Builder(ctx);
builder.setContentTitle(title);
builder.setContentText(ticker);
builder.setSmallIcon(R.drawable.tt_small_icon);
builder.setTicker(ticker);
builder.setWhen(System.currentTimeMillis());
builder.setAutoCancel(true);
// this is the content near the right bottom side
// builder.setContentInfo("content info");
if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.VIBRATION)) {
// delay 0ms, vibrate 200ms, delay 250ms, vibrate 200ms
long[] vibrate = {0, 200, 250, 200};
builder.setVibrate(vibrate);
} else {
logger.d("notification#setting is not using vibration");
}
// sound
if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.SOUND)) {
builder.setDefaults(Notification.DEFAULT_SOUND);
} else {
logger.d("notification#setting is not using sound");
}
if (iconBitmap != null) {
logger.d("notification#fetch icon from network ok");
builder.setLargeIcon(iconBitmap);
} else {
// do nothint ?
}
// if MessageActivity is in the background, the system would bring it to
// the front
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
Notification notification = builder.build();
notifyMgr.notify(notificationId, notification);
}
示例9: onRequestSuccess
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void onRequestSuccess(List<GraphObject> list)
{
Log.d("FriendRequestService", "Num friend request : " + list.size());
Log.d("FriendRequestService", "Service : " + service.get());
if (service.get() == null)
return;
Service s = service.get();
if (list.size() > 0)
{
FriendRequest fq = (FriendRequest) list.get(0);
KlyphPreferences.setFriendRequestServiceOffset(fq.getTime());
final Builder builder = KlyphNotification.getBuilder(s, true);
builder.setContentTitle(fq.getUid_from_name()).setContentText(
s.getString(R.string.notification_friendrequest_message, fq.getUid_from_name()));
if (KlyphPreferences.mustGroupNotifications() && list.size() > 1)
{
sendNotification(list);
}
else
{
boolean isFirst = true;
for (GraphObject graphObject : list)
{
FriendRequest fr = (FriendRequest) graphObject;
TaskStackBuilder stackBuilder = TaskStackBuilder.create(service.get());
Intent intent = Klyph.getIntentForGraphObject(service.get(), fr);
// stackBuilder.addParentStack(UserActivity.class);
Intent mainIntent = new Intent(service.get(), MainActivity.class);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
stackBuilder.addNextIntent(mainIntent);
stackBuilder.addNextIntent(intent);
int intentCode = (int) Math.round(Math.random() * 1000000);
// Gets a PendingIntent containing the entire back stack
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(intentCode, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
builder.setContentTitle(fr.getUid_from_name());
builder.setContentText(s.getString(R.string.notification_friendrequest_message, fr.getUid_from_name()));
builder.setTicker(s.getString(R.string.notification_friendrequest_message, fr.getUid_from_name()));
if (isFirst == false)
{
KlyphNotification.setNoSound(builder);
KlyphNotification.setNoVibration(builder);
}
KlyphNotification.sendNotification(s, builder);
isFirst = false;
}
}
service.get().stopSelf();
}
else
{
s.stopSelf();
}
}
示例10: setAlarm
import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void setAlarm(long interval, boolean repeat) {
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intent = new Intent(ACTION_KEEP_ALIVE);
intent.setClass(mContext, LoginService.class);
PendingIntent pi = PendingIntent.getService(mContext, REQUEST_CODE
, intent
, PendingIntent.FLAG_CANCEL_CURRENT);
long next = System.currentTimeMillis() + interval + 1000;
if (repeat) {
am.setRepeating(AlarmManager.RTC_WAKEUP, next, REPEAT_FREQ, pi);
// if show notification is enabled, show it
if (SettingsManager.getBoolean(mContext, SettingsManager.SHOW_NOTIF
, true)) {
long now = System.currentTimeMillis();
int limit = SettingsManager.getInt(mContext
, SettingsManager.KEEP_ALIVE, -1);
long login = SettingsManager.getLong(mContext
, SettingsManager.LOG_IN_TIME, now);
NotificationManager nm = (NotificationManager) getSystemService(
NOTIFICATION_SERVICE);
Builder b = new NotificationCompat.Builder(mContext);
b.setOngoing(true);
b.setContentTitle(getResources().getString(R.string.app_name));
b.setContentText(getResources().getString(R.string.from)
+ " : " + sdf.format(new Date(login))
+ (limit <= 0 ? "" : " | " + getResources().getString(R
.string.upto) + " : " + sdf.format(new Date(login
+ limit * DateUtils.HOUR_IN_MILLIS))));
b.setSmallIcon(R.drawable.ic_launcher);
b.setTicker(getResources().getString(R.string.logged_in)
+ ", " + getResources().getString(R.string.internet_access));
Intent i = new Intent(mContext, CredentialActivity.class);
PendingIntent pia = PendingIntent.getActivity(mContext, 0, i, Intent
.FLAG_ACTIVITY_CLEAR_TOP);
b.setContentIntent(pia);
Notification n = b.build();
nm.notify(1000, n);
}
} else {
am.set(AlarmManager.RTC_WAKEUP, next, pi);
}
}