gpt4 book ai didi

android - 使用 androidx NotificationManagerCompat 无法解析符号 'from'

转载 作者:行者123 更新时间:2023-12-04 17:39:26 24 4
gpt4 key购买 nike

在扩展 JobService 的 Java 类中使用 NotificationManagerCompat,出现“无法解析”错误。执行了“无效并重新启动”但没有任何反应。

这是我的代码:

import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;


public class DailyNotificationJob extends JobService {

JobParameters paramic;
Boolean jobCancelled = false;

@Override
public boolean onStartJob(JobParameters params) {
new postRequest().execute(propertyName);
return true;
}

@Override
public boolean onStopJob(JobParameters params) {
jobCancelled = true;
return false;
}

@SuppressLint("StaticFieldLeak")
public class postRequest extends AsyncTask<String,Void,String> {

//SOME CODE WAS REMOVED

@SuppressLint("DefaultLocale")
@Override
protected void onPostExecute(String postDatareceived) {

// Create an explicit intent for an Activity in your app
Intent intent = new Intent(DailyNotificationJob.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(DailyNotificationJob.this, 0, intent, 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(DailyNotificationJob.this, "1")
.setSmallIcon(R.drawable.rocket)
.setContentTitle("Search Console Update")
.setContentText(body)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent);

NotificationManagerCompat notificationManagerCompat = new NotificationManagerCompat.from(this);
notificationManagerCompat.notify((int) System.currentTimeMillis(), builder.build());

}
}


}
jobFinished(paramic,true);

}

}



}

notificationmanagercompact 无法解析符号:
notificationmanagercompact cannot resolve symbol from

最佳答案

去掉“新建”

NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);

关于android - 使用 androidx NotificationManagerCompat 无法解析符号 'from',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55168021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com