Java Code Examples for android.content.Intent.ACTION_CHOOSER

The following are Jave code examples for showing how to use ACTION_CHOOSER of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: MyWebChromeClient.java   View Source Code Vote up 6 votes
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);
}
 
Example 2
Project: COEP-Moodle-via-Webview   File: Moodle.java   View Source Code Vote up 6 votes
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
    // Double check that we don't have any existing callbacks
    if (mFilePathCallback != null) {
        mFilePathCallback.onReceiveValue(null);
    }
    mFilePathCallback = filePath;

    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.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, "File Chooser");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

    startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

    return true;

}
 
Example 3
Project: MyDemo   File: MyWebChromeClient.java   View Source Code Vote up 6 votes
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);
}
 
Example 4
Project: RNLearn_Project1   File: ShareTestCase.java   View Source Code Vote up 6 votes
public void testShowBasicShareDialog() {
  final WritableMap content = new WritableNativeMap();
  content.putString("message", "Hello, ReactNative!");
  final WritableMap options = new WritableNativeMap();

  IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CHOOSER);
  intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
  ActivityMonitor monitor = getInstrumentation().addMonitor(intentFilter, null, true);

  getTestModule().showShareDialog(content, options);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  assertEquals(1, monitor.getHits());
  assertEquals(1, mRecordingModule.getOpened());
  assertEquals(0, mRecordingModule.getErrors());

}
 
Example 5
Project: RNLearn_Project1   File: ShareTestCase.java   View Source Code Vote up 6 votes
public void testShowBasicShareDialog() {
  final WritableMap content = new WritableNativeMap();
  content.putString("message", "Hello, ReactNative!");
  final WritableMap options = new WritableNativeMap();

  IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CHOOSER);
  intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
  ActivityMonitor monitor = getInstrumentation().addMonitor(intentFilter, null, true);

  getTestModule().showShareDialog(content, options);

  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  assertEquals(1, monitor.getHits());
  assertEquals(1, mRecordingModule.getOpened());
  assertEquals(0, mRecordingModule.getErrors());

}
 
Example 6
Project: ClouldReader   File: MyWebChromeClient.java   View Source Code Vote up 5 votes
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);
}
 
Example 7
Project: GankReader   File: MyWebChromeClient.java   View Source Code Vote up 5 votes
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);
}
 
Example 8
Project: EasyReader   File: MyWebChromeClient.java   View Source Code Vote up 5 votes
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);
}
 
Example 9
Project: Kids-Portal-Android   File: Fragment_Browser.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: youkes_browser   File: BrowserActivity.java   View Source Code Vote up 5 votes
@Override
public void showFileChooser(ValueCallback<Uri[]> filePathCallback) {
	if (mFilePathCallback != null) {
		mFilePathCallback.onReceiveValue(null);
	}
	mFilePathCallback = filePathCallback;

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

	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, "Image Chooser");
	chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

	mActivity.startActivityForResult(chooserIntent, 1);
}
 
Example 11
Project: Xndroid   File: BrowserActivity.java   View Source Code Vote up 5 votes
@Override
public void showFileChooser(ValueCallback<Uri[]> filePathCallback) {
    if (mFilePathCallback != null) {
        mFilePathCallback.onReceiveValue(null);
    }
    mFilePathCallback = filePathCallback;

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = Utils.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.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, "Image Chooser");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

    startActivityForResult(chooserIntent, 1);
}
 
Example 12
Project: browser   File: BrowserActivity.java   View Source Code Vote up 4 votes
@Override
public void showFileChooser(ValueCallback<Uri[]> filePathCallback) {
	if (mFilePathCallback != null) {
		mFilePathCallback.onReceiveValue(null);
	}
	mFilePathCallback = filePathCallback;

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

	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, "Image Chooser");
	chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

	mActivity.startActivityForResult(chooserIntent, 1);
}
 
Example 13
Project: PaoMovie   File: MyWebChromeClient.java   View Source Code Vote up 4 votes
private Intent createChooserIntent(Intent... list) {
	Intent chooser = new Intent(Intent.ACTION_CHOOSER);
	chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, list);
	chooser.putExtra(Intent.EXTRA_TITLE, "File Chooser");
	return chooser;
}