Example usage for android.content Intent CATEGORY_OPENABLE

List of usage examples for android.content Intent CATEGORY_OPENABLE

Introduction

In this page you can find the example usage for android.content Intent CATEGORY_OPENABLE.

Prototype

String CATEGORY_OPENABLE

To view the source code for android.content Intent CATEGORY_OPENABLE.

Click Source Link

Document

Used to indicate that an intent only wants URIs that can be opened with ContentResolver#openFileDescriptor(Uri,String) .

Usage

From source file:com.android.mms.ui.MessageUtils.java

public static void selectAudio(Activity activity, int requestCode) {
    // / M: Code analyze 027, new feature, to improve the performance of
    // Mms. @{/*w  ww  .j  a  v  a2  s.  co  m*/
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(MmsContentType.AUDIO_UNSPECIFIED);
    String[] mimeTypess = new String[] { MmsContentType.AUDIO_UNSPECIFIED, MmsContentType.AUDIO_OGG,
            "application/x-ogg" };
    intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypess);
    if (FeatureOption.MTK_DRM_APP) {
        intent.putExtra(OmaDrmStore.DrmIntentExtra.EXTRA_DRM_LEVEL, OmaDrmStore.DrmIntentExtra.LEVEL_SD);
    }
    /// @}
    activity.startActivityForResult(intent, requestCode);
}

From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    //      if (this.tocDialog == null) {
    //         initTocDialog();
    //      }//from   w  w  w  .  ja v a  2 s  . co  m

    MenuItem nightMode = menu.findItem(R.id.profile_night);
    MenuItem dayMode = menu.findItem(R.id.profile_day);

    MenuItem showToc = menu.findItem(R.id.show_toc);
    //      MenuItem sync = menu.findItem(R.id.manual_sync);

    showToc.setEnabled(true);
    //      sync.setEnabled(config.isSyncEnabled());

    if (config.getColourProfile() == ColourProfile.DAY) {
        dayMode.setVisible(false);
        nightMode.setVisible(true);
    } else {
        dayMode.setVisible(true);
        nightMode.setVisible(false);
    }

    // Only show open file item if we have a file manager installed
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("file/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    if (!isIntentAvailable(this, intent)) {
        //         menu.findItem(R.id.open_file).setVisible(false);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    return super.onPrepareOptionsMenu(menu);
}

From source file:info.tellmetime.TellmetimeActivity.java

public void pickImage(View view) {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_CODE);
}

From source file:org.drrickorang.loopback.LoopbackActivity.java

/**
 * Save five files: one .png file for a screenshot on the main activity, one .wav file for
 * the plot displayed on the main activity, one .txt file for storing various test results, one
 * .txt file for storing recorder buffer period data, and one .txt file for storing player
 * buffer period data./*from w w  w .j av  a  2 s.c o  m*/
 */
public void onButtonSave(View view) {
    if (!isBusy()) {
        //create filename with date
        String date = mCurrentTime; // the time the plot is acquired
        //String micSource = getApp().getMicSourceString(getApp().getMicSource());
        String fileName = "loopback_" + date;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TITLE, fileName + ".txt"); //suggested filename
            startActivityForResult(intent, SAVE_TO_TXT_REQUEST);

            Intent intent2 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent2.addCategory(Intent.CATEGORY_OPENABLE);
            intent2.setType("image/png");
            intent2.putExtra(Intent.EXTRA_TITLE, fileName + ".png"); //suggested filename
            startActivityForResult(intent2, SAVE_TO_PNG_REQUEST);

            //sometimes ".wav" will be added automatically, sometimes not
            Intent intent3 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent3.addCategory(Intent.CATEGORY_OPENABLE);
            intent3.setType("audio/wav");
            intent3.putExtra(Intent.EXTRA_TITLE, fileName + ".wav"); //suggested filename
            startActivityForResult(intent3, SAVE_TO_WAVE_REQUEST);

            fileName = "loopback_" + date + "_recorderBufferPeriod";
            Intent intent4 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent4.addCategory(Intent.CATEGORY_OPENABLE);
            intent4.setType("text/plain");
            intent4.putExtra(Intent.EXTRA_TITLE, fileName + ".txt");
            startActivityForResult(intent4, SAVE_RECORDER_BUFFER_PERIOD_TO_TXT_REQUEST);

            fileName = "loopback_" + date + "_playerBufferPeriod";
            Intent intent5 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent5.addCategory(Intent.CATEGORY_OPENABLE);
            intent5.setType("text/plain");
            intent5.putExtra(Intent.EXTRA_TITLE, fileName + ".txt");
            startActivityForResult(intent5, SAVE_PLAYER_BUFFER_PERIOD_TO_TXT_REQUEST);
        } else {
            saveAllTo(fileName);
        }
    } else {
        showToast("Test in progress... please wait");
    }
}

