List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT
String ACTION_OPEN_DOCUMENT
To view the source code for android.content Intent ACTION_OPEN_DOCUMENT.
Click Source Link
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.SafeProfileFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.safe_profile, container); // retrieve text and image from main activity imgbut = (ImageView) v.findViewById(R.id.profImg); // profile img whoText = (TextView) v.findViewById(R.id.profName); // profile name email = (TextView) v.findViewById(R.id.safe_profile_email); slogan = (TextView) v.findViewById(R.id.safe_profile_slogan); device = (TextView) v.findViewById(R.id.safe_profile_device); Intent i = getActivity().getIntent(); Bundle b = i.getExtras();/*w ww.j a va2 s . com*/ whoStr = b.getString("who"); safe_gidh = b.getString(Safe.P_SAFE_GIDH); safe_lid = b.getString(Safe.P_SAFE_LID); // safe_id = b.getInt(Safe.P_SAFE_ID) + 1; whoText.setText(whoStr); peer = D_Peer.getPeerByLID(safe_lid, true, false); boolean gotIcon = false; try { byte[] icon = peer.getIcon(); if (icon != null) { Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length - 1); imgbut.setImageBitmap(bmp); gotIcon = true; } } catch (Exception e) { e.printStackTrace(); } if (!gotIcon) { int imgPath = Integer.parseInt(b.getString("profImg")); Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); imgbut.setImageBitmap(bmp); } imgbut.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { byte[] icon = peer.getIcon(); if (icon != null) { ImageFragment fragment = ImageFragment.newInstance(icon); FragmentManager fm = getActivity().getSupportFragmentManager(); fragment.show(fm, "icon"); } if (icon == null) { int imgPath = R.drawable.placeholder; Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); icon = PhotoUtil.BitmapToByteArray(bmp, 100); ImageFragment fragment = ImageFragment.newInstance(icon); FragmentManager fm = getActivity().getSupportFragmentManager(); fragment.show(fm, "icon"); } } }); email.setText(peer.getEmail()); slogan.setText(peer.getSlogan()); String instances = null; String contacts_Date = null; String sync_Date = null; for (String _inst : peer._instances.keySet()) { String contact = Encoder.getGeneralizedTime(peer._instances.get(_inst).get_last_contact_date()); String sync = peer._instances.get(_inst).get_last_sync_date_str(); if (contact == null) contact = Util.__("NEVER"); if (sync == null) sync = Util.__("NEVER"); if (instances == null) { instances = _inst; contacts_Date = contact; sync_Date = sync; } else { instances += ", " + _inst; contacts_Date += ", " + contact; sync_Date += ", " + sync; } } device.setText(Util.getStringNonNullUnique(peer.getInstance()) + " / {" + instances + "}"); if (peer.getSK() != null) { ipAddress = (TextView) v.findViewById(R.id.safe_profile_ip); ipAddress.setText("Known Secret Key"); setProfilePhoto = (Button) v.findViewById(R.id.safe_profile_set_profile_photo); setProfilePhoto.setVisibility(View.VISIBLE); setProfilePhoto.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT < 19) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, SELECT_PROFILE_PHOTO); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); startActivityForResult(intent, SELECT_PPROFILE_PHOTO_KITKAT); } } }); } else { lastContact = (TextView) v.findViewById(R.id.safe_profile_last_contact); lastContact.setText(contacts_Date);//peer.getLastSyncDate(safe_lid)); ipAddress = (TextView) v.findViewById(R.id.safe_profile_ip); ipAddress.setText(sync_Date); /* * hideThisSafe = (Switch) * v.findViewById(R.id.switch_hide_this_safe); * hideThisSafe.setVisibility(View.VISIBLE); * * if (peer.getHidden() == false) hideThisSafe.setChecked(false); * else hideThisSafe.setChecked(true); * * hideThisSafe .setOnCheckedChangeListener(new * OnCheckedChangeListener() { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setHidden(peer, * true); peer.storeRequest(); peer.releaseReference(); } else { * D_Peer.setHidden(peer, false); peer.storeRequest(); * peer.releaseReference(); } * * } }); * * resetLastSyncDate = (Button) v * .findViewById(R.id.button_reset_LastSyncDate); * resetLastSyncDate.setVisibility(View.VISIBLE); * resetLastSyncDate.setOnClickListener(new OnClickListener() { * * @Override public void onClick(View v) { peer = * D_Peer.getPeerByPeer_Keep(peer); peer.setLastSyncDate(null); * peer.storeRequest(); peer.releaseReference(); * * for (D_PeerInstance i : peer._instances.values()) { Calendar date * = i.get_last_sync_date(); Log.i("last_sync_date", * "last sync date: " + date); } } }); */ sendMsg = (Button) v.findViewById(R.id.button_send_msg); sendMsg.setVisibility(View.VISIBLE); sendMsg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(); myIntent.setClass(getActivity(), Chat.class); // pass data to chat myIntent.putExtra("who", whoStr); // myIntent.putExtra(Safe.P_SAFE_ID, safe_id); myIntent.putExtra(Safe.P_SAFE_LID, safe_lid); myIntent.putExtra(Safe.P_SAFE_GIDH, safe_gidh); myIntent.putExtra("profImg", String.valueOf(R.drawable.placeholder)); startActivity(myIntent); } }); /* * // set up switch access accessIt = (Switch) * v.findViewById(R.id.switch_access); * accessIt.setVisibility(View.VISIBLE); if (peer.getUsed() == true) * accessIt.setChecked(true); if (peer.getUsed() == false) * accessIt.setChecked(false); * * accessIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setUsed(peer, true); * } else { D_Peer.setUsed(peer, false); } } }); * * // set up switch block blockIt = (Switch) * v.findViewById(R.id.switch_block); * blockIt.setVisibility(View.VISIBLE); if (peer.getBlocked() == * true) blockIt.setChecked(true); if (peer.getBlocked() == false) * blockIt.setChecked(false); * * blockIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setBlocked(peer, * true); } else { D_Peer.setBlocked(peer, false); } } }); * * // set up switch serve serveIt = (Switch) * v.findViewById(R.id.switch_serve); * serveIt.setVisibility(View.VISIBLE); * * if (peer.getUsed() == true) serveIt.setChecked(true); if * (peer.getUsed() == false) serveIt.setChecked(false); * * serveIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setUsed(peer, true); * peer.storeRequest(); peer.releaseReference(); } else { * D_Peer.setUsed(peer, false); peer.storeRequest(); * peer.releaseReference(); } } }); */ } return super.onCreateView(inflater, container, savedInstanceState); }
From source file:com.commonsware.android.tte.MainActivity.java
private void openDocument(boolean allowMultiple) { Intent i = new Intent().setType("text/*").setAction(Intent.ACTION_OPEN_DOCUMENT) .putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple).addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_OPEN); }
From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void open() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); PoemFile poemFile = mPoemPrefs.getSavedPoem(); if (poemFile != null) intent.setData(poemFile.uri);/* w w w. ja v a2 s . c o m*/ intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); startActivityForResult(intent, ACTION_FILE_OPEN); }
From source file:de.j4velin.encrypter.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); assert fab != null; fab.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . java 2s . co m*/ public void onClick(final View view) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); startActivityForResult(intent, REQUEST_INPUT); } }); plaintextHeadline = findViewById(R.id.plainheadline); plaintextView = findViewById(R.id.plain); showPlaintextLayout(false); init(); }
From source file:org.strongswan.android.ui.VpnProfileImportActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDataSource = new VpnProfileDataSource(this); mDataSource.open();/*from ww w. j av a 2 s. c o m*/ setContentView(R.layout.profile_import_view); mExistsWarning = (TextView) findViewById(R.id.exists_warning); mBasicDataGroup = (ViewGroup) findViewById(R.id.basic_data_group); mName = (TextView) findViewById(R.id.name); mGateway = (TextView) findViewById(R.id.gateway); mSelectVpnType = (TextView) findViewById(R.id.vpn_type); mUsernamePassword = (ViewGroup) findViewById(R.id.username_password_group); mUsername = (EditText) findViewById(R.id.username); mUsernameWrap = (TextInputLayoutHelper) findViewById(R.id.username_wrap); mPassword = (EditText) findViewById(R.id.password); mUserCertificate = (ViewGroup) findViewById(R.id.user_certificate_group); mSelectUserCert = (RelativeLayout) findViewById(R.id.select_user_certificate); mImportUserCert = (Button) findViewById(R.id.import_user_certificate); mRemoteCertificate = (ViewGroup) findViewById(R.id.remote_certificate_group); mRemoteCert = (RelativeLayout) findViewById(R.id.remote_certificate); mExistsWarning.setVisibility(View.GONE); mBasicDataGroup.setVisibility(View.GONE); mUsernamePassword.setVisibility(View.GONE); mUserCertificate.setVisibility(View.GONE); mRemoteCertificate.setVisibility(View.GONE); mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener()); mImportUserCert.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = KeyChain.createInstallIntent(); intent.putExtra(KeyChain.EXTRA_NAME, getString(R.string.profile_cert_alias, mProfile.getName())); intent.putExtra(KeyChain.EXTRA_PKCS12, mProfile.PKCS12); startActivityForResult(intent, INSTALL_PKCS12); } }); Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { loadProfile(getIntent().getData()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); openIntent.setType("*/*"); startActivityForResult(openIntent, OPEN_DOCUMENT); } if (savedInstanceState != null) { mUserCertLoading = savedInstanceState.getString(VpnProfileDataSource.KEY_USER_CERTIFICATE); if (mUserCertLoading != null) { getLoaderManager().initLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks); } mImportUserCert.setEnabled(!savedInstanceState.getBoolean(PKCS12_INSTALLED)); } }
From source file:com.commonsware.android.diceware.PassphraseFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void open() { Intent i = new Intent().setType("text/plain").setAction(Intent.ACTION_OPEN_DOCUMENT) .addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(i, REQUEST_OPEN); }
From source file:com.sxt.chat.activity.NotifycationActivity.java
private void startGalleryApp() { Intent intent = new Intent(); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { intent.setAction(Intent.ACTION_GET_CONTENT); } else {/*from w w w . j a v a 2 s . c o m*/ intent.setAction(Intent.ACTION_OPEN_DOCUMENT); } intent = Intent.createChooser(intent, ""); startActivityForResult(intent, REQUEST_CODE_GALLERY); }
From source file:org.gnucash.android.ui.common.BaseDrawerActivity.java
/** * Handler for the navigation drawer items * *//*from w w w . ja va 2s.c o m*/ protected void onDrawerMenuItemClicked(int itemId) { switch (itemId) { case R.id.nav_item_open: { //Open... files if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //use the storage access framework Intent openDocument = new Intent(Intent.ACTION_OPEN_DOCUMENT); openDocument.addCategory(Intent.CATEGORY_OPENABLE); openDocument.setType("*/*"); startActivityForResult(openDocument, REQUEST_OPEN_DOCUMENT); } else { AccountsActivity.startXmlFileChooser(this); } } break; case R.id.nav_item_favorites: { //favorite accounts Intent intent = new Intent(this, AccountsActivity.class); intent.putExtra(AccountsActivity.EXTRA_TAB_INDEX, AccountsActivity.INDEX_FAVORITE_ACCOUNTS_FRAGMENT); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; case R.id.nav_item_reports: { Intent intent = new Intent(this, ReportsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; /* //todo: Re-enable this when Budget UI is complete case R.id.nav_item_budgets: startActivity(new Intent(this, BudgetsActivity.class)); break; */ case R.id.nav_item_scheduled_actions: { //show scheduled transactions Intent intent = new Intent(this, ScheduledActionsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; case R.id.nav_item_export: AccountsActivity.openExportFragment(this); break; case R.id.nav_item_settings: //Settings activity startActivity(new Intent(this, PreferenceActivity.class)); break; case R.id.nav_item_help: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean(UxArgument.SKIP_PASSCODE_SCREEN, true).apply(); UserVoice.launchUserVoice(this); break; } mDrawerLayout.closeDrawer(mNavigationView); }
From source file:com.mifos.mifosxdroid.dialogfragments.documentdialog.DocumentDialogFragment.java
/** * This method is to start an intent(getExternal Storage Document). * If Android Version is Kitkat or greater then start intent with ACTION_OPEN_DOCUMENT, * otherwise with ACTION_GET_CONTENT//from www . jav a2s . c o m */ @Override public void getExternalStorageDocument() { Intent intentDocument; if (AndroidVersionUtil.isApiVersionGreaterOrEqual(Build.VERSION_CODES.KITKAT)) { intentDocument = new Intent(Intent.ACTION_OPEN_DOCUMENT); } else { intentDocument = new Intent(Intent.ACTION_GET_CONTENT); } intentDocument.addCategory(Intent.CATEGORY_OPENABLE); intentDocument.setType("*/*"); startActivityForResult(intentDocument, FILE_SELECT_CODE); }
From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java
/** * Get an intent to either take a picture with the camera app or select an app that can pick an existing picture *///from ww w . j a v a 2 s . co m public Intent startPictureTakeOrSelect(SourceHint sourceHint) { //Attention: Our RequestCode will not be used for the result, if a jpeg is picked, data.getType will contain image/jpeg, if the picture was just taken with the camera it will be null Intent pickIntent = new Intent(); pickIntent.setType("image/jpeg"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { pickIntent.setAction(Intent.ACTION_OPEN_DOCUMENT); pickIntent.addCategory(Intent.CATEGORY_OPENABLE); } else { pickIntent.setAction(Intent.ACTION_GET_CONTENT); } Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri fileUri = getPicturePlaceholderUri(PictureManager.MEDIA_TYPE_IMAGE, sourceHint); // reserve a filename to save the image takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name takePhotoIntent.putExtra("return-data", true); Intent chooserIntent = Intent.createChooser(pickIntent, context.getString(R.string.select_take_picture)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent }); return chooserIntent; }