I'm trying to launch a new intent from the onPostExecute function of a class that extends AsyncTask. This class is written in the same .java file with the main activity class, and is executed in that main activity class's onCreate function.
public class AnnouncementsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
new GetAnnouncements().execute();
// ...
}
private class GetAnnouncements extends AsyncTask<Void, Void, Void> {
ArrayList<HashMap<String, String>> announcementsList = null;
ProgressDialog progressDialog;
protected void onPostExecute(Void requestResult) {
super.onPostExecute(requestResult);
// ...
announcementsListView.setAdapter(adapter);
announcementsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent openInBrowserIntent = new Intent(AnnouncementsActivity.class, Uri.parse(announcementsList.get(position).get("link")));
}
});
// ...
}
}
}
The error I get is:
error: no suitable constructor found for Intent(Class,Uri) constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; Class cannot be converted to String) constructor Intent.Intent(Context,Class) is not applicable (argument mismatch; Class cannot be converted to Context)
What am I doing wrong here?