From source file:us.theparamountgroup.android.inventory.EditorActivity.java

public void openImageSelector(View view) {
    Intent intent;/*from   w  ww  . j av  a2 s  .c o m*/
    Log.e(LOG_TAG, "While is set and the ifs are worked through.");

    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
    } else {
        intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
    }

    Log.e(LOG_TAG, "Check write to external permissions");

    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}

From source file:com.digitalarx.android.ui.activity.FileDisplayActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog = null;/*w  w w  .  j av a 2 s.  c o m*/
    AlertDialog.Builder builder;
    switch (id) {
    case DIALOG_SHORT_WAIT: {
        ProgressDialog working_dialog = new ProgressDialog(this);
        working_dialog.setMessage(getResources().getString(R.string.wait_a_moment));
        working_dialog.setIndeterminate(true);
        working_dialog.setCancelable(false);
        dialog = working_dialog;
        break;
    }
    case DIALOG_CHOOSE_UPLOAD_SOURCE: {

        String[] items = null;

        String[] allTheItems = { getString(R.string.actionbar_upload_files),
                getString(R.string.actionbar_upload_from_apps),
                getString(R.string.actionbar_failed_instant_upload) };

        String[] commonItems = { getString(R.string.actionbar_upload_files),
                getString(R.string.actionbar_upload_from_apps) };

        if (InstantUploadActivity.IS_ENABLED)
            items = allTheItems;
        else
            items = commonItems;

        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.actionbar_upload);
        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                if (item == 0) {
                    // if (!mDualPane) {
                    Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class);
                    action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, FileDisplayActivity.this.getAccount());
                    startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
                    // } else {
                    // TODO create and handle new fragment
                    // LocalFileListFragment
                    // }
                } else if (item == 1) {
                    Intent action = new Intent(Intent.ACTION_GET_CONTENT);
                    action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
                    startActivityForResult(
                            Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                            ACTION_SELECT_CONTENT_FROM_APPS);
                } else if (item == 2 && InstantUploadActivity.IS_ENABLED) {
                    Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class);
                    action.putExtra(FileUploader.KEY_ACCOUNT, FileDisplayActivity.this.getAccount());
                    startActivity(action);
                }
            }
        });
        dialog = builder.create();
        break;
    }
    case DIALOG_CERT_NOT_SAVED: {
        builder = new AlertDialog.Builder(this);
        builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved));
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            };
        });
        dialog = builder.create();
        break;
    }
    default:
        dialog = null;
    }

    return dialog;
}

From source file:cn.kangeqiu.kq.activity.ChatActivity.java

/**
 * //from   ww w .j ava2 s.co m
 */
private void selectFileFromLocal() {
    Intent intent = null;
    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);

    } else {
        intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, REQUEST_CODE_SELECT_FILE);
}

From source file:com.fa.mastodon.activity.ComposeActivity.java

private void initiateMediaPicking() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        intent.setType("image/* video/*");
    } else {//from   w  w w.  jav a 2s.  c  o  m
        String[] mimeTypes = new String[] { "image/*", "video/*" };
        intent.setType("*/*");
        intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
    }
    startActivityForResult(intent, MEDIA_PICK_RESULT);
}

From source file:com.pimp.companionforband.activities.main.MainActivity.java

private void pickFromGallery() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN // Permission was added in API Level 16
            && ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        requestPermission(Manifest.permission.READ_EXTERNAL_STORAGE,
                getString(R.string.permission_read_storage_rationale), REQUEST_STORAGE_READ_ACCESS_PERMISSION);
    } else {/*from  w  w w . jav  a 2s  .c  o  m*/
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        startActivityForResult(Intent.createChooser(intent, getString(R.string.label_select_picture)),
                REQUEST_SELECT_PICTURE);
    }
}

From source file:com.hdu.tx.aschool.ui.activity.ChatActivity.java

/**
 * //from  www  .ja v a  2 s. co m
 */
private void selectFileFromLocal() {
    Intent intent = null;
    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
    } else {
        intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, REQUEST_CODE_SELECT_FILE);
}