From af670963bc56a98e97a3aacbeb2e35d82418759f Mon Sep 17 00:00:00 2001 From: shanhanyu <202321121018@mail.scuec.edu.cn> Date: Thu, 8 May 2025 08:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E9=94=99=EF=BC=9A=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E7=AC=A6=E5=8F=B7=20notification.setLatestEventInfo..?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 2 +- .../notes/gtask/remote/GTaskASyncTask.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ca50e65..8f5c672 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { implementation(fileTree(mapOf( "dir" to "D:\\ruanjiandaolun\\xiaomi-note\\lib", "include" to listOf("*.aar", "*.jar"), - "exclude" to listOf() + "exclude" to listOf("") ))) testImplementation(libs.junit) androidTestImplementation(libs.ext.junit) 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..a1deb99 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 @@ -64,21 +64,22 @@ 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); - + NotesPreferenceActivity.class), PendingIntent.FLAG_IMMUTABLE); } else { pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, - NotesListActivity.class), 0); + NotesListActivity.class), PendingIntent.FLAG_IMMUTABLE); } - notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content, - pendingIntent); + 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); } -- 2.34.1