Java Code Examples for android.content.Intent#ACTION_GET_CONTENT

The following examples show how to use android.content.Intent#ACTION_GET_CONTENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntentReceiver.java    From Camera-Roll-Android-App with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    switch (getIntent().getAction()) {
        case "com.android.camera.action.REVIEW":
        case Intent.ACTION_VIEW:
            view(getIntent());
            this.finish();
            break;
        case Intent.ACTION_PICK:
            pick(getIntent());
            break;
        case Intent.ACTION_GET_CONTENT:
            pick(getIntent());
            break;
        case Intent.ACTION_EDIT:
            edit(getIntent());
            break;
        default:
            break;
    }
}
 
Example 2
Source File: IntentHelper.java    From candybar with Apache License 2.0 6 votes vote down vote up
public static int getAction(@Nullable Intent intent) {
    if (intent == null) return ACTION_DEFAULT;
    String action = intent.getAction();
    if (action != null) {
        switch (action) {
            case ACTION_ADW_PICK_ICON:
            case ACTION_TURBO_PICK_ICON:
            case ACTION_LAWNCHAIR_ICONPACK:
            case ACTION_NOVA_LAUNCHER:
            case ACTION_ONEPLUS_PICK_ICON:
            case ACTION_PLUS_HOME:
                return ICON_PICKER;
            case Intent.ACTION_PICK:
            case Intent.ACTION_GET_CONTENT:
                return IMAGE_PICKER;
            case Intent.ACTION_SET_WALLPAPER:
                return WALLPAPER_PICKER;
            default:
                return ACTION_DEFAULT;
        }
    }

    return ACTION_DEFAULT;
}
 
Example 3
Source File: ListWithCustomSetting.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
protected void openCustomValueDialog() {
    if (getEntry().isValueTypeFile()) {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("*/*");
        mAdapter.startActivityForResult(intent, getEntry().mRequestCode);
    }
}
 
Example 4
Source File: ExampleMp4ProcessActivity.java    From AAVT with Apache License 2.0 5 votes vote down vote up
public void onClick(View view){
    switch (view.getId()){
        case R.id.mOpen:
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            //intent.setType(“image/*”);//选择图片
            //intent.setType(“audio/*”); //选择音频
            intent.setType("video/mp4"); //选择视频 (mp4 3gp 是android支持的视频格式)
            //intent.setType(“video/*;image/*”);//同时选择视频和图片
            //intent.setType("*/*");//无类型限制
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, 1);
            break;
        case R.id.mProcess:
            mMp4Processor.startRecord();
            mMp4Processor.open();
            break;
        case R.id.mStop:
            mMp4Processor.stopRecord();
            mMp4Processor.close();
            break;
        case R.id.mPlay:
            Intent v=new Intent(Intent.ACTION_VIEW);
            v.setDataAndType(Uri.parse(tempPath),"video/mp4");
            startActivity(v);
            break;
        default:
            break;
    }
}
 
Example 5
Source File: Util.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
public static void showFileViewer(PreferenceFragment fragment, int requestCode) {
    Intent certIntent = new Intent(Intent.ACTION_GET_CONTENT);
    certIntent.setTypeAndNormalize("*/*");
    try {
        fragment.startActivityForResult(certIntent, requestCode);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "showFileViewer: ", e);
    }
}
 
Example 6
Source File: MainActivity.java    From Aftermath with Apache License 2.0 5 votes vote down vote up
public void startPhotoPicker(View view) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(intent, OTHER_REQUEST);
    }
}
 
Example 7
Source File: FileUtils.java    From secrecy with Apache License 2.0 5 votes vote down vote up
/**
 * Get the Intent for selecting content to be used in an Intent Chooser.
 *
 * @return The intent for opening a file with Intent.createChooser()
 * @author paulburke
 */
public static Intent createGetContentIntent() {
    // Implicitly allow the user to select a particular kind of data
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // The MIME data type filter
    intent.setType("*/*");
    // Only return URIs that can be opened with ContentResolver
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}
 
Example 8
Source File: MainActivity.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        startActivityForResult( Intent.createChooser(intent, "选择文件导入"), FILE_SELECT_CODE);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(this, "请安装文件管理器!",  Toast.LENGTH_SHORT).show();
    }
}
 
Example 9
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
    ((EBrowserActivity) mContext).setmUploadMessage(getCompatCallback(uploadMsg));
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    ((EBrowserActivity) mContext).startActivityForResult(Intent.createChooser(i, "File Chooser"),
            EBrowserActivity.FILECHOOSER_RESULTCODE);
}
 
Example 10
Source File: FileUtils.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get the Intent for selecting content to be used in an Intent Chooser.
 *
 * @return The intent for opening a file with Intent.createChooser()
 * @author paulburke
 */
public static Intent createGetContentIntent() {
    // Implicitly allow the user to select a particular kind of data
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // The MIME data type filter
    intent.setType("*/*");
    // Only return URIs that can be opened with ContentResolver
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}
 
Example 11
Source File: MyWebChromeClient.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
private void openFileChooserImpl(ValueCallback<Uri> uploadMsg) {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    mActivity.startActivityForResult(Intent.createChooser(i, "文件选择"), FILECHOOSER_RESULTCODE);
}
 
Example 12
Source File: MyWebChromeClient.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
private void openFileChooseForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMsgAboveAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mActivity.startActivityForResult(chooserIntent, CODE_FILE_CHOOSE_5);
}
 
