當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。