2015-11-07 3 views
0

Im пытается сделать приложение автоматического обновления и получил исходный код здесь: https://code.google.com/p/auto-update-apk-client/downloads/detail?name=auto-update-apk-client_2012-10-04.tgz&can=2&q=Неизвестный метод setLatestEventInfo

Но я получил ошибку «неизвестный метод setLatestEventInfo»

Спасибо за помощь.

protected void raise_notification() { 
    String ns = Context.NOTIFICATION_SERVICE; 
    NotificationManager nm = (NotificationManager) context.getSystemService(ns); 

    String update_file = preferences.getString(UPDATE_FILE, ""); 
    if(update_file.length() > 0) { 
     setChanged(); 
     notifyObservers(AUTOUPDATE_HAVE_UPDATE); 

     // raise notification 
     Notification notification = new Notification(
       appIcon, appName + " update", System.currentTimeMillis()); 
     notification.flags |= NOTIFICATION_FLAGS; 

     CharSequence contentTitle = appName + " update available"; 
     CharSequence contentText = "Select to install"; 
     Intent notificationIntent = new Intent(Intent.ACTION_VIEW); 
     notificationIntent.setDataAndType(
       Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + update_file), 
       ANDROID_PACKAGE); 
     PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 

     notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
     nm.notify(NOTIFICATION_ID, notification); 
    } else { 
     nm.cancel(NOTIFICATION_ID); 
    } 
} 

ответ

0

Этот метод не рекомендуется в уровне API 11. Вы должны использовать NotificationBuilder вместо этого. Обратите внимание на ответы Building a Notification lesson и this.

Смежные вопросы