我嘗試在eclipse中運行android源代碼。這個應用程序的targetSdkVerison是5。我完全陌生的Android,並安裝了最新的API(Android 4.1)。在代碼的某些部分我m到處錯誤,如調用需要API級別5(當前最小值爲3):android.app.Service#startForeground
public void hideNotification(Service context)
{
context.setForeground(false);// error: The method setForeground(boolean) is undefined for the type Service
getNotificationManager(context).cancel(NOTIF_PLAYING);
}
public void showNotification(Service context, long songId)
{
context.startForeground(NOTIF_PLAYING, newNotification(context, songId));//error :Call requires API level 5 (current min is 3): android.app.Service#startForeground
}
我想這些都是因爲不同的SDK版本之間的不兼容。我該如何解決這個問題?