GTaskASyncTask.java修改

hyx_brand
hyx 2 months ago
parent 2b1310ee3d
commit 892ce2a15d

@ -2,7 +2,7 @@
### 导入文档 #### 导入文档
直接使用老师提供压缩包文档用Android studio打开出现报错显示检测不到build.gradle文件 直接使用老师提供压缩包文档用Android studio打开出现报错显示检测不到build.gradle文件
@ -18,4 +18,35 @@
#### 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);
}
```

Loading…
Cancel
Save