2015-11-07 204 views
0

我試着做一個自動更新應用程序,並從這裏得到的源代碼: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); 
    } 
} 

回答

相關問題