Skip to content

Commit

Permalink
Merge pull request #4 from ialokim/without-whatsapp
Browse files Browse the repository at this point in the history
Show message if whatsapp not installed instead of crashing
  • Loading branch information
SubhamTyagi authored Jan 8, 2019
2 parents 10d85e4 + 934bb29 commit 238ca2c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

package io.github.subhamtyagi.openinwhatsapp.fragment;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -76,6 +78,8 @@ private void openInWhatsapp() {
startActivity(Intent.parseUri("whatsapp://send/?" + getNumber(false), 0));
} catch (URISyntaxException a) {
a.printStackTrace();
} catch (ActivityNotFoundException e) {
Snackbar.make(this.getView(), R.string.label_error_whatsapp_not_installed, Snackbar.LENGTH_LONG).show();
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<string name="label_send">Open</string>
<string name="label_error_incorrect_phone">Incorrect phone</string>
<string name="label_share">Share</string>
<string name="label_error_whatsapp_not_installed">You have to install WhatsApp to open the chat directly.</string>

</resources>

0 comments on commit 238ca2c

Please sign in to comment.