X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/fe5b6aa4a81d1878f4b5ad610cb9141e86630b1a..8f0ea82efd778f65c1ccbfcb94b9bd7a2cc2564c:/src/com/owncloud/android/files/FileOperationsHelper.java?ds=inline diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 57b766ec..845eab7f 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -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 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"); @@ -125,7 +145,7 @@ public class FileOperationsHelper { } } - + public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) { if (file != null) {