List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:io.teak.sdk.service.RavenService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { String appId = intent.getStringExtra("appId"); if (appId != null && !appId.isEmpty()) { AppReporter appReporter;//from ww w .j a va 2 s. co m if (!appReporterMap.containsKey(appId)) { appReporter = new AppReporter(this, appId); appReporterMap.put(appId, appReporter); } else { appReporter = appReporterMap.get(appId); } String action = intent.getAction(); if (action != null && !action.isEmpty()) { if (SET_DSN_INTENT_ACTION.equals(action)) { appReporter.setDsn(intent); } else if (REPORT_EXCEPTION_INTENT_ACTION.equals(action)) { appReporter.reportException(intent); } } } } return START_STICKY; }
From source file:org.runnerup.export.RunningAHEADSynchronizer.java
@Override public Status getAuthResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG); try {//w w w . j a v a 2 s .c om access_token = new JSONObject(authConfig).getString("access_token"); return Status.OK; } catch (JSONException e) { e.printStackTrace(); } } return Status.ERROR; }
From source file:com.novoda.imageloader.core.service.CacheCleanerTest.java
private Intent prepareStandardIntent() { Intent i = Mockito.mock(Intent.class); when(i.getAction()).thenReturn(CacheCleaner.CLEAN_CACHE_ACTION); when(i.hasExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(true); when(i.getStringExtra(CacheCleaner.CACHE_DIR_EXTRA)).thenReturn(cacheDir.getAbsolutePath()); return i;//from w w w. j av a 2 s.c o m }
From source file:se.kth.ssvl.tslab.wsn.app.DataListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_data_content); cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog(DataListActivity.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 . c o m*/ } Intent i = getIntent(); // getting attached intent data; sensor_id = i.getStringExtra("sensor_id"); sensor_name = i.getStringExtra("sensor_name"); datalist = new ArrayList<HashMap<String, Object>>(); // Get the URL from settings URL_DATA = this.getPreferences(MODE_WORLD_READABLE).getString("server.url", getResources().getString(R.string.defaultWebServerUrl)); new Data().execute(); Log.d("data: ", "> "); ListView lv = getListView(); /* Listview on item click listener */ lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) { // on click method } }); }
From source file:com.team1.soccerplayers.layout.PlayerInfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check whether we're recreating a previously destroyed instance if (savedInstanceState != null) { // Restore value of members from saved state playerName = savedInstanceState.getString(STATE_PLAYER); } else {//from w w w.j av a 2s. co m // Probably initialize members with default values for a new instance setContentView(R.layout.activity_player_info); Intent intent = getIntent(); playerName = intent.getStringExtra(DisplayFavoritePlayersActivity.EXTRA_MESSAGE); } if (playerName.contains(" ")) { firstName = playerName.split(" "); } if (playerName.contains(" ")) { APILink = "https://api.datamarket.azure.com/Bing/Search/v1/News?Query=%27" + firstName[0].trim() + "%20" + firstName[1].trim() + "%20%27&$format=json"; } else { APILink = "https://api.datamarket.azure.com/Bing/Search/v1/News?Query=%27" + playerName + "%20%27&$format=json"; } //Toast.makeText(PlayerInfoActivity.this, "resrult: " + playerName, Toast.LENGTH_SHORT).show(); ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { DownloadTask downloadTask = new DownloadTask(); downloadTask.execute(); } else { Toast.makeText(PlayerInfoActivity.this, "Unable to Connect to the server, Please try later.", Toast.LENGTH_SHORT).show(); } infoListView = (ListView) findViewById(android.R.id.list); final TextView title1 = new TextView(this); final TextView summary1 = new TextView(this); infoListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { HashMap<String, String> map = (HashMap<String, String>) infoListView.getItemAtPosition(position); page = map.get("Url"); int fadedTitleColor = getResources().getColor(R.color.marked_as_read_title_text); int fadedSummaryColor = getResources().getColor(R.color.marked_as_read_summary_text); profileView(view); } }); }
From source file:com.mobilesolutionworks.android.httpcache.WorksHttpCacheService.java
protected void refreshData(Intent intent) { // rebuild into hierarchical uri String local = intent.getStringExtra("local"); String remote = intent.getStringExtra("remote"); if (mQueues.contains(local)) { return;//from w w w . j av a2 s.c o m } mQueues.add(local); String _method = intent.getStringExtra("method"); WorksHttpRequest.Method method = WorksHttpRequest.Method.GET; if ("POST".equals(_method)) { method = WorksHttpRequest.Method.POST; } WorksHttpRequest config = new WorksHttpRequest(); config.method = method; config.url = remote; Bundle params = intent.getBundleExtra("params"); if (params != null) { for (String key : params.keySet()) { String value = params.getString(key); if (!TextUtils.isEmpty(value)) { config.setPostParam(key, value); } } } int cache = intent.getIntExtra("cache", 0); if (cache == 0) { cache = 60; } cache *= 1000; int timeout = intent.getIntExtra("timeout", 0); if (timeout == 0) { timeout = 10; } timeout *= 1000; WorksHttpFutureTask<String> task = getSaveTask(local, cache, timeout); task.execute(config, mHandler, mExecutors); }
From source file:com.google.android.gcm.GCMBaseIntentService.java
private void handleRegistration(final Context context, Intent intent) { String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID); String error = intent.getStringExtra(EXTRA_ERROR); String unregistered = intent.getStringExtra(EXTRA_UNREGISTERED); Log.d(TAG, "handleRegistration: registrationId = " + registrationId + ", error = " + error + ", unregistered = " + unregistered); // registration succeeded if (registrationId != null) { GCMRegistrar.resetBackoff(context); GCMRegistrar.setRegistrationId(context, registrationId); onRegistered(context, registrationId); return;/*from w ww .j a va 2s .c o m*/ } // unregistration succeeded if (unregistered != null) { // Remember we are unregistered GCMRegistrar.resetBackoff(context); String oldRegistrationId = GCMRegistrar.clearRegistrationId(context); onUnregistered(context, oldRegistrationId); return; } // last operation (registration or unregistration) returned an error; Log.d(TAG, "Registration error: " + error); // Registration failed if (ERROR_SERVICE_NOT_AVAILABLE.equals(error)) { boolean retry = onRecoverableError(context, error); if (retry) { int backoffTimeMs = GCMRegistrar.getBackoff(context); int nextAttempt = backoffTimeMs / 2 + sRandom.nextInt(backoffTimeMs); Log.d(TAG, "Scheduling registration retry, backoff = " + nextAttempt + " (" + backoffTimeMs + ")"); Intent retryIntent = new Intent(INTENT_FROM_GCM_LIBRARY_RETRY); retryIntent.putExtra(EXTRA_TOKEN, TOKEN); PendingIntent retryPendingIntent = PendingIntent.getBroadcast(context, 0, retryIntent, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + nextAttempt, retryPendingIntent); // Next retry should wait longer. if (backoffTimeMs < MAX_BACKOFF_MS) { GCMRegistrar.setBackoff(context, backoffTimeMs * 2); } } else { Log.d(TAG, "Not retrying failed operation"); } } else { // Unrecoverable error, notify app onError(context, error); } }
From source file:com.google.zxing.client.android.plugin.BarcodeScanner.java
/** * Called when the barcode scanner intent completes * * @param requestCode The request code originally supplied to startActivityForResult(), * allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). *//* w w w . j a v a 2s. com*/ public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, intent.getStringExtra("result")); obj.put(FORMAT, intent.getStringExtra("format")); obj.put(CANCELLED, false); } catch (JSONException e) { //Log.d(LOG_TAG, "This should never happen"); } this.cbContext.success(obj); } else if (resultCode == Activity.RESULT_CANCELED) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, ""); obj.put(FORMAT, ""); obj.put(CANCELLED, true); } catch (JSONException e) { //Log.d(LOG_TAG, "This should never happen"); } this.cbContext.success(obj); } else { this.cbContext.error("Invalid Activity"); } } }
From source file:com.mgalgs.trackthatthing.LocationReceiver.java
@Override public void onReceive(Context context, Intent intent) { mContext = context;/*from w w w . j av a 2 s . c o m*/ Location loc = (Location) intent.getExtras().get(LocationPoller.EXTRA_LOCATION); if (loc == null) { msg = intent.getStringExtra(LocationPoller.EXTRA_ERROR); } else { SharedPreferences settings = context.getSharedPreferences(TrackThatThing.PREFS_NAME, Context.MODE_PRIVATE); long sleep_period = settings.getLong(TrackThatThing.PREF_SLEEP_TIME, TrackThatThing.DEFAULT_SLEEP_TIME); if (getTimeSinceLastLoc_S() > sleep_period - 3 || mLastLocTime == -1) { // it has been long enough } else { // it hasn't been long enough! Log.d(TrackThatThing.TAG, "It has only been " + getTimeSinceLastLoc_S() + " seconds since the last location update, not long enough!"); return; } mLastLocTime = SystemClock.elapsedRealtime(); float acc = loc.getAccuracy(); double lat = loc.getLatitude(); double lon = loc.getLongitude(); float speed = loc.getSpeed(); String secret_code = settings.getString(TrackThatThing.PREF_SECRET_CODE, null); QueryString qs = new QueryString(TrackThatThing.BASE_URL + "/put"); qs.add("secret", secret_code); qs.add("lat", Double.toString(lat)); qs.add("lon", Double.toString(lon)); qs.add("acc", Float.toString(acc)); qs.add("speed", Float.toString(speed)); Runnable r = new MyInternetThread(qs); new Thread(r).start(); msg = loc.toString(); } Log.d(TrackThatThing.TAG, "got this location: " + msg); }
From source file:com.BeeFramework.activity.MainActivity.java
/** * ?Intent//from w w w .ja v a 2s.com * * @param intent * intent */ private void handleIntent(Intent intent) { String action = intent.getAction(); if (ACTION_RESPONSE.equals(action)) { String method = intent.getStringExtra(RESPONSE_METHOD); if (PushConstants.METHOD_BIND.equals(method)) { int errorCode = intent.getIntExtra(RESPONSE_ERRCODE, 0); if (errorCode == 0) { String content = intent.getStringExtra(RESPONSE_CONTENT); String appid = ""; String channelid = ""; String userid = ""; try { JSONObject jsonContent = new JSONObject(content); JSONObject params = jsonContent.getJSONObject("response_params"); appid = params.getString("appid"); channelid = params.getString("channel_id"); userid = params.getString("user_id"); editor.putString("UUID", userid); editor.commit(); } catch (JSONException e) { } } else { } } } else if (ACTION_LOGIN.equals(action)) { String accessToken = intent.getStringExtra(EXTRA_ACCESS_TOKEN); PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN, accessToken); } else if (ACTION_MESSAGE.equals(action)) { String message = intent.getStringExtra(EXTRA_MESSAGE); String summary = "Receive message from server:\n\t"; JSONObject contentJson = null; String contentStr = message; try { contentJson = new JSONObject(message); contentStr = contentJson.toString(4); } catch (JSONException e) { } summary += contentStr; } else if (ACTION_PUSHCLICK.equals(action)) { String message = intent.getStringExtra(CUSTOM_CONTENT); } }