本文整理汇总了Java中android.content.Intent.ACTION_OPEN_DOCUMENT属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_OPEN_DOCUMENT属性的具体用法?Java Intent.ACTION_OPEN_DOCUMENT怎么用?Java Intent.ACTION_OPEN_DOCUMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_OPEN_DOCUMENT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importExistingKeyKitKat
/**
* Fires an intent to spin up the "file chooser" UI and select a private key.
*/
@TargetApi(19)
public boolean importExistingKeyKitKat() {
// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
// browser.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones)
intent.addCategory(Intent.CATEGORY_OPENABLE);
// PKCS#8 MIME types aren't widely supported, so we'll try */* fro now.
intent.setType("*/*");
try {
startActivityForResult(intent, REQUEST_CODE_PICK_FILE);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
示例2: chooseFile
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public void chooseFile(Intent dataIntent) {
/* Check for network connectivity */
if (isConnectedToActiveNetwork(this)) {
// if upload was chosen from the app
if (dataIntent == null) {
// Use system file browser
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Choose the file to Upload.."), INTENT_FILE_REQUEST);
} else {
// If Intent received from implicit intent
onActivityResult(INTENT_FILE_REQUEST, RESULT_OK, dataIntent);
}
} else {
/* Show no network dialog */
NoNetworkDialogFragment noNetworkDialogFragment = new NoNetworkDialogFragment();
noNetworkDialogFragment.show(getSupportFragmentManager(), getString(R.string.no_net_dialog_fragment_tag));
}
}
示例3: setFragment
/**
* Override the base class because we need a special treatment for the Movies category,
* that is using the ActionBar list navigation to switch between various fragments
*/
@Override
public void setFragment(String path){
if(mSelectedItemId == ITEM_ID_PROVIDER){
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("video/*");
startActivityForResult(intent, FILE_CHOOSER_ACTIVITY_REQUEST_CODE);
//restore browser
mSelectedItemId = mOldSelectedItemId;
return ;
}
else if (mSelectedItemId == ITEM_ID_MOVIES) {
setupMovieActionBarNavigation(true);
// refresh the category list
}
else {
//default case is no navigation in action bar
((MainActivity)getActivity()).hideSeachView();
setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
// and it is handled by the parent class
super.setFragment(path);
}
}
示例4: OpenFile
public void OpenFile(View view) {
if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) {
// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
// browser.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones)
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Filter to show only images, using the image MIME data type.
// If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
// To search for all documents available via installed storage providers,
// it would be "*/*".
intent.setType("*/*");
startActivityForResult(intent, READ_REQUEST_CODE);
} else {
Intent subActivity = new Intent(MainActivity.this, SelectFileActivity.class);
subActivity.putExtra("action", SelectFileActivity.Actions.SelectFile);
AnimationUtils.startActivityWithScale(this, subActivity, true, SELECT_FILE_CODE, view);
}
}
示例5: selectPictureFromGallery
public void selectPictureFromGallery() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// 设置选择类型为图片类型
intent.setType("image/*");
// 打开图片选择
startActivityForResult(intent, SELECT_GALLERY_PIC);
}
示例6: performFileSearch
private void performFileSearch() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, READ_REQUEST_CODE);
}
示例7: openFileBrowser
private void openFileBrowser()
{
String returnVal = new String();
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); //START INTENT TO CHOOSE FILE USING DEVICE' DEFAULT FILE BROWSER
intent.addCategory(Intent.CATEGORY_OPENABLE);//SHOW ONLY FILES THAT CAN BE OPENED
intent.setType("text/plain"); //only plain txt file can be accessed
startActivityForResult(intent, READ_REQUEST_CODE);
}
示例8: importBookmarks
/**
* This method starts open document system activity.
* @param activity
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void importBookmarks(Activity activity) {
// choose a file via the system's file browser
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// show only results that can be "opened", such as a file
intent.addCategory(Intent.CATEGORY_OPENABLE);
// filter to show only plain text
intent.setType(MIME_TYPE);
activity.startActivityForResult(intent, READ_REQUEST_CODE);
}
示例9: pickFromGallery
public void pickFromGallery(View v) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("image/*"),
REQUEST_PICK_IMAGE);
} else {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
startActivityForResult(intent, REQUEST_KITKAT_PICK_IMAGE);
}
}
示例10: performFileSearch
@TargetApi(Build.VERSION_CODES.KITKAT)
private void performFileSearch() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
startActivityForResult(intent, READ_REQUEST_CODE);
}
示例11: moveToGallery
protected void moveToGallery() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("video/mp4");
startActivityForResult(intent, 1000);
}
示例12: addPicture
private void addPicture() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
startActivityForResult(intent, SELECT_IMAGE);
}
示例13: openSAF
public static void openSAF(Activity context) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
context.startActivityForResult(intent, 42);
}