List of usage examples for android.content Intent ACTION_GET_CONTENT
String ACTION_GET_CONTENT
To view the source code for android.content Intent ACTION_GET_CONTENT.
Click Source Link
From source file:com.dena.app.bootloadhid.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mUri = getArguments().getParcelable("uri"); setHasOptionsMenu(true);// www .j av a 2 s. com View rootView = inflater.inflate(R.layout.fragment_main, container, false); mHandler = new Handler(); mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); mProgressBar.setScaleY(3f); rootView.findViewById(R.id.buttonPick).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); startActivityForResult(intent, 0); } }); mLogcatTextView = (TextView) rootView.findViewById(R.id.logcat); mLogcatScrollView = (ScrollView) rootView.findViewById(R.id.scrollView); mSharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); mFileNameView = (TextView) rootView.findViewById(R.id.textFile); mInstructions1View = (TextView) rootView.findViewById(R.id.instructions1); mAlertDialog = new AlertDialog.Builder(getContext()).setCancelable(false) .setTitle(getResources().getString(R.string.app_name)).create(); if (null != mUri) { setFilePath(mUri.getPath()); } startLogcat(); createWriter(); return rootView; }
From source file:org.kde.kdeconnect.Plugins.SharePlugin.SendFileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDeviceId = getIntent().getStringExtra("deviceId"); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try {/* w w w . j a v a 2 s . c o m*/ startActivityForResult(Intent.createChooser(intent, getString(R.string.send_files)), Activity.RESULT_FIRST_USER); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(this, R.string.no_file_browser, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:com.manning.androidhacks.hack035.MainActivity.java
public void onPickBoth(View v) { Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); pickIntent.setType("image/*"); Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent chooserIntent = Intent.createChooser(pickIntent, getString(R.string.activity_main_pick_both)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent }); startActivityForResult(chooserIntent, PICK_OR_TAKE_PICTURE); }
From source file:org.opendatakit.survey.android.activities.MediaChooseAudioActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); if (extras != null) { appName = extras.getString(APP_NAME); uriFragmentNewFileBase = extras.getString(URI_FRAGMENT_NEW_FILE_BASE); }/*from w w w. j a va 2 s. c om*/ if (savedInstanceState != null) { appName = savedInstanceState.getString(APP_NAME); uriFragmentNewFileBase = savedInstanceState.getString(URI_FRAGMENT_NEW_FILE_BASE); } if (appName == null) { throw new IllegalArgumentException("Expected " + APP_NAME + " key in intent bundle. Not found."); } if (uriFragmentNewFileBase == null) { throw new IllegalArgumentException( "Expected " + URI_FRAGMENT_NEW_FILE_BASE + " key in intent bundle. Not found."); } Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType(MEDIA_CLASS + "*"); try { startActivityForResult(i, ACTION_CODE); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.activity_not_found, Intent.ACTION_GET_CONTENT + " " + MEDIA_CLASS), Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } }
From source file:com.github.barteksc.sample.PDFViewActivity.java
void launchPicker() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("application/pdf"); try {//from www.jav a2s.c o m startActivityForResult(intent, REQUEST_CODE); } catch (ActivityNotFoundException e) { //alert user that file manager not working Toast.makeText(this, R.string.toast_pick_file_error, Toast.LENGTH_SHORT).show(); } }
From source file:com.synox.android.ui.dialog.UploadSourceDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getTheme()); builder.setTitle(R.string.actionbar_upload); builder.setItems(allTheItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount()); getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES); } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }/*from w ww . j a v a2 s . c om*/ getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS); } } }); return builder.create(); }
From source file:com.repay.android.adddebt.ChoosePersonFragment.java
private void showAddFriendDialog() { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.fragment_addfriend_dialogtitle); dialog.setItems(new CharSequence[] { "Add From Contacts", "Add A Name" }, new DialogInterface.OnClickListener() { @Override/*w w w .ja v a 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { if (which == 0) { Intent pickContactIntent = new Intent(Intent.ACTION_GET_CONTENT); pickContactIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); getActivity().startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } else if (which == 1) { addFriendByName(); } } }); dialog.show(); }
From source file:stepic.stepic.BaseMapsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutId());//from ww w . j ava 2 s.c o m setUpMap(); Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE"); Intent gallIntent = new Intent(Intent.ACTION_GET_CONTENT); gallIntent.setType("image/*"); info = new ArrayList<ResolveInfo>(); yourIntentsList = new ArrayList<Intent>(); PackageManager packageManager = BaseMapsActivity.this.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(camIntent, 0); for (ResolveInfo res : listCam) { final Intent finalIntent = new Intent(camIntent); finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); yourIntentsList.add(finalIntent); info.add(res); } List<ResolveInfo> listGall = packageManager.queryIntentActivities(gallIntent, 0); for (ResolveInfo res : listGall) { final Intent finalIntent = new Intent(gallIntent); finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); yourIntentsList.add(finalIntent); info.add(res); } // android.support.v7.app.ActionBar actionBar = getSupportActionBar(); // actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff"))); // actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff"))); //Navigation Drawer Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Drawable drawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.add); toolbar.setOverflowIcon(drawable); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mHandler = new Handler(); Button add = (Button) findViewById(R.id.add); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent tmp = new Intent(Intent.ACTION_PICK); tmp.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE); startActivityForResult(tmp, PICK_FROM_ALBUM); } }); // runOnUiThread(new Runnable() { // @Override // public void run() { // mProgressDialog = ProgressDialog.show(BaseMapsActivity.this, "", " .", true); // mHandler.postDelayed(new Runnable() { // @Override // public void run() { // try { // if (mProgressDialog != null && mProgressDialog.isShowing()) { // mProgressDialog.dismiss(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // }, 1000); // } // // }); }
From source file:net.i2p.android.wizard.ui.I2PB64DestinationFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_wizard_page_single_text_field_picker, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); ((TextView) rootView.findViewById(R.id.wizard_text_field_desc)).setText(mPage.getDesc()); Button b = (Button) rootView.findViewById(R.id.wizard_text_field_pick); b.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("text/plain"); i.addCategory(Intent.CATEGORY_OPENABLE); try { startActivityForResult(Intent.createChooser(i, "Select B64 file"), REQUEST_DESTINATION_FILE); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "Please install a File Manager.", Toast.LENGTH_SHORT).show(); }//from ww w .j a va 2s.c o m } }); mFieldView = ((TextView) rootView.findViewById(R.id.wizard_text_field)); mFieldView.setHint(mPage.getTitle()); if (mPage.getData().getString(Page.SIMPLE_DATA_KEY) != null) mFieldView.setText(mPage.getData().getString(Page.SIMPLE_DATA_KEY)); else if (mPage.getDefault() != null) { mFieldView.setText(mPage.getDefault()); mPage.getData().putString(Page.SIMPLE_DATA_KEY, mPage.getDefault()); } mFeedbackView = (TextView) rootView.findViewById(R.id.wizard_text_field_feedback); return rootView; }
From source file:com.cerema.cloud2.ui.dialog.UploadSourceDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.actionbar_upload); builder.setItems(allTheItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount()); //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // this flow seems broken; // Actionbarsherlock, maybe? getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES); } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }/*from w w w. j ava 2s . c o m*/ getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS); } } }); return builder.create(); }