diff --git a/res/values/strings.xml b/res/values/strings.xml index 5f2802206c..00f010087a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -37,6 +37,9 @@ Incoming SMS Disabled Touch to make TextSecure your default SMS app + + Can\'t find an app to select media. + Picture diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index d1dedc6fb5..fdcf5ccbdc 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -17,13 +17,16 @@ package org.thoughtcrime.securesms.mms; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; +import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.Toast; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.BitmapDecodingException; @@ -31,6 +34,7 @@ import org.thoughtcrime.securesms.util.BitmapDecodingException; import java.io.IOException; public class AttachmentManager { + private final static String TAG = AttachmentManager.class.getSimpleName(); private final Context context; private final View attachmentView; @@ -101,16 +105,26 @@ public class AttachmentManager { } private static void selectMediaType(Activity activity, String type, int requestCode) { - final Intent intent; + final Intent intent = new Intent(); + intent.setType(type); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); - } else { - intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setAction(Intent.ACTION_OPEN_DOCUMENT); + try { + activity.startActivityForResult(intent, requestCode); + return; + } catch (ActivityNotFoundException anfe) { + Log.w(TAG, "couldn't complete ACTION_OPEN_DOCUMENT, no activity found. falling back."); + } } - intent.setType(type); - activity.startActivityForResult(intent, requestCode); + intent.setAction(Intent.ACTION_GET_CONTENT); + try { + activity.startActivityForResult(intent, requestCode); + } catch (ActivityNotFoundException anfe) { + Log.w(TAG, "couldn't complete ACTION_GET_CONTENT intent, no activity found. falling back."); + Toast.makeText(activity, R.string.AttachmentManager_cant_open_media_selection, Toast.LENGTH_LONG).show(); + } } private class RemoveButtonListener implements View.OnClickListener {