List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:me.henrytao.smoothappbarlayoutdemo.activity.BaseActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == RESULT_OK) { new AlertDialog.Builder(BaseActivity.this).setMessage(getString(R.string.text_thanks_for_donate)) .setPositiveButton(R.string.close, null).show(); } else {/*from w ww. j a v a 2s . co m*/ showDonateDialogErrorCallback(null); } } }
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
/** * Called when registration returns successfully. Intent results are straight from the server. * * @param data/*from w w w . j a va 2s .c om*/ * this is an echo of the data sent to the server */ protected void onRegistrationComplete(Intent data) { final String username = data.getStringExtra(EXTRA_USERNAME); final String password = data.getStringExtra(EXTRA_PASSWORD); mUsernameEdit.setText(username); mPasswordEdit.setText(password); handleLogin(); }
From source file:app.cloud9.com.cloud9.NoticeBoard.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); //use the query to search your data somehow }// w ww. j av a 2 s . c o m }
From source file:com.mobicage.rogerthat.registration.OauthRegistrationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { T.UI();/*w ww. j ava 2 s. c o m*/ if (requestCode == START_OAUTH_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { if (!TextUtils.isEmptyOrWhitespace(data.getStringExtra(OauthActivity.RESULT_CODE))) { registerWithOauthCode(data.getStringExtra(OauthActivity.RESULT_CODE), data.getStringExtra(OauthActivity.RESULT_STATE)); } else { String errorMessage = data.getStringExtra(OauthActivity.RESULT_ERROR_MESSAGE); mErrorTextView.setText(errorMessage); UIUtils.showDialog(OauthRegistrationActivity.this, null, errorMessage); } } } }
From source file:com.piusvelte.sonet.core.PhotoUploadService.java
private void start(Intent intent) { if (intent != null) { String action = intent.getAction(); if (Sonet.ACTION_UPLOAD.equals(action)) { if (intent.hasExtra(Accounts.TOKEN) && intent.hasExtra(Statuses.MESSAGE) && intent.hasExtra(Widgets.INSTANT_UPLOAD)) { String place = null; if (intent.hasExtra(Splace)) place = intent.getStringExtra(Splace); String tags = null; if (intent.hasExtra(Stags)) tags = intent.getStringExtra(Stags); // upload a photo Notification notification = new Notification(R.drawable.notification, "uploading photo", System.currentTimeMillis()); notification.setLatestEventInfo(getBaseContext(), "photo upload", "uploading", PendingIntent.getActivity(PhotoUploadService.this, 0, (Sonet.getPackageIntent(PhotoUploadService.this, About.class)), 0)); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID, notification);/*from www . j a v a 2 s. c om*/ (new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... params) { String response = null; if (params.length > 2) { Log.d(TAG, "upload file: " + params[2]); HttpPost httpPost = new HttpPost(String.format(FACEBOOK_PHOTOS, FACEBOOK_BASE_URL, Saccess_token, mSonetCrypto.Decrypt(params[0]))); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); File file = new File(params[2]); ContentBody fileBody = new FileBody(file); entity.addPart(Ssource, fileBody); HttpClient httpClient = SonetHttpClient .getThreadSafeClient(getApplicationContext()); try { entity.addPart(Smessage, new StringBody(params[1])); if (params[3] != null) entity.addPart(Splace, new StringBody(params[3])); if (params[4] != null) entity.addPart(Stags, new StringBody(params[4])); httpPost.setEntity(entity); response = SonetHttpClient.httpResponse(httpClient, httpPost); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } } return response; } @Override protected void onPostExecute(String response) { // notify photo success String message = getString(response != null ? R.string.success : R.string.failure); Notification notification = new Notification(R.drawable.notification, "photo upload " + message, System.currentTimeMillis()); notification.setLatestEventInfo(getBaseContext(), "photo upload", message, PendingIntent.getActivity(PhotoUploadService.this, 0, (Sonet.getPackageIntent(PhotoUploadService.this, About.class)), 0)); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID, notification); stopSelfResult(mStartId); } }).execute(intent.getStringExtra(Accounts.TOKEN), intent.getStringExtra(Statuses.MESSAGE), intent.getStringExtra(Widgets.INSTANT_UPLOAD), place, tags); } } } }
From source file:fi.hut.soberit.sensors.services.BatchDataUploadService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); if (intent == null) { return START_FLAG_REDELIVERY; }/*w ww .j a v a 2 s. c om*/ filesFolder = intent.getStringExtra(INTENT_FILE_FOLDER); uploadFileField = intent.getStringExtra(INTENT_UPLOAD_FILE_FIELD); apiUri = URI.create(intent.getStringExtra(INTENT_API_URL)); showBatchUploadNotification(getString(R.string.batch_upload_started), 0, true); final SharedPreferences prefs = getSharedPreferences(prefsFile, MODE_PRIVATE); final Editor edit = prefs.edit(); edit.putBoolean(DATA_EXPORT_ONGOING, true); edit.commit(); sessionsDbHelper = new DatabaseHelper(this); sessionDao = new SessionDao(sessionsDbHelper); final ObservationTypeDao observationTypeDao = new ObservationTypeDao(sessionsDbHelper); final ObservationKeynameDao observationKeynameDao = new ObservationKeynameDao(sessionsDbHelper); List<ObservationType> types = observationTypeDao.getObservationTypes(null, null); for (ObservationType type : types) { typesMap.put(type.getId(), type); type.setKeynames(observationKeynameDao.getKeynames(type.getId())); } dataExportThread = new Thread(new DataExportThread()); dataExportThread.start(); return START_FLAG_REDELIVERY; }
From source file:com.shafiq.myfeedle.core.PhotoUploadService.java
private void start(Intent intent) { if (intent != null) { String action = intent.getAction(); if (Myfeedle.ACTION_UPLOAD.equals(action)) { if (intent.hasExtra(Accounts.TOKEN) && intent.hasExtra(Statuses.MESSAGE) && intent.hasExtra(Widgets.INSTANT_UPLOAD)) { String place = null; if (intent.hasExtra(Splace)) place = intent.getStringExtra(Splace); String tags = null; if (intent.hasExtra(Stags)) tags = intent.getStringExtra(Stags); // upload a photo Notification notification = new Notification(R.drawable.notification, "uploading photo", System.currentTimeMillis()); notification.setLatestEventInfo(getBaseContext(), "photo upload", "uploading", PendingIntent.getActivity(PhotoUploadService.this, 0, (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0)); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID, notification);// w w w .jav a 2s . c o m (new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... params) { String response = null; if (params.length > 2) { Log.d(TAG, "upload file: " + params[2]); HttpPost httpPost = new HttpPost(String.format(FACEBOOK_PHOTOS, FACEBOOK_BASE_URL, Saccess_token, mMyfeedleCrypto.Decrypt(params[0]))); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); File file = new File(params[2]); ContentBody fileBody = new FileBody(file); entity.addPart(Ssource, fileBody); HttpClient httpClient = MyfeedleHttpClient .getThreadSafeClient(getApplicationContext()); try { entity.addPart(Smessage, new StringBody(params[1])); if (params[3] != null) entity.addPart(Splace, new StringBody(params[3])); if (params[4] != null) entity.addPart(Stags, new StringBody(params[4])); httpPost.setEntity(entity); response = MyfeedleHttpClient.httpResponse(httpClient, httpPost); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } } return response; } @Override protected void onPostExecute(String response) { // notify photo success String message = getString(response != null ? R.string.success : R.string.failure); Notification notification = new Notification(R.drawable.notification, "photo upload " + message, System.currentTimeMillis()); notification.setLatestEventInfo(getBaseContext(), "photo upload", message, PendingIntent.getActivity(PhotoUploadService.this, 0, (Myfeedle.getPackageIntent(PhotoUploadService.this, About.class)), 0)); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFY_ID, notification); stopSelfResult(mStartId); } }).execute(intent.getStringExtra(Accounts.TOKEN), intent.getStringExtra(Statuses.MESSAGE), intent.getStringExtra(Widgets.INSTANT_UPLOAD), place, tags); } } } }
From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode != ICB_HOST_REQUEST_CODE) { return;//from w ww. j a v a 2 s. c om } Preferences prefs = new Preferences(this); if (data == null || resultCode != Activity.RESULT_OK) { prefs.setIcbHost(null, null); } else { String hostName = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Intent intent = (Intent) data.getExtras().get(Intent.EXTRA_SHORTCUT_INTENT); if (intent != null) { String intentUri = intent.toUri(0); prefs.setIcbHost(hostName, intentUri); } else { prefs.setIcbHost(null, null); } } handleIcb(); }
From source file:com.streaming.sweetplayer.PlayerActivity.java
/** * Update the progressbar and time during playback. * * @param intent Intent/*from w w w .j a v a 2 s .c o m*/ */ private void updateControlsTime(Intent intent) { if (PlayerService.isCompleted) { mLoadingBar.setVisibility(View.GONE); String artistName = intent.getStringExtra("artistName"); String songName = intent.getStringExtra("songName"); String artistImageName = intent.getStringExtra("artistImageName"); loadImage(artistImageName); mArtistNameTextView.setText(artistName); mSongNameTextView.setText(songName); if (mDataBase != null) { if (!mDataBase.isOnPlayList(sSongId)) { if (mAddMenuItem != null) { mAddMenuItem.setVisible(true); } } } } int currentDuration = intent.getIntExtra("currentDuration", 0); int totalDuration = intent.getIntExtra("totalDuration", 0); mCurrentDurationTextView.setText(Utils.getTotalDuration(Utils.toSeconds(currentDuration))); mTotalDurationTextView.setText(Utils.getTotalDuration(totalDuration)); mProgressBar.setMax(totalDuration); mProgressBar.setProgress(Utils.toSeconds(currentDuration)); }
From source file:com.android.nobadgift.DashboardActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { final String scanResult = intent.getStringExtra("SCAN_RESULT"); progDialog = ProgressDialog.show(this, "", "Fetching information...", true); new Thread(new Runnable() { public void run() { runOnUiThread(new Runnable() { public void run() { retrieveProductInfo(scanResult); retrievedImage = doInBackground(imageURL); if (urlContent != null) { displayConfirmationDialog(); } else { trace("Item not found."); }//from ww w.java 2s . c o m } }); progDialog.dismiss(); } }).start(); } else if (resultCode == RESULT_CANCELED) { trace("Scanning aborted..."); } } }