2017-04-15 81 views
-1

如何修正的方法setLatestEventInfo(AlarmService_Service,字符串,CharSequences,的PendingIntent)是未定義的類型通知的java - 如何修復的方法setLatestEventInfo(AlarmService_Service,字符串,CharSequences,的PendingIntent)是未定義的類型通知

請任何幫助解決這個錯誤

this is the screenshot of the error

這是腳本:

/** 
* Show a notification while this service is running. 
*/ 
private void showNotification() { 
    // In this sample, we'll use the same text for the ticker and the expanded notification 
    CharSequence text = "Doctor Jokes SF"; 

    // Set the icon, scrolling text and timestamp 
    Notification notification = new Notification(R.drawable.icon, text,System.currentTimeMillis()); 

    Intent notifyIntent = new Intent(this, MainActivity.class); 
// Sets the Activity to start in a new, empty task 
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 

    // The PendingIntent to launch our activity if the user selects this notification 
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
     notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); 

    // Set the info for the views that show in the notification panel. 
    notification.setLatestEventInfo(this, quote.getBody(), text, contentIntent); 

    notification.flags |=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE; 
    //Define sound URI 
    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    notification.sound = soundUri; 

    // Send the notification. 
    // We use a layout id because it is a unique number. We use it later to cancel. 
    mNM.cancelAll(); 
    mNM.notify(0, notification); 
} 
+0

javascript或c#?它是什麼? 100%不是javascript – TypedSource

+0

這個腳本是從一個名爲AlarmService_Service.java的文件中從一個遊戲的代碼源獲取的,所以這是javascript! –

+0

不,它不是java,javascript是與java不同的語言。 – TypedSource

回答

0

顯然它是depracated,你應該使用通知生成器。檢出this answer

相關問題