AN IMPLICIT INTENT



 Here we are gonna get through the 

// Setting the intent

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(data_earthquake.getmUrl()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
Log.d("debug", "onClick: inTryBrowser");
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e("debug", "onClick: in inCatchBrowser", ex );
intent.setPackage(null);
startActivity(Intent.createChooser(intent, "Select Browser"));
}

here we are declaring the implicit intent and we are trying to open it in the chrome browser and in case if it is not installed in the phone then we get to select the browser.

log.d -- is being used for the debug.

we set the intent package to be null because we had already provided him the package so we need make it empty first.

earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Data_Earthquake data_earthquake = earthquakes.get(i);

to Set the onclicklistener in the adapterview we have to do this and here we are trying to get the index no of the listview in the data earthquake.




Comments