当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_GET_CONTENT属性代码示例

本文整理汇总了Java中android.content.Intent.ACTION_GET_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_GET_CONTENT属性的具体用法?Java Intent.ACTION_GET_CONTENT怎么用?Java Intent.ACTION_GET_CONTENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_GET_CONTENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chooseFile

private void chooseFile() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        try {
            getActivity().startActivityForResult(
                    Intent.createChooser(intent, "Select a File to Upload"),
                    FILE_SELECT_CODE);

        } catch (android.content.ActivityNotFoundException ex) {
            // Potentially direct the user to the Market with a Dialog
            Toast.makeText(getActivity(), "Please install a File Manager.",
                    Toast.LENGTH_SHORT).show();
        }

//        Intent intent = new Intent(getActivity(), NormalFilePickActivity.class);
//        intent.putExtra(Constant.MAX_NUMBER, 1);
//        intent.putExtra(NormalFilePickActivity.SUFFIX, new String[] {"xlsx", "xls", "doc", "docx", "ppt", "pptx", "pdf"});
//        startActivityForResult(intent, Constant.REQUEST_CODE_PICK_FILE);


    }
 
开发者ID:othreecodes,项目名称:Quicksend,代码行数:22,代码来源:CVFragment.java

示例2: pickCsvFile

private void pickCsvFile() {

        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);

        intent.setType("*/*");
        String[] mimetypes = {"text/comma-separated-values", "text/csv"};
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            intent.putExtra(EXTRA_MIME_TYPES, mimetypes);
        }

        startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_file)), REQUEST_CODE_PICK_CSV);
    }
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:13,代码来源:CsvPickerFragment.java

示例3: onRequestPermissionsResult

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
    if (requestCode == MY_PERMISSIONS_REQUEST_CALL_PHONE2)
    {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
        {
            Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(intent,PICK_PHOTO);
        } else
        {
            // Permission Denied
            Toast.makeText(ObjectCardActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show();
        }
    }
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
开发者ID:android-app-development-course,项目名称:fruit,代码行数:18,代码来源:ObjectCardActivity.java

示例4: onCreate

@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;
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:23,代码来源:IntentReceiver.java

示例5: PhotoAppsAdapter

public PhotoAppsAdapter(Context context, File captureFile, int captureCode, int importCode) {
  page = 0;
  this.context = context;
  this.captureFile = captureFile;
  this.captureCode = captureCode;
  this.importCode = importCode;
  packageManager = context.getPackageManager();

  Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", captureFile);
  captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
  //captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(captureFile));

  importIntent = new Intent(Intent.ACTION_GET_CONTENT);
  importIntent.setType("image/jpg");
  importList = packageManager.queryIntentActivities(importIntent, PackageManager.MATCH_DEFAULT_ONLY);
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:17,代码来源:PhotoAppsAdapter.java

示例6: onMenuItemClick

@Override
public boolean onMenuItemClick(MenuItem item) {
    if (item.getItemId() == R.id.action_local) {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("video/*.mp4");
        startActivityForResult(intent, PICK_FILE_REQUEST_CODE);
    } else if (item.getItemId() == R.id.action_toggle) {
        if (previewTimeBarLayout.isShowingPreview()) {
            previewTimeBarLayout.hidePreview();
            exoPlayerManager.stopPreview();
        } else {
            previewTimeBarLayout.showPreview();
            exoPlayerManager.loadPreview(previewTimeBar.getProgress(),
                    previewTimeBar.getDuration());
        }
    } else {
        startActivity(new Intent(this, LocalActivity.class));
    }
    return true;
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:20,代码来源:MainActivity.java

示例7: fromGallery

/**
     * 启动手机相册
     */
    private void fromGallery() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("image/*");
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_NAME)));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            startActivityForResult(intent, GALLERY_KITKAT_REQUEST);
        } else {
            startActivityForResult(intent, GALLERY_REQUEST);
        }

//        Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
//        startActivityForResult(intent, 103);103
    }
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:19,代码来源:SetActivity.java

示例8: onClick

@Override
public void onClick(View v) {
	final int id = v.getId();
	if(id==R.id.capture_scan_photo){
		// 打开手机中的相册
		Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
		innerIntent.setType("image/*");
		Intent wrapperIntent = Intent.createChooser(innerIntent,
				"选择二维码图片");
		this.startActivityForResult(wrapperIntent, REQUEST_CODE);
	}else if(id==R.id.capture_flashlight){
		if (isFlashlightOpen) {
			cameraManager.setTorch(false); // 关闭闪光灯
			isFlashlightOpen = false;
		}
		else {
			cameraManager.setTorch(true); // 打开闪光灯
			isFlashlightOpen = true;
		}
	}
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:21,代码来源:CaptureActivity.java

示例9: chooseImg

private void chooseImg() {
    try {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("image/*");
        intent.putExtra("crop", true);
        intent.putExtra("return-data", true);
        startActivityForResult(intent, LOAD_PIC);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:12,代码来源:UpdateUserInfoFragment.java

示例10: openFileChooserImplForAndroid5

private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = 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, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:MyWebChromeClient.java

示例11: createGetContentIntent

/**
 * 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;
}
 
开发者ID:takyonxxx,项目名称:AndroidSdrRtlTuner,代码行数:15,代码来源:FileUtils.java

示例12: openAlbumC

public void openAlbumC(View v){
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED)
    {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                MY_PERMISSIONS_REQUEST_CALL_PHONE2);
    }
    else {
    Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent,PICK_PHOTO);}
}
 
开发者ID:android-app-development-course,项目名称:fruit,代码行数:14,代码来源:FruitCard.java

示例13: addMedia

public void addMedia()
{
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(WILD_WILD);
    startActivityForResult(Intent.createChooser(intent, null), ADD_MEDIA);
}
 
开发者ID:billthefarmer,项目名称:diary,代码行数:7,代码来源:Diary.java

示例14: selectFile

public static void selectFile(Activity mActivity, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("file/*");
    mActivity.startActivityForResult(intent, requestCode);
}
 
开发者ID:XFY9326,项目名称:CatchSpy,代码行数:6,代码来源:ImportMethod.java

示例15: onShowFileChooser

public boolean onShowFileChooser(
        WebView webView, ValueCallback<Uri[]> filePathCallback,
        FileChooserParams fileChooserParams) {
    if (mFilePathCallback != null) {
        mFilePathCallback.onReceiveValue(null);
    }
    mFilePathCallback = filePathCallback;

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = helper_browser.createImageFile();
            takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
        } catch (IOException e) {
            // Error occurred while creating the File
            Log.e(TAG, "Unable to create Image File", e);
        }
        // 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.setType("*/*");

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

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_share_file));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

    startActivityForResult(chooserIntent, REQUEST_CODE_LOLLIPOP);

    return true;
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:49,代码来源:Fragment_Browser.java


注:本文中的android.content.Intent.ACTION_GET_CONTENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。