diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java b/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java index 201de691bf113fe6d1731987c89d3be2bdfbe768..c4ba053af68033f794624ae443b8b3eb8fa0de5d 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java +++ b/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java @@ -12,6 +12,7 @@ package org.openhab.habdroid.ui; import android.app.AlertDialog; import android.app.Dialog; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -59,6 +60,7 @@ import android.view.View; import android.view.ViewStub; import android.view.WindowManager; import android.widget.ProgressBar; +import android.widget.Toast; import org.json.JSONArray; import org.json.JSONException; @@ -1004,7 +1006,17 @@ public class OpenHABMainActivity extends AppCompatActivity implements speechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1); speechIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, openhabPendingIntent); - startActivity(speechIntent); + try { + startActivity(speechIntent); + } catch (ActivityNotFoundException speechRecognizerNotFoundException) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=com.google.android.googlequicksearchbox"))); + } catch (ActivityNotFoundException appStoreNotFoundException) { + Toast.makeText(this, R.string.error_no_app_store_found, + Toast.LENGTH_LONG).show(); + } + } } public void showRefreshHintSnackbarIfNeeded() { diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml index 45a4ff8e51fe7b562c744c3cf17762943b38e454..da2c1f821b00f89103df5538b218c4200cdc13ec 100644 --- a/mobile/src/main/res/values/strings.xml +++ b/mobile/src/main/res/values/strings.xml @@ -103,6 +103,7 @@ <string name="error_http_code_511">Network authentication is required (HTTP response code 511)</string> <string name="error_about_no_conn">Error while fetching openHAB server information</string> <string name="error_openhab_offline">Your openHAB server is offline while the cloud instance is running</string> + <string name="error_no_app_store_found">No app store found to install voice recognizer app</string> <string name="title_activity_openhabwritetag">Write NFC tag</string> <string name="title_activity_libraries">Used libraries</string> <string name="info_write_tag">Touch the tag and keep it close until the confirmation message appear</string>