Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.soomla.store.billing.google.GoogleIabHelper.java

/**
 * Workaround to bug where sometimes response codes come as Long instead of Integer
 *//*from   w  w  w . j a v  a 2s.  com*/
private int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        SoomlaUtils.LogDebug(TAG, "Bundle with null response code, assuming OK (known issue)");
        return IabResult.BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {
        SoomlaUtils.LogError(TAG, "Unexpected type for bundle response code.");
        SoomlaUtils.LogError(TAG, o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.bt.heliniumstudentapp.DayActivity.java

@SuppressWarnings("ConstantConditions")
@Override//from w ww.  j  a v a  2 s .  c o m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_day);

    final Toolbar toolbarTB = (Toolbar) findViewById(R.id.tb_toolbar_ad);
    setSupportActionBar(toolbarTB);
    toolbarTB.setBackgroundResource(MainActivity.primaryColor);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbarTB.getNavigationIcon().setColorFilter(ContextCompat.getColor(this, MainActivity.primaryTextColor),
            PorterDuff.Mode.SRC_ATOP);

    getWindow().getDecorView().setBackgroundResource(MainActivity.themeColor);

    MainActivity.setStatusBar(this);

    ViewPager daysVP = (ViewPager) findViewById(R.id.vp_days_ad);

    Bundle bundle = getIntent().getExtras();
    schedule = (ScheduleFragment.week) bundle.getSerializable("schedule");
    lastPosition = (Integer) bundle.get("pos");

    daysVP.setAdapter(new DaysAdapter(this, getSupportFragmentManager()));
    daysVP.setOffscreenPageLimit(1);
    daysVP.setCurrentItem(lastPosition);

    compactView = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_customization_compact",
            false);

    MainActivity.setToolbarTitle(this, schedule.day_get(schedule.day_get_index(lastPosition) + 2).day,
            schedule.day_get(schedule.day_get_index(lastPosition) + 2).date);

    daysVP.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            MainActivity.setToolbarTitle(DayActivity.this,
                    schedule.day_get(schedule.day_get_index(position) + 2).day,
                    schedule.day_get(schedule.day_get_index(position) + 2).date);

            hw_floating = (schedule.day_get(schedule.day_get_index(position) + 2).floatings_get() != 0);
            invalidateOptionsMenu();

            lastPosition = position;
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }
    });
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (getActivity() == null) {
        return;/*from   w  w  w .ja v a 2s  . co m*/
    }

    int token = loader.getId();
    if (token == SessionsQuery._TOKEN || token == SearchQuery._TOKEN) {
        mAdapter.changeCursor(cursor);
        Bundle arguments = getArguments();

        if (arguments != null && arguments.containsKey("_uri")) {
            String uri = arguments.get("_uri").toString();

            if (uri != null && uri.contains("blocks")) {
                String title = arguments.getString(Intent.EXTRA_TITLE);
                if (title == null) {
                    title = (String) this.getActivity().getTitle();
                }
                EasyTracker.getTracker().sendView("Session Block: " + title);
                LOGD("Tracker", "Session Block: " + title);
            }
        }
    } else {
        LOGD(TAG, "Query complete, Not Actionable: " + token);
        cursor.close();
    }

    mMultiSelectionController.tryRestoreInstanceState();
}

From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult: request=" + requestCode + ", result=" + resultCode);

    if (requestCode == REQUEST_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
        // Process selected image here
        // The document selected by the user won't be returned in the intent.
        // Instead, a URI to that document will be contained in the return intent
        // provided to this method as a parameter.
        // Pull that URI using resultData.getData().
        if (data != null) {
            Uri uri = data.getData();/* ww w .jav  a 2 s .c om*/
            Log.i(TAG, "Uri: " + uri.toString());

            // Resize if too big for messaging
            Bitmap bitmap = getBitmapForUri(uri);
            Bitmap resizedBitmap = scaleImage(bitmap);
            if (bitmap != resizedBitmap) {
                uri = savePhotoImage(resizedBitmap);
            }

            createImageMessage(uri);
        } else {
            Log.e(TAG, "Cannot get image for uploading");
        }
    } else if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {

        if (data != null && data.getExtras() != null) {
            Bundle extras = data.getExtras();
            Bitmap imageBitmap = (Bitmap) extras.get("data");
            Log.d(TAG, "imageBitmap size:" + imageBitmap.getByteCount());
            createImageMessage(savePhotoImage(imageBitmap));
        } else {
            Log.e(TAG, "Cannot get photo URI after taking photo");
        }
    } else if (requestCode == REQUEST_PREFERENCES) {
        if (DesignUtils.getPreferredTheme(this) != mSavedTheme) {
            DesignUtils.applyColorfulTheme(this);
            this.recreate();
        }
    } else if (requestCode == REQUEST_NEW_CHANNEL && resultCode == Activity.RESULT_OK) {
        setChannelPage();
    }
}

