List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.tapchatapp.android.service.GCMReceiver.java
@Override public void onReceive(Context context, Intent intent) { String messageType = mGCM.getMessageType(intent); if (!messageType.equals(GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE)) { return;// www.ja v a 2 s . com } try { byte[] cipherText = Base64.decode(intent.getStringExtra("payload"), Base64.URL_SAFE | Base64.NO_WRAP); byte[] iv = Base64.decode(intent.getStringExtra("iv"), Base64.URL_SAFE | Base64.NO_WRAP); byte[] key = mPusherClient.getPushKey(); if (key == null) { // I don't think this will ever happen throw new Exception("Received push notification before receiving decryption key."); } JSONObject message = new JSONObject(new String(decrypt(cipherText, key, iv), "UTF-8")); Intent broadcastIntent = new Intent(TapchatApp.ACTION_MESSAGE_NOTIFY); addExtras(broadcastIntent, message); context.sendOrderedBroadcast(broadcastIntent, null); } catch (Exception ex) { Log.e(TAG, "Error parsing push notification", ex); } }
From source file:com.ateam.alleneatonautorentals.SalesViewCheckedOutCars.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_reservations); Intent getIntent = getIntent(); userEmail = getIntent.getStringExtra("email"); key = getIntent.getStringExtra("key"); name = getIntent.getStringExtra("name"); resList = new ArrayList<HashMap<String, String>>(); new LoadAllUserRes().execute(); ListView lv = getListView();/*from w w w .ja v a2 s . c o m*/ lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String gps = ((TextView) view.findViewById(R.id.carres_GPS_list)).getText().toString(); String child_seat = ((TextView) view.findViewById(R.id.carres_child_seat_list)).getText() .toString(); String k_tag = ((TextView) view.findViewById(R.id.carres_k_tag_list)).getText().toString(); String assistance = ((TextView) view.findViewById(R.id.carres_assistance_list)).getText() .toString(); String dinsurance = ((TextView) view.findViewById(R.id.carres_dinsurance_list)).getText() .toString(); String ainsurance = ((TextView) view.findViewById(R.id.carres_ainsurance_list)).getText() .toString(); String state = ((TextView) view.findViewById(R.id.carres_state_list)).getText().toString(); String city = ((TextView) view.findViewById(R.id.carres_city_list)).getText().toString(); String start_date = ((TextView) view.findViewById(R.id.carres_start_list)).getText().toString(); String end_date = ((TextView) view.findViewById(R.id.carres_end_list)).getText().toString(); String carid = ((TextView) view.findViewById(R.id.carres_id_list)).getText().toString(); String cartype = ((TextView) view.findViewById(R.id.carres_type_list)).getText().toString(); Intent ii = new Intent(getApplicationContext(), SalesCheckinCar.class); ii.putExtra("carid", carid); ii.putExtra("cartype", cartype); ii.putExtra("state", state); ii.putExtra("city", city); ii.putExtra("start_date", start_date); ii.putExtra("end_date", end_date); ii.putExtra("gps", gps); ii.putExtra("child_seat", child_seat); ii.putExtra("ktag", k_tag); ii.putExtra("assistance", assistance); ii.putExtra("dinsurance", dinsurance); ii.putExtra("ainsurance", ainsurance); ii.putExtra("reservation", "1"); ii.putExtra("email", userEmail); ii.putExtra("key", key); ii.putExtra("name", name); startActivity(ii); finish(); } }); }
From source file:com.adamhurwitz.android.popularmovies.service.MovieDataService.java
@Override protected void onHandleIntent(Intent intent) { // Receive AsyncTask param from MainFragment.java String movieQuery = intent.getStringExtra("MOVIE_QUERY"); HttpURLConnection urlConnection = null; BufferedReader reader = null; // Will contain the raw JSON response as a string. String jsonResponse = null;/* www. j a v a 2 s. c o m*/ try { // Construct the URL to fetch data from and make the connection. Uri builtUri = Uri.parse(BASE_URL).buildUpon().appendQueryParameter(SORT_PARAMETER, movieQuery) .appendQueryParameter(KEY_PARAMETER, KEY_CODE).build(); URL url = new URL(builtUri.toString()); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.connect(); // See if the input stream is not null and a connection could be made. If it is null, do // not process any further. InputStream inputStream = urlConnection.getInputStream(); StringBuilder buffer = new StringBuilder(); if (inputStream == null) { return; } // Read the input stream to see if any valid response was give. reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { // Add new to make debugging easier. buffer.append(line).append("\n"); } if (buffer.length() == 0) { // If the stream is empty, do not process any further. return; } jsonResponse = buffer.toString(); } catch (IOException e) { // If there was no valid Google doodle data returned, there is no point in attempting to // parse it. Log.e(LOG_TAG, "Error, IOException.", e); return; } finally { // Make sure to close the connection and the reader no matter what. if (urlConnection != null) { urlConnection.disconnect(); } if (reader != null) { try { reader.close(); } catch (final IOException e) { Log.e(LOG_TAG, "Error closing stream ", e); } } } // If valid data was returned, return the parsed data. try { Log.i(LOG_TAG, "The Google doodle data that was returned is: " + jsonResponse); parseJSONResponse(jsonResponse); return; } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); e.printStackTrace(); } // Any other case that gets here is an error that was not caught, so return null. return; }
From source file:com.example.administrator.myapplication2._2_exercise._2_End.RightFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout._2_fragment_map, container, false); Intent myIntent = getActivity().getIntent(); if (myIntent != null) { seq = myIntent.getStringExtra("seq"); }//from w w w .j a v a2s .com SharedPreferences myPrefs = this.getActivity().getSharedPreferences("login", Context.MODE_PRIVATE); if ((myPrefs != null) && (myPrefs.contains("id"))) { id = myPrefs.getString("id", ""); } // ? ? map = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map2)).getMap(); map.setMyLocationEnabled(true); arrayPoints = new ArrayList<LatLng>(); // getRecentSeq(); getRecentData(); return rootView; }
From source file:com.scigames.slidegame.Registration4PhotoActivity.java
/** Called with the activity is first created. */ @Override/*from w w w . ja v a2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "super.OnCreate"); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); Intent i = getIntent(); Log.d(TAG, "getIntent"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); studentIdIn = i.getStringExtra("studentId"); visitIdIn = i.getStringExtra("visitId"); Log.d(TAG, "...getStringExtra"); // Inflate our UI from its XML layout description. setContentView(R.layout.registration4_photo); Log.d(TAG, "...setContentView"); this.imageView = (ImageView) this.findViewById(R.id.imageView1); Log.d(TAG, "...findViewById. imageView1"); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); //((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener); ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);//(mDoneListener); ((Button) findViewById(R.id.take_pic)).setOnClickListener(mTakePhotoListener); Log.d(TAG, "...instantiateButtons"); //set listener task.setOnResultsListener(this); }
From source file:com.tealeaf.PushBroadcastReceiver.java
@Override public void onReceive(final Context context, Intent in) { final TeaLeafOptions options = new TeaLeafOptions(context); final String appID = options.getAppID(); if (!appID.equals(in.getStringExtra("appID"))) { return;// ww w . j av a 2 s .c om } scheduledIntent = null; new Thread(new Runnable() { public void run() { HTTP http = new HTTP(); Settings settings = new Settings(context); String format = options.getPushUrl(); String url = String.format(format, appID, Device.getDeviceID(context, settings), options.getBuildIdentifier()); logger.log("{push} Polling for notifications on", url); Pair<String, Integer> result = http.getPush(URI.create(url)); int timeout = options.getPushDelay(); if (result != null) { timeout = result.second; if (timeout == -1) { timeout = options.getPushDelay(); } String json = result.first; logger.log("{push} Got push notification", json, "and will delay for", timeout, "seconds before checking again"); try { JSONArray array = new JSONArray(json); int len = array.length(); JSONArray notifications = new JSONArray(settings.getPushNotifications()); for (int i = 0; i < len; i++) { JSONObject msg = array.getJSONObject(i); if (msg.optBoolean("crossPromo", false)) { // a cross-promo Intent intent = new Intent("com.tealeaf.CROSS_PROMO"); intent.putExtra("appid", msg.getString("appID")); intent.putExtra("url", msg.getString("url")); intent.putExtra("version", msg.getString("version")); intent.putExtra("displayName", msg.getString("displayName")); intent.putExtra("buildID", msg.getString("buildIdentifier")); intent.putExtra("image", msg.optString("image")); context.startService(intent); } else if (msg.optBoolean("hasUpdate", false) && !settings.is("updating_now")) { logger.log("{push} Got an update request (old build id:", options.getBuildIdentifier(), ", new build identifier:", msg.getString("buildIdentifier"), ", old android version:", options.getGameHash(), ", new android version:", msg.getString("gameHash"), ")"); // an update notification Intent intent = new Intent("com.tealeaf.PERFORM_UPDATE"); // required parameters // is the update supposed to be silent? intent.putExtra("silent", msg.getBoolean("silent")); // does the update require hitting the marketplace instead? (native runtime update) intent.putExtra("market", !msg.getString("gameHash").equals(options.getGameHash())); // what's the new build identifier of the update? intent.putExtra("buildIdentifier", msg.getString("buildIdentifier")); // what url can I download the updated build from? intent.putExtra("url", msg.getString("url")); context.sendOrderedBroadcast(intent, null); } } settings.setPushNotifications(notifications.toString()); } catch (JSONException e) { logger.log(e); } } scheduleNext(context, timeout); } }).start(); }
From source file:com.manning.androidhacks.hack046.service.MsgService.java
@Override protected void onHandleIntent(Intent intent) { if (MSG_RECEIVE.equals(intent.getAction())) { handleMsgReceive();/*from w ww .j a v a 2 s.c o m*/ } else if (MSG_DELETE.equals(intent.getAction())) { handleMsgDelete(); } else if (MSG_REPLY.equals(intent.getAction())) { handleMsgReply(intent.getStringExtra(MSG_REPLY_KEY)); } }
From source file:edu.mit.media.funf.funftowotk.MainPipeline.java
@Override protected void onHandleIntent(Intent intent) { if (ACTION_RUN_ONCE.equals(intent.getAction())) { String probeName = intent.getStringExtra(RUN_ONCE_PROBE_NAME); runProbeOnceNow(probeName);// w w w. jav a 2 s .c o m } else { String action = intent.getAction(); if (super.ACTION_UPLOAD_DATA.equals(action)) { //disable real-time upload if need be } super.onHandleIntent(intent); } }
From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java
/** * Check if there is a registration_id, and pass it to the AS. * Send a TOKEN_FAIL event if there is an error. * @param context // w ww.j ava2 s. c o m * @param intent */ private void handleRegistration(Context context, Intent intent) { FREContext freContext = C2DMExtension.context; String registration = intent.getStringExtra("registration_id"); if (intent.getStringExtra("error") != null) { String error = intent.getStringExtra("error"); Log.d(TAG, "Registration failed with error: " + error); if (freContext != null) { freContext.dispatchStatusEventAsync("TOKEN_FAIL", error); } } else if (intent.getStringExtra("unregistered") != null) { Log.d(TAG, "Unregistered successfully"); if (freContext != null) { freContext.dispatchStatusEventAsync("UNREGISTERED", "unregistered"); } } else if (registration != null) { Log.d(TAG, "Registered successfully"); if (freContext != null) { freContext.dispatchStatusEventAsync("TOKEN_SUCCESS", registration); } } }
From source file:se.kth.ssvl.tslab.wsn.app.SensorListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sensor_list); cd = new ConnectionDetector(getApplicationContext()); // Check for Internet connection if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog(SensorListActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return;//from w w w . j a v a 2 s . co m } Intent i = getIntent(); gateway_id = i.getStringExtra("gateway_id"); // Hashmap for ListView sensorslist = new ArrayList<HashMap<String, String>>(); Log.d("sensorlist: ", "> "); // Load URL from settings URL_SENSOR = this.getPreferences(MODE_WORLD_READABLE).getString("server.url", getResources().getString(R.string.defaultWebServerUrl)); // Loading Sensors JSON in Background Thread new LoadSensors().execute(); ListView lv = getListView(); /** * Listview on item click listener DataListActivity will be lauched * by passing sensor id * */ lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) { // On selecting single sensor to get sensor data Intent i = new Intent(getApplicationContext(), DataListActivity.class); // to get sensors data, sensor id is needed String sensor_name = ((TextView) view.findViewById(R.id.sensor_name)).getText().toString(); String sensor_id = ((TextView) view.findViewById(R.id.sensor_id)).getText().toString(); Toast.makeText(getApplicationContext(), "gateway Id: " + gateway_id + ", Sensor Id: " + sensor_id, Toast.LENGTH_SHORT).show(); i.putExtra("sensor_id", sensor_id); i.putExtra("sensor_name", sensor_name); startActivity(i); } }); }