EclipseでAndroidソースコードを実行しようとしています。このアプリのtargetSdkVerisonは5です。私はAndroidをまったく使用したことがなく、最新のAPI(Android 4.1)をインストールしました。コードの一部で、次のようなエラーが発生します
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間の非互換性が原因だと思います。どうすれば同じことを解決できますか?