List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:de.electricdynamite.pasty.GCMIntentService.java
@SuppressLint("NewApi") @Override//from w ww.j ava2 s . com protected void onMessage(Context context, Intent intent) { if (prefs == null) this.prefs = new PastyPreferencesProvider(context); final Bundle extras = intent.getExtras(); if (extras == null) { Log.i(TAG, "onMessage(): Empty intent received"); return; } final String mItemId = extras.getString("itemId"); final String mItemStr = extras.getString("item"); final int mEventId = Integer.parseInt(extras.getString("eventId")); if (mItemId == null || mItemStr == null || mItemId == "" || mItemStr == "") { Log.i(TAG, "onMessage(): Invalid intent received"); return; } if (LOCAL_LOG) Log.v(TAG, "onMessage(): Received message for event: " + mEventId); switch (mEventId) { case EVENT_ITEM_ADDED: final String lastItemId = prefs.getLastItem(); if (mItemId.equals(lastItemId)) return; if (client == null) { client = new PastyClient(prefs.getRESTBaseURL(), true); client.setUsername(prefs.getUsername()); client.setPassword(prefs.getPassword()); } final ClipboardItem mItem = new ClipboardItem(mItemId, mItemStr); final Boolean mPush = prefs.getPush(); final Boolean mCopyToClipboard = prefs.getPushCopyToClipboard(); final Boolean mNotify = prefs.getPushNotify(); if (mPush == true) { if (mCopyToClipboard == true) { if (mItem.getText() != "") { Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); startService(resultIntent); resultIntent = null; } } else { if (mNotify == true) { String contentText = String.format(getString(R.string.notification_event_add_text), mItem.getText()); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_pasty) .setContentTitle(getString(R.string.notification_event_add_title)) .setContentText(contentText).setAutoCancel(Boolean.TRUE); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); PendingIntent resultPendingIntent = PendingIntent.getService(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(PastySharedStatics.NOTIFICATION_ID, mBuilder.build()); } } JSONArray clipboard = null; try { clipboard = client.getClipboard(); cacheClipboard(clipboard); } catch (PastyException e) { if (LOCAL_LOG) Log.v(TAG, "Could not get clipboard: " + e.getMessage()); } } break; default: Log.i(TAG, "onMessage(): Unsupported event: " + mEventId); break; } /* TODO Make ClipboardFragment react to changes from GCMIntentService */ }
From source file:com.octade.droid.ilesansfil.IleSansFil.java
/** Called when the activity is first created. */ @Override/*from w ww . j a v a 2 s .com*/ public void onCreate(Bundle inState) { super.onCreate(inState); if (inState != null) { Log.i(CURRENTMODULE, "Creating From Bundle :" + inState.getString("DDD")); try { Date d = DateUtils.parseDate(inState.getString("DDD")); Date now = new Date(); if ((now.getTime() - d.getTime()) > (1000 * 3600 * 24)) { Log.i(CURRENTMODULE, "More than 1 day on Sleep"); } } catch (DateParseException e) { // TODO Auto-generated catch block Log.i(CURRENTMODULE, "State date cannot be read"); } } else { Log.i(CURRENTMODULE, "Creating From Scratch:"); } mainApp = (IleSansFilApp) getApplication(); setContentView(R.layout.main); setupTabs(); ToggleButton button1 = (ToggleButton) findViewById(R.id.ToggleButton01); button1.setOnClickListener(wifiEnableClickListener); Button button2 = (Button) findViewById(R.id.Button01); button2.setOnClickListener(wifiSettingClickListener); Button button3 = (Button) findViewById(R.id.hotSpotLocateButton); button3.setOnClickListener(findHotSpotClickListener); mainApp.setMainActivity(this); }
From source file:com.example.parking.ParkingInformationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDBAdapter = new DBAdapter(this); setContentView(R.layout.activity_parking_information); mParkNameTV = (TextView) findViewById(R.id.tv_parking_name); mParkNameTV.setText(R.string.park_name_fixed); mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number); mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed)); mCarType = (Spinner) findViewById(R.id.sp_car_type); mParkingType = (Spinner) findViewById(R.id.sp_parking_type); mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location); mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number); Intent intent = getIntent();/*ww w . j av a 2 s . c o m*/ Bundle bundle = intent.getExtras(); mLicensePlateNumberTV.setText(bundle.getString("licensePlate")); mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving); new TimeThread().start(); mOkButton = (Button) findViewById(R.id.bt_confirm_arriving); mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(), mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(), Integer.parseInt(mLocationNumber.getSelectedItem().toString()), DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null, "")); mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving); mPhotoBT.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mEnterImage != null) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT) .show(); } else { openTakePhoto(); } } }); mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving); mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving); mEnterImageIV.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create(); ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image); Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image); img.setImageBitmap(mEnterImage); dialog.setView(imgEntryView); // dialog dialog.show(); imgEntryView.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { dialog.cancel(); } }); deleteBT.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { mEnterImage = null; mEnterImageIV.setImageResource(drawable.ic_photo_background_64px); dialog.cancel(); } }); } }); getActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter filter = new IntentFilter(); filter.addAction("ExitApp"); registerReceiver(mReceiver, filter); }
From source file:com.android.idearse.Result.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.result);/* w w w.ja v a 2s . c o m*/ getWindow().getAttributes().windowAnimations = R.style.Fade; Bundle extras = getIntent().getExtras(); QR = extras.getString("qr"); preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); type = preferences.getString("type", ""); preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sessionid = preferences.getString("sessionid", ""); session_name = preferences.getString("session_name", ""); token = preferences.getString("token", ""); nid = preferences.getString("place_id", ""); loadima = (ImageView) findViewById(R.id.loading); rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.drawable.rotate_loading); rotation.setRepeatCount(Animation.INFINITE); loadima.startAnimation(rotation); ActionBar actionBar = getSupportActionBar(); setTitle(""); getSupportActionBar().setIcon(R.drawable.title_logo); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); Button qr_again2 = (Button) findViewById(R.id.detect_again2); Button qr_again = (Button) findViewById(R.id.detect_again); Button call = (Button) findViewById(R.id.call); qr_again2.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { if (isCameraAvailable()) { Intent intent = new Intent(getApplicationContext(), ZBarScannerActivity.class); intent.putExtra(ZBarConstants.SCAN_MODES, new int[] { Symbol.QRCODE }); startActivityForResult(intent, ZBAR_QR_SCANNER_REQUEST); } else { Intent goToLogin = new Intent(getApplicationContext(), Login.class); startActivity(goToLogin); } } }); qr_again.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { if (isCameraAvailable()) { Intent intent = new Intent(getApplicationContext(), ZBarScannerActivity.class); intent.putExtra(ZBarConstants.SCAN_MODES, new int[] { Symbol.QRCODE }); startActivityForResult(intent, ZBAR_QR_SCANNER_REQUEST); } else { Intent goToLogin = new Intent(getApplicationContext(), Login.class); startActivity(goToLogin); } } }); call.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent goToCall = new Intent(getApplicationContext(), Call.class); startActivity(goToCall); } }); if (type.contains("treballador")) { new QRquery().execute( getString(R.string.URL) + "conectar_mobil/trabajadores.json?nid=" + nid + "&nif=" + QR); } else if (type.contains("maquines")) { new QRquery().execute( getString(R.string.URL) + "conectar_mobil/maquinas.json?nid=" + nid + "&matricula=" + QR); } }
From source file:com.geozen.demo.foursquare.jiramot.Foursquare.java
private void startDialogAuth(Context activity) { CookieSyncManager.createInstance(activity); Bundle params = new Bundle(); dialog(activity, LOGIN, params, new DialogListener() { public void onComplete(Bundle values) { // ensure any cookies set by the dialog are saved CookieSyncManager.getInstance().sync(); String _token = values.getString(TOKEN); setAccessToken(_token);//from www.ja va 2 s .c o m if (isSessionValid()) { Log.d("Foursquare-authorize", "Login Success! access_token=" + getAccessToken()); mAuthDialogListener.onComplete(values); } else { mAuthDialogListener.onFoursquareError(new FoursquareError("Failed to receive access token.")); } } public void onError(DialogError error) { Log.d("Foursquare-authorize", "Login failed: " + error); mAuthDialogListener.onError(error); } public void onFoursquareError(FoursquareError error) { Log.d("Foursquare-authorize", "Login failed: " + error); mAuthDialogListener.onFoursquareError(error); } public void onCancel() { Log.d("Foursquare-authorize", "Login canceled"); mAuthDialogListener.onCancel(); } }); }
From source file:org.cloudfoundry.android.cfdroid.CloudFoundry.java
/** * Makes sure that we have a reference to a non-null * {@link CloudFoundryClient} object./*ww w .j av a 2 s.c o m*/ * */ private void ensureClient() { if (cache.client != null) { return; } try { AccountManagerFuture<Bundle> future = accountManager.getAuthTokenByFeatures(Accounts.ACCOUNT_TYPE, Accounts.ACCOUNT_TYPE, new String[0], activity, null, null, null, null); Bundle bundle = future.getResult(); String targetURL = Accounts.extractTarget(bundle.getString(AccountManager.KEY_ACCOUNT_NAME)); cache.token = bundle.getString(AccountManager.KEY_AUTHTOKEN); cache.client = new CloudFoundryClient(cache.token, targetURL); } catch (Exception e) { Ln.e(e, "Logged from here"); } }
From source file:luis.clientebanco.OAuth.UrbankOAuth.java
public void urbankLogin(Context mContext) { webService = new WebService(); String authRequestRedirect = AppContext.UB_APP_OAUTH_URL + "?client_id=" + AppContext.UB_CLIENT_ID + "&redirect_uri=" + AppContext.UB_APP_REDIRECT + "&response_type=code" + "&scope=permission_read_transaction"; if (LOGGING.DEBUG) Log.d(TAG, "authRequestRedirect->" + authRequestRedirect); new UrbankOAuthDialog(mContext, authRequestRedirect, new GenericDialogListener() { public void onComplete(Bundle values) { if (LOGGING.DEBUG) Log.d(TAG, "onComplete->" + values); accessCode = ""; try { accessCode = values.getString("code"); new urbankAccessToken().execute(); } catch (Exception ex1) { Log.w(TAG, ex1.toString()); accessCode = null;//from ww w. j av a2 s .c o m } Log.v(TAG, "prueba"); } public void onError(String e) { if (LOGGING.DEBUG) Log.d(TAG, "onError->" + e); } public void onCancel() { if (LOGGING.DEBUG) Log.d(TAG, "onCancel()"); } }).show(); }
From source file:net.idlesoft.android.apps.github.activities.Repository.java
@Override protected void onRestoreInstanceState(final Bundle savedInstanceState) { try {/*from w ww . j a v a 2s. c o m*/ if (savedInstanceState.containsKey("json")) { mJson = new JSONObject(savedInstanceState.getString("json")); } if (mJson != null) { loadRepoInfo(); } } catch (final JSONException e) { e.printStackTrace(); } super.onRestoreInstanceState(savedInstanceState); }
From source file:com.commontime.plugin.notification.Notification.java
private static JSONObject convertBundleToJson(Bundle extras) { try {//w w w .j a va2 s . co m JSONObject json; json = new JSONObject().put("event", "message"); Iterator<String> it = extras.keySet().iterator(); while (it.hasNext()) { String key = it.next(); Object value = extras.get(key); // System data from Android if (key.equals("from") || key.equals("collapse_key")) { json.put(key, value); } else if (key.equals("foreground")) { json.put(key, extras.getBoolean("foreground")); } else if (key.equals("coldstart")) { json.put(key, extras.getBoolean("coldstart")); } else if (key.equals("title")) { json.put(key, extras.getString("title")); } else if (key.equals("message")) { json.put(key, extras.getString("message")); } else if (key.equals("payload")) { createPayloadObject(json, (String) value); } else { if (value instanceof String) { createPayloadObject(json, (String) value); } } } // while json.put("service", "GCM"); return json; } catch (JSONException e) { } return null; }