In my Android project I have made an abstract AsyncTask class in which I input the URL and if needed paging information so I don\'t need to keep writing the HTTP stuff etc.<
You can't avoid the warning, but you can hide it with a @SuppressWarnings annotation. Try this:
new SuperCoolAsyncTask() {
@Override
@SuppressWarnings("unchecked")
protected void onAsyncTaskResult(Object o) {
if(o instanceof ArrayList) {
//generates warning in the following line
AppConstants.scoreStatistics = (ArrayList)o;
}
}
}.execute(get_url_score_statistics());
The other option, if you're really worried about type safety, is to leave the generic unspecified (i.e. only cast to ArrayList, not ArrayList, and then cast each element as you remove it.