ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("log", s);
clipboard.setPrimaryClip(clip);
This code gives the error “Code requires API level 11 (current is 8)”. Only because these 3 lines I need to change minSdkVersion from 8 to 11. Is it possible to have minSdkVersion 8, and do something with this code – for example, execute it only if current version is at least 11? But I still want to have this functionality, and don’t want to change minSdkVersion.
You can wrap your code into a conditional block to make it run only on platform versions that allow it:
Also you may want to tell
Lintto use a warning level on this case instead of the normal error level that it uses:Window -> Preferences -> Android -> Lint Error Checking -> Select New Api and change the severity to Warning