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:org.ueu.uninet.it.IragarkiaBidali.java
/** * Prestatu iragarki berria bidaltzeko formularioa *//*from w ww .j a va2 s. c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.iragarkia_bidali); this.ekintza = this; this.izena = (EditText) findViewById(R.id.editTextIzena); this.izenburua = (EditText) findViewById(R.id.editTextIzenburua); this.eposta = (EditText) findViewById(R.id.editTextEposta); this.telefonoa = (EditText) findViewById(R.id.editTextTelefonoa); this.mezua = (EditText) findViewById(R.id.editTextDeskribapena); this.ohar_legala = (CheckBox) findViewById(R.id.checkBoxlegalAdviceBidali); this.errobota = (EditText) findViewById(R.id.editTextErrobota); this.atala = (Spinner) findViewById(R.id.spinnerAtala); imgView = (ImageView) findViewById(R.id.ImageView); upload = (Button) findViewById(R.id.Upload); bidali = (Button) findViewById(R.id.iragarkiaBidali); // Iragarkiak irudirik badu galeriatik kargatu upload.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getApplicationContext(), "Aukeratu irudi bat.", Toast.LENGTH_SHORT).show(); try { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Irudia aukeratu"), PICK_IMAGE); } catch (Exception e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }); // Formularioa bidali bidali.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (balidatu()) { dialog = ProgressDialog.show(IragarkiaBidali.this, "Fitxategia igotzen eta mezua bidaltzen", "Itxaron mesedez...", true); //Formularioa eta irudia bidali new ImageUploadTask().execute(); } } }); ArrayAdapter<String> iragarki_motak = new ArrayAdapter<String>(this, R.layout.spinner_view, getResources().getStringArray(R.array.iragarki_kategoriak)); iragarki_motak.setDropDownViewResource(R.layout.spinner_view_dropdown); this.atala.setAdapter(iragarki_motak); // Sareko monitora prestatu NetworkConnectivity.sharedNetworkConnectivity().configure(this); NetworkConnectivity.sharedNetworkConnectivity().addNetworkMonitorListener(this); NetworkConnectivity.sharedNetworkConnectivity().startNetworkMonitor(); }
From source file:com.github.pockethub.android.ui.comment.RawCommentFragment.java
private void startImagePicker() { Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, REQUEST_CODE_SELECT_PHOTO); }
From source file:kr.wdream.ui.Components.AvatarUpdater.java
public void openGallery() { if (Build.VERSION.SDK_INT >= 23 && parentFragment != null && parentFragment.getParentActivity() != null) { if (parentFragment.getParentActivity().checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { parentFragment.getParentActivity() .requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 4); return; }//from ww w . j a v a2 s . c o m } PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true, false, false, null); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override public void didSelectPhotos(ArrayList<String> photos, ArrayList<String> captions, ArrayList<ArrayList<TLRPC.InputDocument>> masks, ArrayList<MediaController.SearchImage> webPhotos) { if (!photos.isEmpty()) { Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true); processBitmap(bitmap); } } @Override public void startPhotoSelectActivity() { try { Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); parentFragment.startActivityForResult(photoPickerIntent, 14); } catch (Exception e) { FileLog.e("tmessages", e); } } @Override public boolean didSelectVideo(String path) { return true; } }); parentFragment.presentFragment(fragment); }
From source file:dk.spaceblog.thenicobomb.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mainActivityInstance = this; //Initialize the static instance with the current instance // Set the main menu view setContentView(R.layout.activity_main); // Configure the default values for delay, repeat and intervals. delay = interval = repeat = 1;//from w w w. ja v a2 s. c o m textMessage = phoneNumber = null; // Populate the spinners (http://www.mkyong.com/android/android-spinner-drop-down-list-example/) // Repeat spinner repeatSpinner = (Spinner) findViewById(R.id.repeatSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sms_repeat_count, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); repeatSpinner.setAdapter(adapter); repeatSpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(1)); repeatSpinner.setSelection(0); // Delay spinner delaySpinner = (Spinner) findViewById(R.id.delaySpinner); ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this, R.array.sms_delay, android.R.layout.simple_spinner_item); adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); delaySpinner.setAdapter(adapter2); delaySpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(2)); delaySpinner.setSelection(0); // Interval spinner intervalSpinner = (Spinner) findViewById(R.id.intervalSpinner); ArrayAdapter<CharSequence> adapter3 = ArrayAdapter.createFromResource(this, R.array.sms_interval, android.R.layout.simple_spinner_item); adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); intervalSpinner.setAdapter(adapter3); intervalSpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(3)); intervalSpinner.setSelection(0); //Activate the contact button : ((ImageButton) findViewById(R.id.pick_contact)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // user BoD suggests using Intent.ACTION_PICK instead of .ACTION_GET_CONTENT to avoid the chooser Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // BoD con't: CONTENT_TYPE instead of CONTENT_ITEM_TYPE intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); startActivityForResult(intent, 1); } }); //Check whether the app has the permission to send SMS : this.checkSMSPermission(); }
From source file:it.polimi.wifidirect.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, container, false); this.updateThisDevice(); //click connect's button mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override/*from w ww .ja v a 2s . c om*/ public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.getP2pDevice().deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.getP2pDevice().deviceAddress, true, true); ((DeviceListFragment.DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClientList.getInstance().getList().clear(); ((DeviceListFragment.DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("video/*, image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } }); //click on connect's button mContentView.findViewById(R.id.btn_start_ping_pong).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PingPongDialog pingPongDialog = (PingPongDialog) getFragmentManager() .findFragmentByTag("pingPongDialog"); if (pingPongDialog == null) { pingPongDialog = PingPongDialog.newInstance(); pingPongDialog.setTargetFragment(fragment, PINGPONG); pingPongDialog.show(getFragmentManager(), "pingPongDialog"); getFragmentManager().executePendingTransactions(); } } }); mContentView.findViewById(R.id.btn_start_ping_pong).setVisibility(View.GONE); RecyclerView mRecyclerView = (RecyclerView) mContentView.findViewById(R.id.clientRecyclerView); LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); // allows for optimizations if all item views are of the same size. mRecyclerView.setHasFixedSize(true); mAdapter = new WiFiDetailClientListAdapter(); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); return mContentView; }
From source file:com.android.gallery3d.app.Gallery.java
private void initializeByIntent() { Intent intent = getIntent();/*www .j a va 2 s .c o m*/ String action = intent.getAction(); if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) { startGetContent(intent); } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) { // We do NOT really support the PICK intent. Handle it as // the GET_CONTENT. However, we need to translate the type // in the intent here. Log.w(TAG, "action PICK is not supported"); String type = Utils.ensureNotNull(intent.getType()); if (type.startsWith("vnd.android.cursor.dir/")) { if (type.endsWith("/image")) intent.setType("image/*"); if (type.endsWith("/video")) intent.setType("video/*"); } startGetContent(intent); } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action) || ACTION_REVIEW.equalsIgnoreCase(action)) { startViewAction(intent); } else { startDefaultPage(); } }
From source file:net.micode.fileexplorer.FileViewActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity();//from w ww .ja va 2 s.co m // getWindow().setFormat(android.graphics.PixelFormat.RGBA_8888); mRootView = inflater.inflate(R.layout.file_explorer_list, container, false); ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity); mFileCagetoryHelper = new FileCategoryHelper(mActivity); mFileViewInteractionHub = new FileViewInteractionHub(this); Intent intent = mActivity.getIntent(); String action = intent.getAction(); if (!TextUtils.isEmpty(action) && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) { mFileViewInteractionHub.setMode(Mode.Pick); boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false); if (!pickFolder) { String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY); if (exts != null) { mFileCagetoryHelper.setCustomCategory(exts); } } else { mFileCagetoryHelper.setCustomCategory(new String[] {} /*folder only*/); mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() { public void onClick(View v) { try { Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0); mActivity.setResult(Activity.RESULT_OK, intent); mActivity.finish(); } catch (URISyntaxException e) { e.printStackTrace(); } } }); mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() { public void onClick(View v) { mActivity.finish(); } }); } } else { mFileViewInteractionHub.setMode(Mode.View); } mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list); mFileIconHelper = new FileIconHelper(mActivity); mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList, mFileViewInteractionHub, mFileIconHelper); boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD, !FileExplorerPreferenceActivity.isReadRoot(mActivity)); Log.i(LOG_TAG, "baseSd = " + baseSd); String rootDir = intent.getStringExtra(ROOT_DIRECTORY); if (!TextUtils.isEmpty(rootDir)) { if (baseSd && this.sdDir.startsWith(rootDir)) { rootDir = this.sdDir; } } else { rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH; } mFileViewInteractionHub.setRootPath(rootDir); String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity); Uri uri = intent.getData(); if (uri != null) { if (baseSd && this.sdDir.startsWith(uri.getPath())) { currentDir = this.sdDir; } else { currentDir = uri.getPath(); } } mFileViewInteractionHub.setCurrentPath(currentDir); Log.i(LOG_TAG, "CurrentDir = " + currentDir); mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action) || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT))); mFileListView.setAdapter(mAdapter); mFileViewInteractionHub.refreshFileList(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); intentFilter.addDataScheme("file"); mActivity.registerReceiver(mReceiver, intentFilter); updateUI(); setHasOptionsMenu(true); return mRootView; }
From source file:com.google.android.apps.paco.FindMyExperimentsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.find_experiments, null); setContentView(mainLayout);// w w w. j a va2 s . c o m Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(ExperimentColumns.CONTENT_URI); } userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.find_experiments_list); createListHeader(); createRefreshHeader(); experimentProviderUtil = new ExperimentProviderUtil(this); refreshButton = (Button) findViewById(R.id.RefreshExperimentsButton2); refreshButton.setVisibility(View.VISIBLE); refreshButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!isConnected()) { showDialogById(DownloadHelper.NO_NETWORK_CONNECTION); } else { refreshList(); } } }); progressBar = (ProgressBar) findViewById(R.id.findExperimentsProgressBar); reloadAdapter(); list.setItemsCanFocus(true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experiments.get(position); Uri uri = ContentUris.withAppendedId(getIntent().getData(), experiment.getServerId()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { // The caller is waiting for us to return an experiment selected by // the user. The have clicked on one, so return it now. setResult(RESULT_OK, new Intent().setData(uri)); } else { Intent experimentIntent = new Intent(FindMyExperimentsActivity.this, ExperimentDetailActivity.class); experimentIntent.setData(uri); experimentIntent.putExtra(ExperimentDetailActivity.ID_FROM_MY_EXPERIMENTS_FILE, true); startActivityForResult(experimentIntent, JOIN_REQUEST_CODE); } } }); registerForContextMenu(list); }
From source file:com.google.android.apps.paco.FindExperimentsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.find_experiments, null); setContentView(mainLayout);//from w w w . ja v a 2s. com Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(ExperimentColumns.CONTENT_URI); } userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.find_experiments_list); createListHeader(); createRefreshHeader(); experimentProviderUtil = new ExperimentProviderUtil(this); refreshButton = (Button) findViewById(R.id.RefreshExperimentsButton2); refreshButton.setVisibility(View.VISIBLE); refreshButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!isConnected()) { showDialogById(DownloadHelper.NO_NETWORK_CONNECTION); } else { refreshList(); } } }); progressBar = (ProgressBar) findViewById(R.id.findExperimentsProgressBar); reloadAdapter(); list.setItemsCanFocus(true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experiments.get(position); Uri uri = ContentUris.withAppendedId(getIntent().getData(), experiment.getServerId()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { // The caller is waiting for us to return an experiment selected by // the user. The have clicked on one, so return it now. setResult(RESULT_OK, new Intent().setData(uri)); } else { Intent experimentIntent = new Intent(FindExperimentsActivity.this, ExperimentDetailActivity.class); experimentIntent.setData(uri); startActivityForResult(experimentIntent, JOIN_REQUEST_CODE); } } }); registerForContextMenu(list); }
From source file:com.narkii.security.info.LicenseInfoFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); fileButton = (Button) view.findViewById(R.id.button_add_local); captureButton = (Button) view.findViewById(R.id.button_add_capture); uploadButton = (Button) view.findViewById(R.id.button_upload); previewImage = (ImageView) view.findViewById(R.id.image_preview); gridView = (GridView) view.findViewById(R.id.image_uploaded); fileName = (EditText) view.findViewById(R.id.text_file_name); gridViewAdapter = new GridViewAdapter(getActivity(), null, false); gridView.setAdapter(gridViewAdapter); captureButton.setOnClickListener(new OnClickListener() { @Override//ww w .j av a 2s. co m public void onClick(View v) { // TODO Auto-generated method stub Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = MediaFileStorage.getOutputMediaFileUri(MediaFileStorage.MEDIA_TYPE_IMAGE); Log.d(TAG, fileUri.toString()); Log.d(TAG, fileUri.getPath()); i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); getParentFragment().startActivityForResult(i, Constants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } }); fileButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setType("*/*"); //("image/*") intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); //FragmentFragmentFragmentFragmentResultFragment getParentFragment().startActivityForResult(intent, Constants.CONTENT_GET_ACTIVITY_REQUEST_CODE); } }); uploadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (preBitmap != null && !fileName.getText().toString().equals("")) { // new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub DbOperations operations = DbOperations.getInstance(getActivity()); ContentValues values = new ContentValues(); values.put(Permission.COLUMN_FK_ENTERPRISE_ID, getArguments().getLong("enterpriseId", 0)); Log.d(TAG, "storage file:" + fileUri.toString()); Log.d(TAG, "storage file:" + fileUri.getPath()); values.put(Permission.COLUMN_URL, fileUri.toString()); values.put(Permission.COLUMN_CERTIFICATE_NAME, fileName.getText().toString()); if (isImage) values.put(Permission.COLUMN_TYPE, 1); else values.put(Permission.COLUMN_TYPE, 2); long result = operations.insert(Permission.TABLE_NAME, values); if (result > 0) { Message msg = new Message(); msg.what = Constants.INSERT_UPLOADED_OK_MSG; handler.sendMessage(msg); } } }).start(); } else { Toast.makeText(getActivity(), "please select file and input name", Toast.LENGTH_LONG).show(); } } }); long id = getArguments().getLong("enterpriseId", 0); Bundle bundle = new Bundle(); bundle.putLong("id", id); getLoaderManager().initLoader(Constants.PERMISSION_IMAGE_ID, bundle, this); }