From 892ce2a15de72751338073ede56aedb12c48a588 Mon Sep 17 00:00:00 2001 From: hyx <1515023255@qq.com> Date: Tue, 22 Apr 2025 14:30:30 +0800 Subject: [PATCH] =?UTF-8?q?GTaskASyncTask.java=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hyx_小米便签项目日志.md | 35 +++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/hyx_小米便签项目日志.md b/hyx_小米便签项目日志.md index 5fd87bd..db97744 100644 --- a/hyx_小米便签项目日志.md +++ b/hyx_小米便签项目日志.md @@ -2,7 +2,7 @@ -### 导入文档 +#### 导入文档 直接使用老师提供压缩包文档用Android studio打开,出现报错显示检测不到build.gradle文件 @@ -18,4 +18,35 @@ -​ \ No newline at end of file +#### GTaskASyncTask.java修改 + +出现报错:80: 错误: 找不到符号 + notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content, + ^ + +分析原因:版本问题,新版本的安卓项目对notification.builder不兼容了,需要把showNotification函数进行修改 + +修改代码: + +```java +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), PendingIntent.FLAG_IMMUTABLE); + } else { + pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, + NotesListActivity.class), PendingIntent.FLAG_IMMUTABLE); + } + 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); +} +``` +