我正在获取notification.setLatestEventInfo(this,TAG,message,contentIntent)方法中找不到的方法。我必须更改build.grade吗?
private void displayNotificationMessage(String message) {
Notification notification = new Notification(R.drawable.emo_im_winking,
message, System.currentTimeMillis());
notification.flags = Notification.FLAG_NO_CLEAR;
PendingIntent contentIntent =
PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
notification.setLatestEventInfo(this, TAG, message, contentIntent);
notificationMgr.notify(0, notification);
}这是我当前的build.grade:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.androidbook.services.simplelocalservice"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}发布于 2016-04-11 10:22:24
在API23中删除了setLatestEventInfo。请改用Notification.Builder。
http://developer.android.com/reference/android/app/Notification.Builder.html
发布于 2016-04-11 10:54:27
请改用NotificationCompat。
http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html
setLatestEventInfo已经被弃用了很长一段时间。
https://stackoverflow.com/questions/36538787
复制相似问题