List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:org.klnusbaum.udj.auth.AuthActivity.java
/** * Called when response is received from the server for confirm credentials * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. * * @param result the confirmCredentials result. *//* w ww . j a v a 2 s. co m*/ private void finishConfirmCredentials(boolean result) { Log.i(TAG, "finishConfirmCredentials()"); final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); mAccountManager.setPassword(account, mPassword); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == BreakRouteActivity.RESULT_ROUTE_BROKEN) { if (data != null && data.getExtras() != null) { Bundle args = data.getExtras(); startStat = Util.locationFromCoordinates(args.getDouble("start_station_lat"), args.getDouble("start_station_lon")); endStat = Util.locationFromCoordinates(args.getDouble("end_station_lat"), args.getDouble("end_station_lon")); aStationName = args.getString("start_stat_name"); bStationName = args.getString("end_stat_name"); distance = args.getDouble("distance"); stationIconId = args.getInt("iconId"); getMapFragment().jsonRoot = null; List<Location> viaList = new LinkedList<Location>(); viaList.add(startStat);//from ww w . ja v a 2 s.c om viaList.add(endStat); new SMHttpRequest().getRoute(getMapFragment().startLocation, getMapFragment().endLocation, viaList, this); } } }
From source file:yulei.android.client.AndroidMobilePushApp.java
private String getMessage(int numOfMissedMessages) { String message = ""; String linesOfMessageCount = getString(R.string.lines_of_message_count); if (numOfMissedMessages > 0) { String plural = numOfMissedMessages > 1 ? "s" : ""; Log.i("onResume", "missed " + numOfMissedMessages + " message" + plural); tView.append("You missed " + numOfMissedMessages + " message" + plural + ". Your most recent was:\n"); for (int i = 0; i < savedValues.getInt(linesOfMessageCount, 0); i++) { String line = "***" + savedValues.getString("MessageLine" + i, "") + "&&&&"; message += (line + "\n"); }// w w w .j ava 2 s.c o m NotificationManager mNotification = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotification.cancel(R.string.notification_number); SharedPreferences.Editor editor = savedValues.edit(); editor.putInt(this.numOfMissedMessages, 0); editor.putInt(linesOfMessageCount, 0); editor.commit(); } else { Log.i("onResume", "no missed messages"); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { String realData = extras.getString("default"); // message += "___" +realData +"___"; if (realData != null && realData.length() > 2) { //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); if (realData.length() > 2) { Log.e("here", realData); try { Toast toast = Toast.makeText(getApplicationContext(), decodeJSONforName(realData) + decodeJSONforTime(realData), Toast.LENGTH_SHORT); toast.show(); Log.e("heres", "sssss"); //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); addMarker(decodeJSONforLat(realData), decodeJSONforLon(realData), decodeJSONforName(realData), decodeJSONforSentiment(realData), decodeJSONforScore(realData)); message = "\n" + decodeJSONforName(realData) + "\n" + decodeJSONforContent(realData) + "\n"; addHeatMap(decodeJSONforLat(realData), decodeJSONforLon(realData)); //addMarker((Double)decodeObj.get("latitute"),(Double)decodeObj.get("longitude"),(String)decodeObj.get("time"),(String)decodeObj.get("userName")); } catch (Exception e) { Log.e("exception", "Exception throwed"); } } } } } } message += "\n"; return message; }
From source file:uk.ac.ucl.excites.sapelli.relay.BackgroundService.java
/** * Register an SMS Data (Binary) Receiver *///from www. j a va2 s . c om private void registerSmsReceiver() { smsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Debug.i("Received Binary SMS"); Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; if (null != bundle) { // In telecommunications the term (PDU) means protocol data // unit. // There are two ways of sending and receiving SMS messages: // by text mode and by PDU (protocol description unit) mode. // The PDU string contains not only the message, but also a // lot of meta-information about the sender, his SMS service // center, the time stamp etc // It is all in the form of hexa-decimal octets or decimal // semi-octets. Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i = 0; i < msgs.length; i++) { // Create the Message msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); // Get Message Parameters SmsObject receivedSms = new SmsObject(); receivedSms.setTelephoneNumber(msgs[i].getOriginatingAddress()); receivedSms.setMessageTimestamp(msgs[i].getTimestampMillis()); receivedSms.setMessageData(Base64.encodeToString(msgs[i].getUserData(), Base64.CRLF)); Debug.d("Received SMS and it's content hash is: " + BinaryHelpers .toHexadecimealString(Hashing.getMD5Hash(msgs[i].getUserData()).toByteArray())); // Store the SmsObject to the db dao.storeSms(receivedSms); } } // This will stop the Broadcast and not allow the message to // be interpreted by the default Android app or other apps abortBroadcast(); } }; // Set up the Receiver Parameters IntentFilter mIntentFilter = new IntentFilter(); mIntentFilter.setPriority(999); mIntentFilter.addAction("android.intent.action.DATA_SMS_RECEIVED"); mIntentFilter.addDataScheme("sms"); // Set the Port that is listening to mIntentFilter.addDataAuthority("*", "2013"); // mIntentFilter.addDataType(type) registerReceiver(smsReceiver, mIntentFilter); Debug.d("Set up BinarySMS receiver."); }
From source file:com.google.android.gcm.demo.app.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); ctx = context;/*from w ww . j ava 2 s . c om*/ String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + intent.getExtras().toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + intent.getExtras().toString()); } else { sendNotification("Received: " + intent.getExtras().toString()); // "urn":"soundcloud:sounds:125","finished_at":"0001-01-01T00:00:00Z","last_played_at":"0001-01-01T00:00:00Z","progress":0} LLQueue queue = LLQueue.get(); if (queue == null) return; //queue.loadListenLaterQueue(); if (intent.hasExtra("set")) { String set = intent.getStringExtra("set"); try { JSONObject obj = new JSONObject(set); String urn = obj.optString("urn"); Log.d(TAG, "GCM set with urn:" + urn); if (!TextUtils.isEmpty(urn)) { queue.addUrn(urn); } } catch (JSONException e) { Log.w(TAG, e); } } else if (intent.hasExtra("delete")) { String delete = intent.getStringExtra("delete"); try { JSONObject obj = new JSONObject(delete); String urn = obj.optString("urn"); Log.d(TAG, "GCM set with urn:" + urn); if (!TextUtils.isEmpty(urn)) { queue.removeUrn(urn); } } catch (JSONException e) { Log.w(TAG, e); } } else if (intent.hasExtra("play")) { String play = intent.getStringExtra("play"); try { JSONObject obj = new JSONObject(play); String urn = obj.optString("urn"); String toggleAt = obj.optString("toggle_at"); long progress = obj.optInt("progress", 0); Log.d(TAG, "GCM play with urn:" + urn + " ,togglet_at:" + toggleAt); Intent playIntent = new Intent(); queue.playUrn(urn, progress); if (!TextUtils.isEmpty(toggleAt)) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");//spec for RFC3339 (with fractional seconds) try { Date date = format.parse(toggleAt); Log.d(TAG, "parsed date:" + date); // AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // alarmManager.set(AlarmManager.RTC_WAKEUP, date.getTime(), PendingIntent.getActivity(context, 0, playIntent, 0)); } catch (ParseException e) { Log.w(TAG, e); } } else { } } catch (JSONException e) { Log.w(TAG, e); } } } setResultCode(Activity.RESULT_OK); }
From source file:com.allmycode.flags.other.MyActivityOther.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from ww w .j a v a2 s . c o m targetActivity = (EditText) findViewById(R.id.editText1); flags = (EditText) findViewById(R.id.editText2); cheatSheet = (EditText) findViewById(R.id.editText3); for (String item : flagsList) { cheatSheet.append(item); cheatSheet.append("\n"); } Intent whoCalled = getIntent(); helloView = ((TextView) findViewById(R.id.textView3)); helloView.setTextColor(android.graphics.Color.WHITE); helloView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); helloView.setText("Flags: 0x" + Integer.toHexString(whoCalled.getFlags())); if (whoCalled.getExtras() != null) { boolean areErrors = whoCalled.getExtras().getBoolean("existErrors", false); if (areErrors) { helloView.append(" There were errors!"); helloView.setTextColor(android.graphics.Color.RED); helloView.setTypeface(Typeface.DEFAULT, Typeface.BOLD); } } ActivityManager am = (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processes; processes = am.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo info : processes) { Log.i("Process:", info.processName); } }
From source file:com.orange.labs.sdk.session.AuthSession.java
/** * Check if authentication is successfull. * @param success//from w w w .j a v a2s. c o m * @param failure */ public void checkAuthentication(final OrangeListener.Success<String> success, final OrangeListener.Error failure) { String refreshToken = getRefreshToken(); // Check Refresh Token if (refreshToken == null || refreshToken.length() == 0) { // Check the result of AuthActivity // Check if an error occurred Intent data = AuthActivity.result; if (data != null) { Bundle extras = data.getExtras(); OrangeAPIException exception = (OrangeAPIException) extras .getSerializable(AuthActivity.EXTRA_EXCEPTION_ERROR); if (exception != null) { failure.onErrorResponse(exception); } else { // Check the authorization code to return an access token, refresh token... // Prepare URL String url = API_SERVER + "/oauth/v2/token"; // Prepare params in body request JSONObject params = new JSONObject(); try { params.put("grant_type", "authorization_code"); params.put("code", data.getStringExtra(AuthActivity.EXTRA_AUTHORIZATION_CODE)); params.put("redirect_uri", redirectURI); getRestClient().jsonRequest("/session/check/authorizationCode", Request.Method.POST, url, params, getHeaders(), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // save values : accessToken = response.optString("access_token"); setExpiresIn(response.optInt("expires_in")); setRefreshToken(response.optString("refresh_token")); // Check that authent is success ! SharedPreferences sharedPref = context .getSharedPreferences(SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean(SHARED_PREFERENCES_FORCE_LOGIN, false); editor.commit(); success.onResponse("OK"); } }, failure); } catch (JSONException e) { failure.onErrorResponse(new OrangeAPIException()); } } } } else { // get the access token with refresh token refresh(success, failure); } }
From source file:fm.smart.r1.CreateSoundActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_sound); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); item_id = (String) extras.get("item_id"); id = (String) extras.get("id"); goal_id = (String) extras.get("goal_id"); // not being added at present // TODO/*from w w w.j a v a 2s .com*/ to_record = (String) extras.get("to_record"); sound_type = extras.getString("sound_type"); recorder = new MediaRecorder(); TextView text = (TextView) findViewById(R.id.create_sound_text); text.setText(Html.fromHtml(to_record)); button = (Button) findViewById(R.id.create_sound_submit); button.setOnClickListener(this); }
From source file:com.google.zxing.client.android.history.HistoryActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); pegaScreenResolution();//from w ww .ja v a 2s. co m this.historyManager = new HistoryManager(this); adapter = new HistoryItemAdapter(this); setListAdapter(adapter); View listview = getListView(); registerForContextMenu(listview); originalTitle = getTitle(); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); String txt = bundle.getString("envia_dados"); if (txt.equals("envia_dados")) { Toast.makeText(this, R.string.toast_envia_dado_acima, Toast.LENGTH_LONG).show(); } }
From source file:fm.smart.r1.activity.CreateSoundActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_sound); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); item_id = (String) extras.get("item_id"); id = (String) extras.get("id"); list_id = (String) extras.get("list_id"); to_record = (String) extras.get("to_record"); sound_type = extras.getString("sound_type"); recorder = new MediaRecorder(); TextView text = (TextView) findViewById(R.id.create_sound_text); text.setText(Html.fromHtml(to_record)); button = (Button) findViewById(R.id.create_sound_submit); button.setOnClickListener(this); }