Example 13
Source File: FileChooser.java    From MFileChooser with MIT License 5 votes vote down vote up
public void chooseFile(CallbackContext callbackContext) {

        // type and title should be configurable
    	Context context=this.cordova.getActivity().getApplicationContext();
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setClass(context,FileChooserActivity.class);
        
        Intent chooser = Intent.createChooser(intent, "Select File");
        cordova.startActivityForResult(this, chooser, PICK_FILE_REQUEST);
        
        PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
        pluginResult.setKeepCallback(true);
        callback = callbackContext;
        callbackContext.sendPluginResult(pluginResult);
    }
 
Example 14
Source File: Installer2Fragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
private boolean pickFilesWithSaf() {
    Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getContentIntent.setType("*/*");
    getContentIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    startActivityForResult(Intent.createChooser(getContentIntent, getString(R.string.installer_pick_apks)), REQUEST_CODE_GET_FILES);

    return true;
}
 
Example 15
Source File: PickRequest.java    From quickimagepick with Apache License 2.0 5 votes vote down vote up
@SuppressLint("InlinedApi")
@NonNull
private Intent prepareDocumentsIntent(final boolean pAllowMultiple) {

    final Intent docsIntent = new Intent(Intent.ACTION_GET_CONTENT);
    docsIntent.addCategory(Intent.CATEGORY_OPENABLE);
    docsIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, this.mAllowOnlyLocalContent);
    docsIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, pAllowMultiple);

    this.setIntentAllowedMimeTypes(docsIntent);

    return docsIntent;
}
 
Example 16
Source File: QQUtil.java    From android-common-utils with Apache License 2.0 5 votes vote down vote up
public static  void startPickLocaleImage(Activity activity,String title) {
	Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
		intent.setAction(ACTION_OPEN_DOCUMENT);
	} else {
		intent.setAction(Intent.ACTION_GET_CONTENT);
	}
	intent.addCategory(Intent.CATEGORY_OPENABLE);
	intent.setType("image/*");
	activity.startActivityForResult(Intent.createChooser(intent, title), 0);
}
 
Example 17
Source File: WebViewActivity.java    From mattermost-android-classic with Apache License 2.0 5 votes vote down vote up
private Intent createDefaultOpenableIntent() {
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    Intent chooser = createChooserIntent(createCameraIntent(), createCamcorderIntent(),
            createSoundRecorderIntent());
    chooser.putExtra(Intent.EXTRA_INTENT, i);

    return chooser;
}
 
Example 18
Source File: ScannerActivity.java    From YZxing with Apache License 2.0 4 votes vote down vote up
private void goPicture() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_CODE_GET_PIC_URI);
}
 
Example 19
Source File: MainActivity.java    From Android-File-Chooser with GNU General Public License v3.0 4 votes vote down vote up
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
    // Double check that we don't have any existing callbacks
    if (mUploadMessage != null) {
        mUploadMessage.onReceiveValue(null);
    }
    mUploadMessage = filePath;
    Log.e("FileCooserParams => ", filePath.toString());

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
            takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.e(TAG, "Unable to create Image File", ex);
        }

        // Continue only if the File was successfully created
        if (photoFile != null) {
            mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
        } else {
            takePictureIntent = null;
        }
    }

    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    contentSelectionIntent.setType("image/*");

    Intent[] intentArray;
    if (takePictureIntent != null) {
        intentArray = new Intent[]{takePictureIntent};
    } else {
        intentArray = new Intent[2];
    }

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
    startActivityForResult(Intent.createChooser(chooserIntent, "Select images"), 1);

    return true;

}
 
Example 20
Source File: ArtistDetailActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    final ArrayList<Song> songs = songAdapter.getDataSet();
    switch (id) {
        case R.id.action_sleep_timer:
            new SleepTimerDialog().show(getSupportFragmentManager(), "SET_SLEEP_TIMER");
            return true;
        case R.id.action_equalizer:
            NavigationUtil.openEqualizer(this);
            return true;
        case R.id.action_shuffle_artist:
            MusicPlayerRemote.openAndShuffleQueue(songs, true);
            return true;
        case R.id.action_play_next:
            MusicPlayerRemote.playNext(songs);
            return true;
        case R.id.action_add_to_current_playing:
            MusicPlayerRemote.enqueue(songs);
            return true;
        case R.id.action_add_to_playlist:
            AddToPlaylistDialog.create(songs).show(getSupportFragmentManager(), "ADD_PLAYLIST");
            return true;
        case android.R.id.home:
            super.onBackPressed();
            return true;
        case R.id.action_biography:
            if (biographyDialog == null) {
                biographyDialog = new MaterialDialog.Builder(this)
                        .title(artist.getName())
                        .positiveText(android.R.string.ok)
                        .build();
            }
            if (PreferenceUtil.isAllowedToDownloadMetadata(ArtistDetailActivity.this)) { // wiki should've been already downloaded
                if (biography != null) {
                    biographyDialog.setContent(biography);
                    biographyDialog.show();
                } else {
                    Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
                }
            } else { // force download
                biographyDialog.show();
                loadBiography();
            }
            return true;
        case R.id.action_set_artist_image:
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), REQUEST_CODE_SELECT_IMAGE);
            return true;
        case R.id.action_reset_artist_image:
            Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.updating), Toast.LENGTH_SHORT).show();
            CustomArtistImageUtil.getInstance(ArtistDetailActivity.this).resetCustomArtistImage(artist);
            forceDownload = true;
            return true;
        case R.id.action_colored_footers:
            item.setChecked(!item.isChecked());
            setUsePalette(item.isChecked());
            return true;
    }
    return super.onOptionsItemSelected(item);
}