I have found following code on net. I am confused about the first line. What is the purpose of this line ?
@SuppressWarnings("unchecked")
private void showAlert(String title,String msg,final Class cls)
{
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(title);
alertDialog.setMessage(msg);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent samepage = new Intent(LoginActivity.this,
cls);
startActivity(samepage);
}
});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
}
There is an unchecked generics conversion / casting in the code inside of the method.
So by indicating a
@SuppressWarningsannotation, you don’t get a warning from the IDE or compilation, as you are telling the compiler that you are aware and you don’t get warnings.