From 9f1bd44f88669b6a107cdcee4f9f57abda0e678f Mon Sep 17 00:00:00 2001 From: Lin-bp <2280119672@qq.com> Date: Thu, 14 Mar 2024 20:38:04 +0800 Subject: [PATCH] =?UTF-8?q?Lin-bp=EF=BC=9A=E2=80=9C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86GtaskASync=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AA=E7=B1=BB=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notes/gtask/remote/GTaskASyncTask.java | 72 ++++++++++++++----- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java index b3b61e7..adf4b66 100644 --- a/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java +++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java @@ -63,25 +63,63 @@ public class GTaskASyncTask extends AsyncTask { }); } - 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, - NotesPreferenceActivity.class), 0); - - } else { - 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) { +// 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, +// NotesPreferenceActivity.class), 0); +// +// } else { +// 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) { publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity -- Gitee