android.content.Intent#ACTION_GET_CONTENT源码实例Demo

下面列出了android.content.Intent#ACTION_GET_CONTENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: candybar   文件: IntentHelper.java
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;
}
 
源代码2 项目: Camera-Roll-Android-App   文件: IntentReceiver.java
@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;
    }
}
 
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;
}
 
源代码4 项目: android-common-utils   文件: QQUtil.java
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);
}
 
源代码5 项目: quickimagepick   文件: PickRequest.java
@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;
}
 
源代码6 项目: SAI   文件: Installer2Fragment.java
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;
}
 
源代码7 项目: MFileChooser   文件: FileChooser.java
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);
    }
 
源代码8 项目: BaseProject   文件: MyWebChromeClient.java
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);
}
 
源代码9 项目: CloudReader   文件: MyWebChromeClient.java
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);
}
 
源代码10 项目: revolution-irc   文件: ListWithCustomSetting.java
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);
    }
}
 
源代码11 项目: iGap-Android   文件: FileUtils.java
/**
 * 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;
}
 
源代码12 项目: appcan-android   文件: CBrowserMainFrame.java
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);
}
 
源代码13 项目: nono-android   文件: MainActivity.java
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();
    }
}
 
源代码14 项目: secrecy   文件: FileUtils.java
/**
 * 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;
}
 
源代码15 项目: Aftermath   文件: MainActivity.java
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);
    }
}
 
源代码16 项目: android-testdpc   文件: Util.java
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);
    }
}
 
源代码17 项目: AAVT   文件: ExampleMp4ProcessActivity.java
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;
    }
}
 
源代码18 项目: VinylMusicPlayer   文件: ArtistDetailActivity.java
@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);
}
 
源代码19 项目: Android-File-Chooser   文件: MainActivity.java
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;

}
 
源代码20 项目: YZxing   文件: ScannerActivity.java
private void goPicture() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_CODE_GET_PIC_URI);
}
 
 方法所在类
 同类方法