From source file:com.chess.genesis.data.GameDataDB.java

public void copyGameToLocal(final String gameid, final int gametype) {
    final String[] data = { gameid };
    final String type = (gametype == Enums.ONLINE_GAME) ? "onlinegames" : "archivegames";
    final Bundle row = rowToBundle(db.rawQuery("SELECT * FROM " + type + " WHERE gameid=?", data), 0, true);

    final long time = System.currentTimeMillis();
    final String tnames = "(name, ctime, stime, gametype, opponent, zfen, history)";
    final String dstring = "(?, ?, ?, ?, ?, ?, ?)";
    final Object[] data2 = { row.get("white") + " Vs. " + row.get("black"), time, time, row.get("gametype"),
            Enums.HUMAN_OPPONENT, row.get("zfen"), row.get("history") };

    db.execSQL("INSERT INTO localgames" + tnames + " VALUES " + dstring + ';', data2);
}

From source file:com.rjfun.cordova.sms.SMSPlugin.java

protected void createIncomingSMSReceiver() {
    Activity ctx = this.cordova.getActivity();
    this.mReceiver = new BroadcastReceiver() {

        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Log.d(LOGTAG, ("onRecieve: " + action));
            if (SMS_RECEIVED.equals(action)) {
                Bundle bundle;
                if (SMSPlugin.this.mIntercept) {
                    this.abortBroadcast();
                }// w ww . j  a v a  2s  .c o m
                if ((bundle = intent.getExtras()) != null) {
                    Object[] pdus;
                    if ((pdus = (Object[]) bundle.get("pdus")).length != 0) {
                        for (int i = 0; i < pdus.length; ++i) {
                            SmsMessage sms = SmsMessage.createFromPdu((byte[]) ((byte[]) pdus[i]));
                            JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms);
                            SMSPlugin.this.onSMSArrive(json);
                        }
                    }
                }
            }
        }
    };
    String[] filterstr = new String[] { SMS_RECEIVED };
    for (int i = 0; i < filterstr.length; ++i) {
        IntentFilter filter = new IntentFilter(filterstr[i]);
        filter.setPriority(100);
        ctx.registerReceiver(this.mReceiver, filter);
        Log.d(LOGTAG, ("broadcast receiver registered for: " + filterstr[i]));
    }
}

From source file:es.glasspixel.wlanaudit.activities.KeyListActivity.java

/**
 * @see android.app.Activity#onCreate(Bundle)
 *//*from w w  w.ja  va 2s .  c  o m*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.key_list_layout);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // create our manager instance after the content view is set
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setStatusBarTintResource(R.color.wlanaudit_material);

    // If a previous instance state was saved
    if (savedInstanceState != null && savedInstanceState.get(KEY_LIST_KEY) != null) {
        // Load the state
        mKeyList = savedInstanceState.getStringArrayList(KEY_LIST_KEY);
    } else {
        // Read the network from the intent extra passed to this activity
        mKeyList = (List<String>) getIntent().getExtras().getStringArrayList(KEY_LIST_KEY);
    }

    // Ads Initialization
    setupAds((LinearLayout) findViewById(R.id.keyListAdLayout));

    // List display
    setListAdapter(new ArrayAdapter<String>(this, R.layout.key_list_element_layout, R.id.keyString, mKeyList));
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

/** Create the activity, taking into account ongoing dialogs or already downloaded data.
*
* If there is a retained ParseShowDetailsPageTask, set its parent
* activity to the newly created ShowDetailsScreen (the old one was
* destroyed because of an orientation change or something.  This
* way, the ParseShowDetailsPageTask does not leak any of the Views
* from the old ShowDetailsScreen.  Also, grab the songs from the
* ParseShowDetailsPageTask to refresh the list of songs with.
*///  ww  w.  java 2  s.  co  m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.show_details_screen);
    Intent intent = getIntent();
    Bundle b = intent.getExtras();
    if (b != null) {
        show = (ArchiveShowObj) b.get("Show");
    }
    if (show == null) {
        if (intent.getScheme().equals("http")) {
            Uri link = intent.getData();
            String linkString = link.toString();
            if (linkString.contains("/download/")) {
                String[] paths = linkString.split("/");
                for (int i = 0; i < paths.length; i++) {
                    if (paths[i].equals("download")) {
                        show = new ArchiveShowObj(Uri.parse("http://www.archive.org/details/" + paths[i + 1]),
                                true);
                        show.setSelectedSong(linkString);
                    }
                }
            } else {
                show = new ArchiveShowObj(link, false);
            }
        }
    }

    //      
    //      

    showTitle = show.getArtistAndTitle();
    showLabel = (TextView) findViewById(R.id.ShowLabel);
    showLabel.setText(showTitle);

    trackList = (ListView) findViewById(R.id.SongsListView);
    trackList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {

            playShow(position);
            Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class);
            startActivity(i);
        }
    });
    trackList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.ADD_SONG_TO_QUEUE, Menu.NONE, "Add to playlist");
            menu.add(Menu.NONE, VibeVault.DOWNLOAD_SONG, Menu.NONE, "Download Song");
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Song");
        }
    });

    downloadLinks = new ArrayList<ArchiveSongObj>();
    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof ParseShowDetailsPageTask) {
        workerTask = (ParseShowDetailsPageTask) retained;
        workerTask.setActivity(this);
        downloadLinks = workerTask.songs;
    } else if (show.getShowURL() != null) {

        workerTask = new ParseShowDetailsPageTask(this);
        workerTask.execute(show);
    }
}

