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.davidmascharka.lips.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
    case R.id.action_reset:
        resetDatafile();//  w  ww . ja v a  2s  .c o  m
        break;
    case R.id.action_select_building:
        showSelectBuildingDialog();
        break;
    case R.id.action_select_room_size:
        new SelectRoomSizeDialogFragment().show(getSupportFragmentManager(), "RoomSize");
        break;
    case R.id.action_display_map:
        displayMap = !displayMap;
        item.setChecked(displayMap);
        ((GridView) findViewById(R.id.gridView)).setDisplayMap(displayMap);
        break;
    case R.id.action_select_map:
        // Launch an intent to select the map the user wants to display
        Intent selectMapIntent = new Intent();
        selectMapIntent.setAction(Intent.ACTION_GET_CONTENT);
        selectMapIntent.setType("image/*");
        selectMapIntent.addCategory(Intent.CATEGORY_OPENABLE);

        if (selectMapIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(selectMapIntent, GET_MAP_REQUEST);
        }
        break;
    case R.id.action_start_tracker:
        Intent intent = new Intent(this, TrackerActivity.class);
        startActivity(intent);
        break;
    default:
        super.onOptionsItemSelected(item);
        break;
    }
    return true;
}

From source file:com.buddi.client.dfu.DfuActivity.java

private void openFileChooser() {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(mFileTypeTmp == DfuService.TYPE_AUTO ? DfuService.MIME_TYPE_ZIP : DfuService.MIME_TYPE_HEX);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (intent.resolveActivity(getPackageManager()) != null) {
        // file browser has been found on the device
        startActivityForResult(intent, SELECT_FILE_REQ);
    } else {/*from w w  w .j a v  a 2 s. com*/
        // there is no any file browser app, let's try to download one
        final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
        final ListView appsList = (ListView) customView.findViewById(android.R.id.list);
        appsList.setAdapter(new FileBrowserAppsAdapter(this));
        appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        appsList.setItemChecked(0, true);
        new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        dialog.dismiss();
                    }
                }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        final int pos = appsList.getCheckedItemPosition();
                        if (pos >= 0) {
                            final String query = getResources()
                                    .getStringArray(R.array.dfu_app_file_browser_action)[pos];
                            final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
                            startActivity(storeIntent);
                        }
                    }
                }).show();
    }
}

From source file:org.safegees.safegees.gui.view.PrincipalMapActivity.java

public void pickImage(View View) {
    //pickImage(v);
    Log.i("Picked image", "true");
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_IMAGE_CODE);
}

From source file:com.xxjwd.chat.ChatActivity.java

 /**
 * //from  ww w . j  a  v  a  2  s .  c  om
 */
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:org.asnelt.derandom.MainActivity.java

/**
 * Starts an activity for selecting an input file.
 *///from  w  w w  .  ja va 2  s . co  m
private void selectTextFile() {
    String fileSelectorTitle = getResources().getString(R.string.file_selector_title);
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(FILE_MIME_TYPE);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    try {
        startActivityForResult(Intent.createChooser(intent, fileSelectorTitle), FILE_REQUEST_CODE);
    } catch (android.content.ActivityNotFoundException e) {
        processingFragment.resetInputUri();
        onFileInputAborted();
    }
}

From source file:app.view.chat.ChatActivity.java

/**
 * //from w w  w . ja  v  a2 s .  com
 */
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);
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java

private void onSelectedChangeImage() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_IMAGE);
}

From source file:com.easemob.ui.ChatActivity.java

/**
 * /*from w w  w  . ja  va2s  .c om*/
 */
private void selectFileFromLocal() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_CODE_SELECT_FILE);
}

From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java

/**
 * To savge a document by its path.<br/>
 *
 * @param path the file path to share/*from  w  w w . j ava2 s  .c o m*/
 */
private void saveDocument(String path) {
    Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(
            MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(path)));
    startActivityForResult(intent, ACTION_SAVE_DOCUMENT);
}

From source file:com.smp.musicspeed.MainActivity.java

private Intent createAudioContentIntent() {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("audio/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    // intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    return intent;
}