List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.scigames.slidegame.MenuActivity.java
@Override protected void onNewIntent(Intent i) { //for the 2nd, 3rd, 4th... time we arrive at Menu Activity. Log.d(TAG, "onNewIntent"); rfidIn = i.getStringExtra("rfid"); studentIdIn = i.getStringExtra("studentId"); slideLevelIn = i.getStringExtra("slideLevel"); massIn = i.getStringExtra("mass"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); ;/*from w ww . j a v a 2s .c o m*/ visitIdIn = i.getStringExtra("visitId"); photoUrl = i.getStringExtra("photo"); photoUrl = baseDbURL + "/" + photoUrl; Log.d(TAG, "Menu Activity INs: "); Log.d(TAG, rfidIn + studentIdIn + slideLevelIn + massIn); displayProfile(); }
From source file:org.andrico.andrico.facebook.FBBase.java
/** * When a LoginActivity activity returns a LOGIN_REQUEST, parse its * response./*from w ww. j a v a 2 s . c o m*/ * * @param resultCode * @param data */ public Boolean handleLoginActivityResult(Context context, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { setSession(data.getStringExtra(LoginActivity.SESSION_KEY_EXTRA), data.getStringExtra(LoginActivity.SECRET_EXTRA), data.getStringExtra(LoginActivity.UID_EXTRA)); return true; } else { return false; } }
From source file:org.geometerplus.android.fbreader.network.auth.WebAuthorisationScreen.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_PROGRESS); SQLiteCookieDatabase.init(this); CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie(); final Intent intent = getIntent(); final Uri data = intent.getData(); if (data == null || data.getHost() == null) { finish();//from w w w . ja v a2 s .c om return; } final String completeUrl = intent.getStringExtra(COMPLETE_URL_KEY); OrientationUtil.setOrientation(this, intent); final WebView view = new WebView(this); view.getSettings().setJavaScriptEnabled(true); view.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { setProgress(progress * 100); } }); view.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { setTitle(url); if (url != null && url.startsWith(completeUrl)) { final HashMap<String, String> cookies = new HashMap<String, String>(); final String cookieString = CookieManager.getInstance().getCookie(url); if (cookieString != null) { // cookieString is a string like NAME=VALUE [; NAME=VALUE] for (String pair : cookieString.split(";")) { final String[] parts = pair.split("=", 2); if (parts.length != 2) { continue; } cookies.put(parts[0].trim(), parts[1].trim()); } } storeCookies(data.getHost(), cookies); WebAuthorisationScreen.this.setResult(RESULT_OK); finish(); } } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1) { // hack for auth problem in android 2.1 handler.proceed(); } else { super.onReceivedSslError(view, handler, error); } } }); setContentView(view); view.loadUrl(intent.getDataString()); }
From source file:eu.inmite.apps.smsjizdenka.service.UpdateService.java
private void handleAuthorMessage(JSONObject versionJson, String lang, Intent intent, boolean fromPush) { String intentMessage = intent.getStringExtra("message"); if (fromPush && intentMessage != null) { NotificationUtil.notifyMessage(c, intentMessage); } else if (!fromPush) { String message = getStringLocValue(versionJson, lang, "msg"); if (!TextUtils.isEmpty(message)) { NotificationUtil.notifyMessage(c, message); }/*from w w w . j a va2 s . c o m*/ } }
From source file:com.hmsoft.bluetooth.le.DeviceControlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); setContentView(R.layout.gatt_services_characteristics); final Intent intent = getIntent(); mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME); mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS); // Sets up UI references. mDataField = (TextView) findViewById(R.id.data_value); edtSend = (EditText) this.findViewById(R.id.edtSend); edtSend.setText("www.jnhuamao.cn"); svResult = (ScrollView) this.findViewById(R.id.svResult); btnSend = (Button) this.findViewById(R.id.btnSend); btnSend.setOnClickListener(new ClickEvent()); btnSend.setEnabled(false);/*from ww w . j ava2 s . c o m*/ getActionBar().setTitle(mDeviceName); getActionBar().setDisplayHomeAsUpEnabled(true); Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); Log.d(TAG, "Try to bindService=" + bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE)); registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter()); }
From source file:net.olejon.mdapp.DonateActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); if (resultCode == RESULT_OK) { try { JSONObject purchaseDataJsonObject = new JSONObject(purchaseData); consumeDonation(purchaseDataJsonObject.getString("purchaseToken")); mTools.showToast(getString(R.string.donate_thank_you), 1); finish();/* w w w.ja v a 2 s .co m*/ } catch (Exception e) { mTools.showToast(getString(R.string.donate_something_went_wrong), 1); } } } }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void dispatchCommand(final Intent intent) { String cmd = intent.getStringExtra("cmdString"); String servelURL = intent.getStringExtra("serverUrl"); String deviceID = intent.getStringExtra("deviceID"); boolean local = intent.getBooleanExtra("local", false); Log.d(TAG, "dispatch cmd:" + cmd + " | servelURL:" + servelURL + " | deviceID:" + deviceID + " | local:" + local);//from w w w .j a v a 2 s . c om final Context context = getApplicationContext(); if (local) { if (TextUtils.isEmpty(servelURL)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_local_saddress_not_set))); } } else { if (TextUtils.isEmpty(deviceID)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_no_deviceid))); } if (TextUtils.isEmpty(servelURL)) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.msg_saddress_not_set))); } } RequestFuture<String> future = RequestFuture.newFuture(); CommandRequest request = new CommandRequest(local ? Request.Method.POST : Request.Method.GET, // diff servelURL, cmd, future, future); mRequestQueue.add(request); try { String response = future.get(request.getTimeoutMs() + 10000, TimeUnit.MILLISECONDS); Log.d(TAG, "get cmd response:" + response); saveAndNotify(intent, CommandRequest.getJsonStringResponse(200, response)); } catch (ExecutionException e) { Throwable error = e.getCause(); Log.d(TAG, "get cmd error:" + error.toString()); String errorString = context.getString(R.string.error_unknown); int errorCode = 400; if (error instanceof ServerError) { errorString = context.getString(R.string.chat_error_conn); errorCode = 400; } else if (error instanceof TimeoutError) { errorString = context.getString(R.string.chat_error_http_error); errorCode = 400; } else if (error instanceof ParseError) { errorString = context.getString(R.string.chat_error_http_error); errorCode = 400; } else if (error instanceof NoConnectionError) { errorString = context.getString(R.string.chat_error_no_connection_error); errorCode = 400; } saveAndNotify(intent, CommandRequest.getJsonStringResponse(errorCode, errorString)); } catch (TimeoutException e) { saveAndNotify(intent, CommandRequest.getJsonStringResponse(400, context.getString(R.string.chat_error_http_error))); } catch (Exception e) { future.cancel(true); e.printStackTrace(); // saveAndNotify(intent, // CommandRequest.getJsonStringResponse( // 400, // context.getString(R.string.error_internal) // )); } }
From source file:me.xingrz.prox.ProxVpnService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String configUrl = intent.getStringExtra(EXTRA_PAC_URL); if (running) { logger.d("Service already running, just reload config"); AutoConfigManager.getInstance().load(configUrl, null); return START_NOT_STICKY; } else {//w w w . ja v a 2s . c o m this.startId = startId; AutoConfigManager.getInstance().load(configUrl, this); return START_REDELIVER_INTENT; } }
From source file:com.he5ed.lib.cloudprovider.auth.OAuth2Fragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // retain web view state during rotation setRetainInstance(true);//from w w w . ja v a 2s . co m // get extra from intent Intent intent = getActivity().getIntent(); if (intent != null) { mCloudApi = intent.getStringExtra(OAuth2Activity.EXTRA_CLOUD_API); } else { // end activity getActivity().finish(); } mHttpClient = new OkHttpClient(); }
From source file:com.magnet.mmx.client.TestMmxPush.java
@SmallTest public void testPushMessageParsePush() throws JSONException { PushMessage pushMessage = PushMessage.decode(TEST_PUSH_STRING, null); assertTrue(pushMessage.getAction() == PushMessage.Action.PUSH); GCMPayload gcmPayload = (GCMPayload) pushMessage.getPayload(); assertTrue(("mmx:p:" + Constants.PingPongCommand.notify.name()) .equals(gcmPayload.getMmx().get(Constants.PAYLOAD_TYPE_KEY))); String idString = (String) gcmPayload.getMmx().get(Constants.PAYLOAD_ID_KEY); assertEquals(ID_VALUE, idString);/*w w w. ja va 2 s .com*/ String urlString = (String) gcmPayload.getMmx().get(Constants.PAYLOAD_CALLBACK_URL_KEY); assertEquals(CALLBACK_URL, urlString); assertEquals(CHIME_AIFF, gcmPayload.getSound()); assertEquals(ORDER_STRING, gcmPayload.getBody()); assertEquals(ORDER_STATUS, gcmPayload.getTitle()); assertEquals(SIMPLE_ICON, gcmPayload.getIcon()); Map<String, Object> customString = (Map<String, Object>) gcmPayload.getMmx() .get(Constants.PAYLOAD_CUSTOM_KEY); JSONObject jsonObject = new JSONObject(customString); assertEquals(DO_SOMETHING_IMMEDIATELY, jsonObject.getString("action")); assertEquals(IMAGE_URL, jsonObject.get("URL")); assertEquals(1, jsonObject.getInt("priority")); assertTrue(jsonObject.has("jsontext")); String jsonText = jsonObject.getString("jsontext"); JSONObject json = new JSONObject(jsonText); assertEquals(RAHULS_MAC_BOOK_PRO_LOCAL, json.getString("from")); assertEquals(ID_VALUE, json.getString("id")); assertEquals(SELECTOR_FETCH_MESSAGE, json.getString("action")); // now format it as an Intent Intent pushIntent = MMXWakeupIntentService.buildPushIntent(gcmPayload); assertEquals(MMXClient.ACTION_PUSH_RECEIVED, pushIntent.getAction()); assertEquals(ID_VALUE, pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_ID)); assertEquals(ORDER_STRING, pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_BODY)); assertEquals(ORDER_STATUS, pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_TITLE)); assertEquals(CHIME_AIFF, pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_SOUND)); assertEquals(SIMPLE_ICON, pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_ICON)); String jsonString = pushIntent.getStringExtra(MMXClient.EXTRA_PUSH_CUSTOM_JSON); JSONObject jsonObject2 = new JSONObject(jsonString); assertEquals(jsonObject.length(), jsonObject2.length()); }