List of usage examples for android.content Intent EXTRA_LOCAL_ONLY
String EXTRA_LOCAL_ONLY
To view the source code for android.content Intent EXTRA_LOCAL_ONLY.
Click Source Link
From source file:com.kdao.cmpe235_project.UploadActivity.java
private void initUI() { /**/*from ww w . ja v a2 s.c o m*/ * This adapter takes the data in transferRecordMaps and displays it, * with the keys of the map being related to the columns in the adapter */ simpleAdapter = new SimpleAdapter(this, transferRecordMaps, R.layout.record_item, new String[] { "checked", "fileName", "progress", "bytes", "state", "percentage" }, new int[] { R.id.radioButton1, R.id.textFileName, R.id.progressBar1, R.id.textBytes, R.id.textState, R.id.textPercentage }); simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { switch (view.getId()) { case R.id.radioButton1: RadioButton radio = (RadioButton) view; radio.setChecked((Boolean) data); return true; case R.id.textFileName: TextView fileName = (TextView) view; fileName.setText((String) data); return true; case R.id.progressBar1: ProgressBar progress = (ProgressBar) view; progress.setProgress((Integer) data); return true; case R.id.textBytes: TextView bytes = (TextView) view; bytes.setText((String) data); return true; case R.id.textState: TextView state = (TextView) view; state.setText(((TransferState) data).toString()); return true; case R.id.textPercentage: TextView percentage = (TextView) view; percentage.setText((String) data); return true; } return false; } }); setListAdapter(simpleAdapter); // Updates checked index when an item is clicked getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) { if (checkedIndex != pos) { transferRecordMaps.get(pos).put("checked", true); if (checkedIndex >= 0) { transferRecordMaps.get(checkedIndex).put("checked", false); } checkedIndex = pos; updateButtonAvailability(); simpleAdapter.notifyDataSetChanged(); } } }); //btnUploadFile = (Button) findViewById(R.id.buttonUploadFile); btnUploadImage = (Button) findViewById(R.id.buttonUploadImage); btnUploadAudio = (Button) findViewById(R.id.buttonUploadAudio); btnUploadVideo = (Button) findViewById(R.id.buttonUploadVideo); btnPause = (Button) findViewById(R.id.buttonPause); btnResume = (Button) findViewById(R.id.buttonResume); btnCancel = (Button) findViewById(R.id.buttonCancel); btnDelete = (Button) findViewById(R.id.buttonDelete); btnPauseAll = (Button) findViewById(R.id.buttonPauseAll); btnCancelAll = (Button) findViewById(R.id.buttonCancelAll); btnUploadImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { System.out.println(">>>>> Start uploading photos... <<<<<<<"); Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/photo"; intent.setType("image/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnUploadAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/audio"; intent.setType("audio/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnUploadVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/video"; intent.setType("video/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnPause.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure the user has selected a transfer if (checkedIndex >= 0 && checkedIndex < observers.size()) { Boolean paused = transferUtility.pause(observers.get(checkedIndex).getId()); /** * If paused does not return true, it is likely because the * user is trying to pause an upload that is not in a * pausable state (For instance it is already paused, or * canceled). */ if (!paused) { Toast.makeText(UploadActivity.this, Config.UPLOAD_PAUSE_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnResume.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure the user has selected a transfer if (checkedIndex >= 0 && checkedIndex < observers.size()) { TransferObserver resumed = transferUtility.resume(observers.get(checkedIndex).getId()); // Sets a new transfer listener to the original observer. // This will overwrite existing listener. observers.get(checkedIndex).setTransferListener(new UploadListener()); /** * If resume returns null, it is likely because the transfer * is not in a resumable state (For instance it is already * running). */ if (resumed == null) { Toast.makeText(UploadActivity.this, Config.UPLOAD_RESUME_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure a transfer is selected if (checkedIndex >= 0 && checkedIndex < observers.size()) { Boolean canceled = transferUtility.cancel(observers.get(checkedIndex).getId()); /** * If cancel returns false, it is likely because the * transfer is already canceled */ if (!canceled) { Toast.makeText(UploadActivity.this, Config.UPLOAD_TRANSFER_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure a transfer is selected if (checkedIndex >= 0 && checkedIndex < observers.size()) { transferUtility.deleteTransferRecord(observers.get(checkedIndex).getId()); observers.remove(checkedIndex); transferRecordMaps.remove(checkedIndex); checkedIndex = INDEX_NOT_CHECKED; updateButtonAvailability(); updateList(); } } }); btnPauseAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { transferUtility.pauseAllWithType(TransferType.UPLOAD); } }); btnCancelAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { transferUtility.cancelAllWithType(TransferType.UPLOAD); } }); updateButtonAvailability(); }
From source file:org.csploit.android.plugins.LoginCracker.java
public void onCreate(Bundle savedInstanceState) { SharedPreferences themePrefs = getSharedPreferences("THEME", 0); Boolean isDark = themePrefs.getBoolean("isDark", false); if (isDark)/*w w w .j a v a 2 s .co m*/ setTheme(R.style.DarkTheme); else setTheme(R.style.AppTheme); super.onCreate(savedInstanceState); if (!System.getCurrentTarget().hasOpenPorts()) new FinishDialog(getString(R.string.warning), getString(R.string.no_open_ports), this).show(); final ArrayList<String> ports = new ArrayList<String>(); for (Port port : System.getCurrentTarget().getOpenPorts()) ports.add(Integer.toString(port.getNumber())); mProtocolAdapter = new ProtocolAdapter(); mPortSpinner = (Spinner) findViewById(R.id.portSpinner); mPortSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ports)); mPortSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { String port = (String) adapter.getItemAtPosition(position); int protocolIndex = mProtocolAdapter.getIndexByPort(port); if (protocolIndex != -1) mProtocolSpinner.setSelection(protocolIndex); } public void onNothingSelected(AdapterView<?> arg0) { } }); mProtocolSpinner = (Spinner) findViewById(R.id.protocolSpinner); mProtocolSpinner.setAdapter(new ProtocolAdapter()); mProtocolSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { int portIndex = mProtocolAdapter.getPortIndexByProtocol(position); if (portIndex != -1) mPortSpinner.setSelection(portIndex); } public void onNothingSelected(AdapterView<?> arg0) { } }); mCharsetSpinner = (Spinner) findViewById(R.id.charsetSpinner); mCharsetSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, CHARSETS)); mCharsetSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { if (CHARSETS_MAPPING[position] == null) { new InputDialog(getString(R.string.custom_charset), getString(R.string.enter_chars_wanted), LoginCracker.this, new InputDialogListener() { @Override public void onInputEntered(String input) { input = input.trim(); if (!input.isEmpty()) mCustomCharset = "aA1" + input; else { mCustomCharset = null; mCharsetSpinner.setSelection(0); } } }).show(); } else mCustomCharset = null; } public void onNothingSelected(AdapterView<?> arg0) { } }); mUserSpinner = (Spinner) findViewById(R.id.userSpinner); mUserSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, USERNAMES)); mUserSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { String user = (String) adapter.getItemAtPosition(position); if (user != null && user.equals("-- ADD --")) { new InputDialog(getString(R.string.add_username), getString(R.string.enter_username), LoginCracker.this, new InputDialogListener() { @Override public void onInputEntered(String input) { USERNAMES = Arrays.copyOf(USERNAMES, USERNAMES.length + 1); USERNAMES[USERNAMES.length - 1] = "-- ADD --"; USERNAMES[USERNAMES.length - 2] = input; mUserSpinner.setAdapter(new ArrayAdapter<String>(LoginCracker.this, android.R.layout.simple_spinner_item, USERNAMES)); mUserSpinner.setSelection(USERNAMES.length - 2); } }).show(); } } public void onNothingSelected(AdapterView<?> arg0) { } }); mMaxSpinner = (Spinner) findViewById(R.id.maxSpinner); mMaxSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, LENGTHS)); mMinSpinner = (Spinner) findViewById(R.id.minSpinner); mMinSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, LENGTHS)); mStartButton = (FloatingActionButton) findViewById(R.id.startFAB); mStatusText = (TextView) findViewById(R.id.statusText); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mActivity = (ProgressBar) findViewById(R.id.activity); mProgressBar.setMax(100); mReceiver = new AttemptReceiver(); mStartButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mRunning) { setStoppedState(); } else { setStartedState(); } } }); mWordlistPicker = new Intent(); mWordlistPicker.addCategory(Intent.CATEGORY_OPENABLE); mWordlistPicker.setType("text/*"); mWordlistPicker.setAction(Intent.ACTION_GET_CONTENT); if (Build.VERSION.SDK_INT >= 11) mWordlistPicker.putExtra(Intent.EXTRA_LOCAL_ONLY, true); }
From source file:com.krayzk9s.imgurholo.activities.MainActivity.java
private void displayUpload() { new AlertDialog.Builder(this).setTitle(R.string.dialog_upload_options_title) .setItems(R.array.upload_options, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Intent intent;//from w ww . ja v a 2 s. co m MainActivity activity = MainActivity.this; switch (whichButton) { case 0: final EditText urlText = new EditText(activity); urlText.setSingleLine(); new AlertDialog.Builder(activity).setTitle(R.string.dialog_url_title).setView(urlText) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (urlText.getText() != null) { UrlAsync urlAsync = new UrlAsync(urlText.getText().toString(), apiCall); urlAsync.execute(); } } }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }) .show(); break; case 1: intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 3); break; case 2: intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 4); break; case 3: new AlertDialog.Builder(activity).setTitle(R.string.dialog_explanation_title) .setMessage(R.string.dialog_explanation_summary) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //do nothing } }).show(); default: break; } } }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); }
From source file:com.fatelon.partyphotobooth.setup.fragments.EventInfoSetupFragment.java
/** * Starts the {@link Activity} for event logo selection. * * @param context the {@link Context}.//from w ww.j a va 2s. c o m */ private void launchLogoSelection(Context context) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(EVENT_LOGO_MIME_TYPE); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); Intent chooserIntent = Intent.createChooser(intent, context.getString(R.string.event_info_setup__event_logo_chooser_title)); startActivityForResult(chooserIntent, EVENT_LOGO_REQUEST_CODE); }
From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = getIntent(); final String action = intent.getAction(); if (IntentUtils.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;/*from ww w . j a v a 2s. c o m*/ } else if (IntentUtils.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { //mState.action = ACTION_MANAGE; mState.action = ACTION_BROWSE; } else { mState.action = ACTION_BROWSE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(IntentUtils.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(IntentUtils.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(IntentUtils.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, true); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); mState.rootMode = SettingsActivity.getRootMode(this); }
From source file:hku.fyp14017.blencode.ui.fragment.SoundFragment.java
@TargetApi(19) private void disableGoogleDrive(Intent intent) { intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); }
From source file:com.android.mms.ui.MessageUtils.java
private static void selectMediaByType(Context context, int requestCode, String contentType, boolean localFilesOnly) { if (context instanceof Activity) { Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); innerIntent.setType(contentType); /// M: @{ if (FeatureOption.MTK_DRM_APP) { innerIntent.putExtra(OmaDrmStore.DrmIntentExtra.EXTRA_DRM_LEVEL, OmaDrmStore.DrmIntentExtra.LEVEL_SD); }/*w ww . j av a 2 s. c o m*/ /// @} if (localFilesOnly) { innerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } Intent wrapperIntent = Intent.createChooser(innerIntent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); } }