|
@@ -22,7 +22,10 @@
|
|
|
package com.owncloud.android.files;
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
+import android.content.ActivityNotFoundException;
|
|
|
import android.content.Intent;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.content.pm.ResolveInfo;
|
|
|
import android.net.Uri;
|
|
|
import android.support.v4.app.DialogFragment;
|
|
|
import android.webkit.MimeTypeMap;
|
|
@@ -43,6 +46,8 @@ import com.owncloud.android.ui.dialog.ShareLinkToDialog;
|
|
|
|
|
|
import org.apache.http.protocol.HTTP;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
@@ -88,13 +93,28 @@ public class FileOperationsHelper {
|
|
|
}
|
|
|
|
|
|
Intent chooserIntent;
|
|
|
+ List<ResolveInfo> launchables;
|
|
|
if (intentForGuessedMimeType != null) {
|
|
|
chooserIntent = Intent.createChooser(intentForGuessedMimeType, mFileActivity.getString(R.string.actionbar_open_with));
|
|
|
+ launchables = mFileActivity.getPackageManager().queryIntentActivities(intentForGuessedMimeType, PackageManager.GET_INTENT_FILTERS);
|
|
|
} else {
|
|
|
chooserIntent = Intent.createChooser(intentForSavedMimeType, mFileActivity.getString(R.string.actionbar_open_with));
|
|
|
+ launchables = mFileActivity.getPackageManager().queryIntentActivities(intentForSavedMimeType, PackageManager.GET_INTENT_FILTERS);
|
|
|
}
|
|
|
|
|
|
- mFileActivity.startActivity(chooserIntent);
|
|
|
+ if(launchables != null && launchables.size() > 0) {
|
|
|
+ try {
|
|
|
+ mFileActivity.startActivity(chooserIntent);
|
|
|
+ } catch (ActivityNotFoundException anfe) {
|
|
|
+ Toast.makeText(mFileActivity.getApplicationContext(),
|
|
|
+ R.string.file_list_no_app_for_file_type, Toast.LENGTH_SHORT)
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Toast.makeText(mFileActivity.getApplicationContext(),
|
|
|
+ R.string.file_list_no_app_for_file_type, Toast.LENGTH_SHORT)
|
|
|
+ .show();
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
|