I am trying to create an intent to create an sms with compatibility for API levels higher than KitKat
.
The code works, but I got a warning that the API level 19 is required.
I tried to solve it with @TargetApi(Build.VERSION_CODES.KITKAT)
but got a warning "Annotations
are not allowed here".
Is there an easy way to ignore this warning?
private boolean apLowerThanKitKat = (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT);
Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
if (apLowerThanKitKat)
{
smsIntent.setPackage("vnd.android-dir/mms-sms");
}
else
{
//@TargetApi(Build.VERSION_CODES.KITKAT)
smsIntent.setPackage(Telephony.Sms.getDefaultSmsPackage(getActivity()));
}
Thanks in advance!