From source file:com.polyvi.xface.extension.XMessagingExt.java

private void genMsgReceiveBroadcastReceive() {
    if (null == mMsgReceiveBroadcaseReveiver) {
        mMsgReceiveBroadcaseReveiver = new BroadcastReceiver() {
            @Override//  ww w. jav a  2s  .c  om
            public void onReceive(Context context, Intent intent) {
                if (INTENT_ACTION.equals(intent.getAction())) {
                    Bundle bundle = intent.getExtras();
                    if (null != bundle) {
                        // pdus??
                        Object[] pdus = (Object[]) bundle.get("pdus");
                        // 
                        SmsMessage[] msgs = new SmsMessage[pdus.length];
                        for (int i = 0; i < pdus.length; i++) {
                            // ???pdu?,?
                            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                        }
                        JSONArray receivedMsgs = buildSmsList(msgs);
                        XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString());
                        XSystemEventCenter.getInstance().sendEventAsync(evt);
                    }
                }
            }
        };
    }
}

From source file:com.wareninja.opensource.common.wsrequest.WebServiceNew.java

public String getJsonFromParams2(Bundle params) {

    Map<String, Object> paramsMap = new LinkedHashMap<String, Object>();

    String valStr;//from   w  w w. j  a va  2  s  . c  o m
    Object valObj;
    for (String key : params.keySet()) {

        valObj = params.get(key);
        if (valObj instanceof String) {

            // ugly check if the string value is JSONObj or JSONArr
            valStr = "" + valObj;
            // if (LOGGING.DEBUG) Log.d(TAG, "valStr->"+valStr);
            valObj = null;
            try {
                valObj = new JSONObject(valStr);

                // note: very ugly hack just for tag loco part!
                if (valStr.contains("{") && valStr.contains("lat") && valStr.contains("lng")) {

                    LinkedHashMap<String, Object> tempMap = new LinkedHashMap<String, Object>();
                    tempMap.put("lng", ((JSONObject) valObj).get("lng"));
                    tempMap.put("lat", ((JSONObject) valObj).get("lat"));
                    JSONObject tempJson = new JSONObject(tempMap);

                    if (LOGGING.DEBUG)
                        Log.d(TAG, "tempJson->" + tempJson + "| len:" + tempJson.length());
                    if (LOGGING.DEBUG)
                        Log.d(TAG, "valObj(before)->" + valObj);

                    if (tempJson.length() > 0) {
                        valObj = tempJson;
                    }

                    if (LOGGING.DEBUG)
                        Log.d(TAG, "valObj(after)->" + valObj);
                }
            } catch (JSONException ex) {
                valObj = null;
            }

            if (valObj == null) {
                try {
                    valObj = new JSONArray(valStr);
                } catch (JSONException ex) {
                    valObj = null;
                }
            }
            if (valObj == null)
                valObj = valStr;
        }

        if (valObj != null)
            paramsMap.put(key, valObj);
    }

    return getJsonFromParams(paramsMap);
}