List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // This handles the qrcode results if (requestCode == 0) { if (resultCode == Activity.RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); for (String stanzas : contents.split(" ")) { String[] tmp = stanzas.split(":"); if (tmp[0].equalsIgnoreCase("KEY_BASE64")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(true); } else if (tmp[0].equalsIgnoreCase("KEY")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(false); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY_BASE64")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(true); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(false); }//from ww w. j av a2 s . c o m } // end for loop } if (resultCode == Activity.RESULT_CANCELED) { //handle cancel Context context = getActivity(); CharSequence text = " QR Code Canceled"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); toast.show(); } } }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
synchronized private void exportData(Intent intent) { // Gets backup folder String backupName = intent.getStringExtra(INTENT_BACKUP_NAME); File backupDir = StorageHelper.getBackupDir(backupName); // Directory clean in case of previously used backup name StorageHelper.delete(this, backupDir.getAbsolutePath()); // Directory is re-created in case of previously used backup name (removed above) backupDir = StorageHelper.getBackupDir(backupName); // Database backup exportDB(backupDir);// www . j ava 2s . c o m // exportNotes(backupDir); // Attachments backup exportAttachments(backupDir); // Settings if (intent.getBooleanExtra(INTENT_BACKUP_INCLUDE_SETTINGS, true)) { exportSettings(backupDir); } // Notification of operation ended String title = getString(com.dycody.android.idealnote.R.string.data_export_completed); String text = backupDir.getPath(); createNotification(intent, this, title, text, backupDir); }
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
/** * {@inheritDoc}/*from w w w. j a v a 2 s . com*/ */ @Override public void onCreate(Bundle icicle) { if (BuildConfig.DEBUG) { Log.i(TAG, "onCreate(" + icicle + ")"); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { requestWindowFeature(Window.FEATURE_ACTION_BAR); } super.onCreate(icicle); mAccountManager = AccountManager.get(this); if (BuildConfig.DEBUG) { Log.i(TAG, "loading data from Intent"); } final Intent intent = getIntent(); mUsername = intent.getStringExtra(EXTRA_USERNAME); mAuthtokenType = intent.getStringExtra(EXTRA_AUTHTOKEN_TYPE); mRequestNewAccount = mUsername == null; mConfirmCredentials = intent.getBooleanExtra(EXTRA_CONFIRMCREDENTIALS, false); if (BuildConfig.DEBUG) { Log.i(TAG, " request new: " + mRequestNewAccount); } requestWindowFeature(Window.FEATURE_LEFT_ICON); final CharSequence appName = getAppName(); // make the title based on the app name. setTitle(getString(R.string.login_title, appName)); // TODO make this changeable. Maybe use fragments? setContentView(R.layout.login); // this is done this way, so the associated icon is managed in XML. try { getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, getPackageManager().getActivityIcon(getComponentName())); } catch (final NameNotFoundException e) { e.printStackTrace(); } mMessage = (TextView) findViewById(R.id.message); mUsernameEdit = (EditText) findViewById(R.id.username); mUsernameEdit.setHint(isEmailAddressLogin() ? R.string.auth_email_login_hint : R.string.auth_username_hint); mPasswordEdit = (EditText) findViewById(R.id.password); mPasswordEdit.setOnEditorActionListener(this); findViewById(R.id.login).setOnClickListener(this); findViewById(R.id.cancel).setOnClickListener(this); mRegisterButton = (Button) findViewById(R.id.register); mRegisterButton.setOnClickListener(this); final String regButton = getString(R.string.signup_text, appName); if (regButton.length() < 24) { mRegisterButton.setText(regButton); } ((TextView) findViewById(R.id.username_label)).setText(getString(R.string.username_label, appName)); mUsernameEdit.setText(mUsername); // this will be unnecessary with fragments mAuthenticationTask = (AuthenticationTask) getLastNonConfigurationInstance(); if (mAuthenticationTask != null) { mAuthenticationTask.attach(this); } }
From source file:io.anyline.cordova.AnylinePlugin.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { //should always be called, but unclear if the reset of the handler always works Thread.setDefaultUncaughtExceptionHandler(mDefaultUncaughtExceptionHandler); ResultReporter.setListener(null);//from w w w .ja v a2s . c om if (resultCode == RESULT_OK) { //nothing todo, handeled with ResultReporter } else if (resultCode == RESULT_CANCELED) { mCallbackContext.error("Canceled"); } else if (resultCode == RESULT_ERROR) { mCallbackContext.error(data.getStringExtra(EXTRA_ERROR_MESSAGE)); } }
From source file:de.stadtrallye.rallyesoft.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.i(THIS, "Receiving Intent"); if (intent != null && intent.hasExtra(Std.TAB)) { Log.i(THIS, "Receiving Intent with Tab"); if (intent.getStringExtra(Std.TAB).equals(Std.CHATROOM)) { int chatroom = intent.getIntExtra(Std.CHATROOM, -1); int chatID = intent.getIntExtra(Std.CHAT_ID, -1); Bundle b = new Bundle(); b.putInt(Std.CHATROOM, chatroom); b.putInt(Std.CHAT_ID, chatID); tabManager.setArguments(RallyeTabManager.TAB_CHAT, b); tabManager.switchToTab(RallyeTabManager.TAB_CHAT); }//from w w w.j av a 2 s .c om } }
From source file:ca.ualberta.cs.unter.view.RiderMainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1) { if (resultCode == RESULT_OK) { String strEditText = data.getStringExtra("edittextvalue"); searchDepartureLocationEditText.setText(strEditText); }//from w w w . ja v a 2s .c o m } else if (requestCode == 2) { if (resultCode == RESULT_OK) { String strEditText = data.getStringExtra("edittextvalue"); searchDestinationLocationEditText.setText(strEditText); } } }
From source file:eu.alefzero.owncloud.files.services.InstantUploadService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null || !intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_DISPLAY_NAME) || !intent.hasExtra(KEY_FILE_PATH) || !intent.hasExtra(KEY_FILE_SIZE) || !intent.hasExtra(KEY_MIME_TYPE)) { Log.w(TAG, "Not all required information was provided, abording"); return Service.START_NOT_STICKY; }/*w w w. j av a2s . c om*/ if (mUploaderRunnable == null) { mUploaderRunnable = new UploaderRunnable(); } String filename = intent.getStringExtra(KEY_DISPLAY_NAME); String filepath = intent.getStringExtra(KEY_FILE_PATH); String mimetype = intent.getStringExtra(KEY_MIME_TYPE); Account account = intent.getParcelableExtra(KEY_ACCOUNT); long filesize = intent.getLongExtra(KEY_FILE_SIZE, -1); mUploaderRunnable.addElementToQueue(filename, filepath, mimetype, filesize, account); // starting new thread for new download doesnt seems like a good idea // maybe some thread pool or single background thread would be better Log.d(TAG, "Starting instant upload thread"); new Thread(mUploaderRunnable).start(); return Service.START_STICKY; }
From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java
private SafeBroadcastReceiver getBroadcastReceiver() { return new SafeBroadcastReceiver() { @Override// w w w . j ava 2 s . c o m public String[] onSafeReceive(Context context, Intent intent) { T.UI(); if (intent.getAction().equals(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT)) { final String emailHash = intent.getStringExtra(EMAILHASH); if (emailHash != null && emailHash.equals(mExpectedEmailHash)) { abortProcessing(); if (intent.getBooleanExtra(ProcessScanActivity.SUCCESS, true)) { final Intent inviteFriendIntent = new Intent(ProcessScanActivity.this, InviteFriendActivity.class); // Copy extra from other intent for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL, EMAILHASH, NAME, QUALIFIED_IDENTIFIER }) { inviteFriendIntent.putExtra(extra, intent.getStringExtra(extra)); } inviteFriendIntent.putExtra(TYPE, intent.getLongExtra(TYPE, FriendsPlugin.FRIEND_TYPE_USER)); startActivity(inviteFriendIntent); finish(); return new String[] { intent.getAction() }; } else { showError(intent); } } else { // ignore } } else if (intent.getAction().equals(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT)) { if (mExpectedEmailHash != null && mExpectedEmailHash.equals(intent.getStringExtra(EMAILHASH)) && mExpectedAction != null && mExpectedAction.equals(intent.getStringExtra(POKE_ACTION))) { abortProcessing(); if (intent.getBooleanExtra(SUCCESS, true)) { final Intent serviceActionIntent = new Intent(ProcessScanActivity.this, ServiceActionActivity.class); // Copy extra from other intent for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL, NAME, POKE_DESCRIPTION, QUALIFIED_IDENTIFIER, STATIC_FLOW, STATIC_FLOW_HASH }) { serviceActionIntent.putExtra(extra, intent.getStringExtra(extra)); } serviceActionIntent.putExtra(EMAILHASH, mExpectedEmailHash); serviceActionIntent.putExtra(POKE_ACTION, mExpectedAction); serviceActionIntent.setAction(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT); serviceActionIntent.putExtra(SUCCESS, true); startActivity(serviceActionIntent); finish(); // TODO: set success? return new String[] { intent.getAction() }; } else { showError(intent); } } else { // ignore } } else if (intent.getAction().equals(URL_REDIRECTION_DONE)) { final String emailHash = intent.getStringExtra(EMAILHASH); if (intent.hasExtra(POKE_ACTION)) { final String pokeAction = intent.getStringExtra(POKE_ACTION); getServiceActionInfo(emailHash, pokeAction); } else { processEmailHash(emailHash); } return new String[] { intent.getAction() }; } return null; // Intent was ignored } }; }
From source file:net.evecom.android.log.DailyLogLookActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.daily_log_look_activity); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // init1();//from w w w .jav a 2 s . c o m Intent intent = getIntent(); sysid = intent.getStringExtra("sysid"); areaname = intent.getStringExtra("areaname"); init(); initView(); getXmlAndSetList(); }
From source file:com.googlecode.android_scripting.facade.BluetoothFacade.java
@Rpc(description = "Connect to a device over Bluetooth. Blocks until the connection is established or fails.", returns = "True if the connection was established successfully.") public String bluetoothConnect( @RpcParameter(name = "uuid", description = "The UUID passed here must match the UUID used by the server device.") @RpcDefault(DEFAULT_UUID) String uuid, @RpcParameter(name = "address", description = "The user will be presented with a list of discovered devices to choose from if an address is not provided.") @RpcOptional String address) throws IOException { if (address == null) { Intent deviceChooserIntent = new Intent(); deviceChooserIntent.setComponent(Constants.BLUETOOTH_DEVICE_LIST_COMPONENT_NAME); Intent result = mAndroidFacade.startActivityForResult(deviceChooserIntent); if (result != null && result.hasExtra(Constants.EXTRA_DEVICE_ADDRESS)) { address = result.getStringExtra(Constants.EXTRA_DEVICE_ADDRESS); } else {//from www .j a v a 2s . c o m return null; } } BluetoothDevice mDevice; BluetoothSocket mSocket; BluetoothConnection conn; mDevice = mBluetoothAdapter.getRemoteDevice(address); mSocket = mDevice.createRfcommSocketToServiceRecord(UUID.fromString(uuid)); // Always cancel discovery because it will slow down a connection. mBluetoothAdapter.cancelDiscovery(); mSocket.connect(); conn = new BluetoothConnection(mSocket); return addConnection(conn); }