1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Prevent the app from crashing when trying to launch an invalid link or when no browser is installed.

This commit is contained in:
Christophe Beyls 2017-01-25 16:03:54 +01:00
parent 63f3f28bfa
commit 4aa734ca3b
2 changed files with 17 additions and 4 deletions

View file

@ -503,8 +503,14 @@ public class EventDetailsFragment extends Fragment {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link.getUrl()));
v.getContext().startActivity(intent);
String url = link.getUrl();
if (url != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try {
v.getContext().startActivity(intent);
} catch (ActivityNotFoundException ignore) {
}
}
}
}
}

View file

@ -1,5 +1,6 @@
package be.digitalia.fosdem.fragments;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
@ -57,8 +58,14 @@ public class PersonInfoListFragment extends RecyclerViewFragment implements Load
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.more_info:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(person.getUrl()));
startActivity(intent);
String url = person.getUrl();
if (url != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try {
startActivity(intent);
} catch (ActivityNotFoundException ignore) {
}
}
return true;
}
return false;