List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:com.csipsimple.plugins.twvoip.CallHandler.java
@Override public void onReceive(Context context, Intent intent) { if (ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { PendingIntent pendingIntent = null; // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr) && !TextUtils.isEmpty(pwd)) { // Build pending intent Intent i = new Intent(ACTION_DO_TWVOIP_CALL); i.setClass(context, getClass()); i.putExtra(Intent.EXTRA_PHONE_NUMBER, number); pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); // = PendingIntent.getActivity(context, 0, i, 0); }/*from w ww .j a v a 2s.c o m*/ // Build icon Bitmap bmp = null; Drawable icon = context.getResources().getDrawable(R.drawable.icon); BitmapDrawable bd = ((BitmapDrawable) icon); bmp = bd.getBitmap(); // Build the result for the row (label, icon, pending intent, and // excluded phone number) Bundle results = getResultExtras(true); if (pendingIntent != null) { results.putParcelable(Intent.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); } results.putString(Intent.EXTRA_TITLE, "12voip WebCallback"); if (bmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp); } // DO *NOT* exclude from next tel: intent cause we use a http method // results.putString(Intent.EXTRA_PHONE_NUMBER, number); } else if (ACTION_DO_TWVOIP_CALL.equals(intent.getAction())) { // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // params List<NameValuePair> params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("username", user)); params.add(new BasicNameValuePair("password", pwd)); params.add(new BasicNameValuePair("from", nbr)); params.add(new BasicNameValuePair("to", number)); String paramString = URLEncodedUtils.format(params, "utf-8"); String requestURL = "https://www.12voip.com//myaccount/makecall.php?" + paramString; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(requestURL); // Create a response handler HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == 200) { InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent()); BufferedReader br = new BufferedReader(isr); String line; String fullReply = ""; boolean foundSuccess = false; while ((line = br.readLine()) != null) { if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) { showToaster(context, "Success... wait a while you'll called back"); foundSuccess = true; break; } if (!TextUtils.isEmpty(line)) { fullReply = fullReply.concat(line); } } if (!foundSuccess) { showToaster(context, "Error : server error : " + fullReply); } } else { showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode()); } } catch (ClientProtocolException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } catch (IOException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } } }
From source file:de.Maxr1998.xposed.maxlock.ui.ThemeService.java
@Override protected void onHandleIntent(Intent intent) { Log.d("MaxLock/ThemeService", "Intent received"); themeFile = new File(Util.dataDir(this) + File.separator + "shared_prefs" + File.separator + themeOrigFile); int extra = intent.getIntExtra("extra", -1); switch (extra) { case 1://w ww. ja va 2s. c om importTheme(intent.getStringExtra("package")); break; case 2: clearUp(); break; } }
From source file:com.subzero.runners.android.AndroidLauncher.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent 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) { try { JSONObject jo = new JSONObject(purchaseData); String sku = jo.getString("productId"); String name = null; if (sku.equals("ryan")) name = "Ryan"; else if (sku.equals("ash")) name = "Ash"; else if (sku.equals("rob")) name = "Rob"; else if (sku.equals("battle_cat")) name = "BattleCat"; else if (sku.equals("xorp")) name = "Xorp"; else if (sku.equals("rootsworth")) name = "Rootsworth"; else if (sku.equals("snap")) name = "Snap"; else if (sku.equals("metatron")) name = "Metatron"; else if (sku.equals("abaddon")) name = "Abaddon"; pref.putBoolean(name, true); pref.flush();/*w w w .j ava2 s . c o m*/ } catch (JSONException e) { // alert("Failed to parse purchase data."); e.printStackTrace(); } } } super.onActivityResult(requestCode, resultCode, data); _gameHelper.onActivityResult(requestCode, resultCode, data); }
From source file:io.clh.lrt.androidservice.TraceListenerService.java
private void traceEventStop(Context context, Intent intent) { JSONObject jsonData = new JSONObject(); String appName = intent.getStringExtra("appName"); traceEvent(context, intent);// w w w . j a va 2 s . c o m Log.d(TAG, "trace done: " + intent.toString()); appLut.remove(appName); }
From source file:com.bdcorps.videonews.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); topicCode = intent.getStringExtra("topicCode"); //if it's a string you stored. //CCT Connection mConnection = new CustomTabsServiceConnection() { @Override/* w ww . j a v a2 s .c o m*/ public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) { mClient = customTabsClient; mCustomTabsSession = getSession(); mClient.warmup(0); } @Override public void onServiceDisconnected(ComponentName componentName) { mClient = null; mCustomTabsSession = null; } }; //Bind CCT Service String packageName = "com.android.chrome"; CustomTabsClient.bindCustomTabsService(this, packageName, mConnection); text = (TextView) findViewById(R.id.textview); img = (ImageView) findViewById(R.id.imageview); titleTextView = (TextView) findViewById(R.id.title_text_view); mTts = new TextToSpeech(this, this); Button b1 = (Button) findViewById(R.id.button); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { grabnews(topicCode); } }); Button b2 = (Button) findViewById(R.id.button2); b2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { speak(text.getText().toString()); } }); Button b3 = (Button) findViewById(R.id.button3); b3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { article++; grabnews(topicCode); } }); text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { Log.i("SSS", "text on board is =" + editable.toString()); speak(text.getText().toString()); } }); }
From source file:com.lsb.inomet.Inomet.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); primera_vez = false;/*ww w .j a va 2 s . c o m*/ if (requestCode == DIR_WEB) { // cogemos el valor devuelto por la otra actividad direccionWeb = data.getStringExtra("DirEstacion"); // enseamos al usuario el resultado //Toast.makeText(this, "Config devolvi: " + result, Toast.LENGTH_LONG).show(); datuak_irakurri(); } }
From source file:at.mg.androidfeatures.activities.GoogleServiceTest.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_ACCOUNTPICKER: if (resultCode == RESULT_OK) { String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); AccountUtils.setAccountName(this, accountName); Log.i(accountName);/* w w w. j a v a 2 s .c om*/ } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "This application requires a Google account.", Toast.LENGTH_SHORT).show(); finish(); } return; case REQUEST_CODE_RECOVER_PLAY_SERVICES: if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Google Play Services must be installed.", Toast.LENGTH_SHORT).show(); finish(); } return; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.google.android.apps.muzei.SourceSubscriberService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;/* w w w . j a v a 2s. c o m*/ } String action = intent.getAction(); if (!ACTION_PUBLISH_STATE.equals(action)) { return; } // Handle API call from source String token = intent.getStringExtra(EXTRA_TOKEN); ComponentName selectedSource = SourceManager.getSelectedSource(this); if (selectedSource == null || !TextUtils.equals(token, selectedSource.flattenToShortString())) { Log.w(TAG, "Dropping update from non-selected source, token=" + token + " does not match token for " + selectedSource); return; } SourceState state = null; if (intent.hasExtra(EXTRA_STATE)) { Bundle bundle = intent.getBundleExtra(EXTRA_STATE); if (bundle != null) { state = SourceState.fromBundle(bundle); } } if (state == null) { // If there is no state, there is nothing to change return; } ContentValues values = new ContentValues(); values.put(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME, selectedSource.flattenToShortString()); values.put(MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED, true); values.put(MuzeiContract.Sources.COLUMN_NAME_DESCRIPTION, state.getDescription()); values.put(MuzeiContract.Sources.COLUMN_NAME_WANTS_NETWORK_AVAILABLE, state.getWantsNetworkAvailable()); JSONArray commandsSerialized = new JSONArray(); int numSourceActions = state.getNumUserCommands(); boolean supportsNextArtwork = false; for (int i = 0; i < numSourceActions; i++) { UserCommand command = state.getUserCommandAt(i); if (command.getId() == MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK) { supportsNextArtwork = true; } else { commandsSerialized.put(command.serialize()); } } values.put(MuzeiContract.Sources.COLUMN_NAME_SUPPORTS_NEXT_ARTWORK_COMMAND, supportsNextArtwork); values.put(MuzeiContract.Sources.COLUMN_NAME_COMMANDS, commandsSerialized.toString()); ContentResolver contentResolver = getContentResolver(); Cursor existingSource = contentResolver.query(MuzeiContract.Sources.CONTENT_URI, new String[] { BaseColumns._ID }, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + "=?", new String[] { selectedSource.flattenToShortString() }, null, null); if (existingSource != null && existingSource.moveToFirst()) { Uri sourceUri = ContentUris.withAppendedId(MuzeiContract.Sources.CONTENT_URI, existingSource.getLong(0)); contentResolver.update(sourceUri, values, null, null); } else { contentResolver.insert(MuzeiContract.Sources.CONTENT_URI, values); } if (existingSource != null) { existingSource.close(); } Artwork artwork = state.getCurrentArtwork(); if (artwork != null) { artwork.setComponentName(selectedSource); contentResolver.insert(MuzeiContract.Artwork.CONTENT_URI, artwork.toContentValues()); // Download the artwork contained from the newly published SourceState startService(TaskQueueService.getDownloadCurrentArtworkIntent(this)); } }
From source file:com.snappy.GCMIntentService.java
/** * Method called on Receiving a new message * *///from w w w .j a v a 2 s .c om @Override protected void onMessage(Context context, Intent intent) { db = new LocalDB(context); Bundle pushExtras = intent.getExtras(); String pushMessage = intent.getStringExtra(Const.PUSH_MESSAGE); String pushFromName = intent.getStringExtra(Const.PUSH_FROM_NAME); String pushMessageBody = intent.getStringExtra(Const.PUSH_FROM_MESSAGE_BODY); String pushMessaBodyStyled = pushFromName + ": " + pushMessageBody; db.writeMessage(pushMessaBodyStyled); try { boolean appIsInForeground = new SpikaApp.ForegroundCheckAsync().execute(getApplicationContext()).get(); boolean screenLocked = ((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode(); if (appIsInForeground && !screenLocked) { mPushBroadcast.replaceExtras(pushExtras); LocalBroadcastManager.getInstance(this).sendBroadcast(mPushBroadcast); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } else { //triggerNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } }
From source file:net.gromgull.android.bibsonomyposter.BibsonomyPosterActivity.java
/** Called with the activity is first created. */ @Override/*from w ww .j a va 2 s . c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); load(); Intent intent = getIntent(); String action = intent.getAction(); if (action.equalsIgnoreCase(Intent.ACTION_SEND)) { final String uri = intent.getStringExtra(Intent.EXTRA_TEXT); final String title = intent.getStringExtra(Intent.EXTRA_SUBJECT); final Context context = getApplicationContext(); new AsyncTask<Void, Integer, Boolean>() { @Override protected Boolean doInBackground(Void... v) { try { bookmark(uri, title); return true; } catch (Exception e) { Log.w(LOGTAG, "Could not bookmark: " + title + " / " + uri, e); return false; } } protected void onPostExecute(Boolean result) { if (result) { Toast toast = Toast.makeText(context, "Bookmarked " + title, Toast.LENGTH_SHORT); toast.show(); } else { Toast toast = Toast.makeText(context, "Error bookmarking " + title, Toast.LENGTH_SHORT); toast.show(); } } }.execute(); finish(); return; } // Inflate our UI from its XML layout description. setContentView(R.layout.bibsonomyposter_activity); if (username != null) ((EditText) findViewById(R.id.username)).setText(username); if (apikey != null) ((EditText) findViewById(R.id.apikey)).setText(apikey); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.save)).setOnClickListener(mSaveListener); }