From 5eb319659eec673c463ea388fdb905e3a8894487 Mon Sep 17 00:00:00 2001 From: yyn <820966846@qq.com> Date: Tue, 16 Aug 2022 21:38:23 +0800 Subject: [PATCH] modified: src/src/net/micode/notes/gtask/remote/GTaskASyncTask.java --- .../notes/gtask/remote/GTaskASyncTask.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/src/net/micode/notes/gtask/remote/GTaskASyncTask.java b/src/src/net/micode/notes/gtask/remote/GTaskASyncTask.java index b3b61e7..2441294 100644 --- a/src/src/net/micode/notes/gtask/remote/GTaskASyncTask.java +++ b/src/src/net/micode/notes/gtask/remote/GTaskASyncTask.java @@ -63,11 +63,18 @@ public class GTaskASyncTask extends AsyncTask { }); } + /* + * The method 'notification.setLatestEventInfo' has been deprecated over API level 11, + * Thus the method below should be overwrite. + * Here is the original source code. + */ + /* private void showNotification(int tickerId, String content) { Notification notification = new Notification(R.drawable.notification, mContext .getString(tickerId), System.currentTimeMillis()); notification.defaults = Notification.DEFAULT_LIGHTS; notification.flags = Notification.FLAG_AUTO_CANCEL; + PendingIntent pendingIntent; if (tickerId != R.string.ticker_success) { pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, @@ -77,10 +84,32 @@ public class GTaskASyncTask extends AsyncTask { pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, NotesListActivity.class), 0); } + notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content, pendingIntent); mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); } + */ + + private void showNotification(int tickerId, String content) { + PendingIntent pendingIntent; + if (tickerId != R.string.ticker_success) { + pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, NotesPreferenceActivity.class), 0); + } else { + pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, NotesListActivity.class), 0); + } + + Notification.Builder builder = new Notification.Builder(mContext) + .setAutoCancel(true) + .setContentTitle(mContext.getString(R.string.app_name)) + .setContentText(content) + .setContentIntent(pendingIntent) + .setWhen(System.currentTimeMillis()) + .setOngoing(true); + + Notification notification = builder.getNotification(); + mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); + } @Override protected Integer doInBackground(Void... unused) {