android 设置每天重复通知,是否有可能在android中更改重复通知的内容文本或消息?如果是,如何?...

这里我在广播接收机类中所做的更改。

public class TimeAlarm extends BroadcastReceiver {

NotificationManager nm;

long pattern[] = {500, 500};

private Uri notifsound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

private NotificationCompat.BigTextStyle contentStyle;

private List contentTexts, contentTitles;

@Override

public void onReceive(Context context, Intent intent) {

contentTexts = new ArrayList();

contentTitles = new ArrayList();

prepareContentTitles();

prepareContentTexts();

SharedPreferences prefs = context.getSharedPreferences("notification_count", context.MODE_PRIVATE);

int count = prefs.getInt("notification_count", 0);

contentStyle = new android.support.v4.app.NotificationCompat.BigTextStyle();

contentStyle.bigText((CharSequence) contentTexts.get(count));

contentStyle.setBigContentTitle((CharSequence) contentTitles.get(count));

contentStyle.setSummaryText("AutoKit");

NotificationCompat.Builder builder;

builder = (NotificationCompat.Builder) new NotificationCompat.Builder(context)

.setSmallIcon(R.mipmap.ic_launcher)

.setContentTitle("AutoKit")

.setContentText("Tip of the Day")

.setTicker("Daily Tip")

.setStyle(contentStyle)

.setSound(notifsound)

.setAutoCancel(true)

.setVibrate(pattern);

PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(contentIntent);

nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

nm.notify(1, builder.build());

if (count == contentTexts.size() - 1) {

SharedPreferences.Editor editor = prefs.edit();

editor.putInt("notification_count", 0);

editor.commit();

}

else {

SharedPreferences.Editor editor = prefs.edit();

editor.putInt("notification_count", count + 1);

editor.commit();

}

}

public void prepareContentTexts() {

contentTexts.add("Drivers who sit higher feel as if they're driving slower. " +

"Thus, SUV drivers, who are already piloting the vehicles most prone to " +

"roll, drive faster because they feel like they're creeping along. " +

"So lower your seat to get the sensation of more speed.");

contentTexts.add("Manufacturers recommend replacing your blades every three months. " +

"Keep a spare set in your trunk. A product such as Rain Clear can also help " +

"minimize the work of your wipers; spray it onto the glass every few weeks. " +

"In some light rains, it makes the wipers almost unnecessary");

contentTexts.add("At the BMW Performance Driving School, instructor Jim Clark says " +

"these four words over and over: \"Slow in, fast out.\" When taking a corner," +

" you need to scrub as much of that speed as you can while the car is braking" +

" in a straight line, then you can accelerate out of the curve. The converse " +

"is \"Fast in, maybe no out.\"");

}

public void prepareContentTitles() {

contentTitles.add("Lower Your Seat");

contentTitles.add("Rainproof Your Windshield");

contentTitles.add("Maneuver Tight Corners ");

}

}

通知显示每次烧制

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值