首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到notification.setLatestEventInfo

找不到notification.setLatestEventInfo
EN

Stack Overflow用户
提问于 2016-04-11 10:15:19
回答 2查看 527关注 0票数 0

我正在获取notification.setLatestEventInfo(this,TAG,message,contentIntent)方法中找不到的方法。我必须更改build.grade吗?

代码语言:javascript
复制
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:

代码语言:javascript
复制
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'
}
EN

回答 2

Stack Overflow用户

发布于 2016-04-11 10:22:24

在API23中删除了setLatestEventInfo。请改用Notification.Builder

http://developer.android.com/reference/android/app/Notification.Builder.html

票数 1
EN

Stack Overflow用户

发布于 2016-04-11 10:54:27

请改用NotificationCompat。

http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

setLatestEventInfo已经被弃用了很长一段时间。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36538787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档