Skip to content

Commit

Permalink
don't be that guy who lets an app to crash so badly
Browse files Browse the repository at this point in the history
  • Loading branch information
ebaschiera committed Jan 19, 2021
1 parent f0a90e1 commit 6b41f9d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/src/main/java/com/ebaschiera/triplecamel/ShareActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ebaschiera.triplecamel;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.os.Bundle;
import android.content.Intent;
import android.content.Context;
Expand Down Expand Up @@ -52,7 +53,16 @@ protected void onCreate(Bundle savedInstanceState) {
//Log.d("new_intent", camel_search_uri.toString());
Intent webIntent = new Intent(Intent.ACTION_VIEW, camel_search_uri);

startActivity(webIntent);
try {
startActivity(webIntent);
} catch (ActivityNotFoundException e) {
Context context = getApplicationContext();
String text = getResources().getString(R.string.no_web_browser);
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
finish();
}
} else {
//return a warning and stop the intent
Context context = getApplicationContext();
Expand Down

0 comments on commit 6b41f9d

Please sign in to comment.