В моей программе пользователь получает уведомление о задаче, которую он создал, а в уведомлениях есть кнопка, которая преобразует написанные пользователем задачи в речь.
Это означает, что я хочу добавитьдействие для кнопки уведомления, которая преобразует письменные напоминания пользователя в речь.
ReminderalramService.java:
public class ReminderAlarmService extends IntentService {
private static final String TAG = ReminderAlarmService.class.getSimpleName();
private static final int NOTIFICATION_ID = 42;
//This is a deep link intent, and needs the task stack
public static PendingIntent getReminderPendingIntent(Context context, Uri uri) {
Intent action = new Intent(context, ReminderAlarmService.class);
action.setData(uri);
return PendingIntent.getService(context, 0, action, PendingIntent.FLAG_UPDATE_CURRENT);
}
public ReminderAlarmService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Uri uri = intent.getData();
//Display a notification to view the task details
Intent action = new Intent(this, AddReminderActivity.class);
action.setData(uri);
PendingIntent operation = TaskStackBuilder.create(this)
.addNextIntentWithParentStack(action)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
//Grab the task description
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
String description = "";
try {
if (cursor != null && cursor.moveToFirst()) {
description = AlarmReminderContract.getColumnString(cursor, AlarmReminderContract.AlarmReminderEntry.KEY_TITLE);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
Notification note = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.reminder_title))
.setContentText(description)
.setSmallIcon(R.drawable.ic_add_alert_black_24dp)
.setContentIntent(operation)
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setAutoCancel(true)
.build();
manager.notify(NOTIFICATION_ID, note);
}
}
Я хочу добавить действие в уведомление о тексте вречь.