改错:找不到符号 notification.setLatestEventInfo... #5

Merged
pb7q4l69o merged 1 commits from second into main 3 months ago

@ -40,7 +40,7 @@ dependencies {
implementation(fileTree(mapOf( implementation(fileTree(mapOf(
"dir" to "D:\\ruanjiandaolun\\xiaomi-note\\lib", "dir" to "D:\\ruanjiandaolun\\xiaomi-note\\lib",
"include" to listOf("*.aar", "*.jar"), "include" to listOf("*.aar", "*.jar"),
"exclude" to listOf() "exclude" to listOf("")
))) )))
testImplementation(libs.junit) testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit) androidTestImplementation(libs.ext.junit)

@ -64,21 +64,22 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
} }
private void showNotification(int tickerId, String content) { 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; PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) { if (tickerId != R.string.ticker_success) {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesPreferenceActivity.class), 0); NotesPreferenceActivity.class), PendingIntent.FLAG_IMMUTABLE);
} else { } else {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, 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, Notification.Builder builder = new Notification.Builder(mContext)
pendingIntent); .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); mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
} }

Loading…
Cancel
Save