Example usage for android.os Bundle containsKey

List of usage examples for android.os Bundle containsKey

Introduction

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

Prototype

public boolean containsKey(String key) 

Source Link

Document

Returns true if the given key is contained in the mapping of this Bundle.

Usage

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

@Override
public void setSettingsFromBundle(Bundle inState) {
    super.setSettingsFromBundle(inState);
    if (inState != null) {
        setRadiusInMeters(inState.getInt(RADIUS_IN_METERS_BUNDLE_KEY, radiusInMeters));
        setResultsLimit(inState.getInt(RESULTS_LIMIT_BUNDLE_KEY, resultsLimit));
        if (inState.containsKey(SEARCH_TEXT_BUNDLE_KEY)) {
            setSearchText(inState.getString(SEARCH_TEXT_BUNDLE_KEY));
        }/* w  ww  . j  a  v a 2 s .  c o  m*/
        if (inState.containsKey(LOCATION_BUNDLE_KEY)) {
            Location location = inState.getParcelable(LOCATION_BUNDLE_KEY);
            setLocation(location);
        }
        showSearchBox = inState.getBoolean(SHOW_SEARCH_BOX_BUNDLE_KEY, showSearchBox);
    }
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java

@Override
public void onActivityCreated(Bundle bundle) {
    try {/* ww w . ja  v a2s.c  o  m*/
        deviceTitle.setText(getArguments().getString(ARG_HOSTNAME));
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
    }

    //Check if we have a bundle
    if (null != bundle) {
        if (bundle.containsKey("json")) {
            try {
                deviceJSON = new JSONObject(bundle.getString("json"));
                ProcessJSON();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("cpuimg")) {
            try {
                CPUGraphView.setImageBitmap((Bitmap) bundle.getParcelable("img"));
                CPUGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("loadavgimg")) {
            try {
                loadAverageGraphView.setImageBitmap((Bitmap) bundle.getParcelable("cpuimg"));
                loadAverageGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("memimg")) {
            try {
                MemoryGraphView.setImageBitmap((Bitmap) bundle.getParcelable("memimg"));
                MemoryGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

    } else {
        (new Thread() {
            public void run() {
                ZenossAPI API;

                if (PreferenceManager.getDefaultSharedPreferences(getActivity())
                        .getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) {
                    API = new ZenossAPIZaas();
                } else {
                    API = new ZenossAPICore();
                }

                try {
                    credentials = new ZenossCredentials(getActivity());
                    API.Login(credentials);
                    deviceJSON = API.GetDevice(getArguments().getString(ARG_UID));

                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ProcessJSON();
                        }
                    });

                } catch (Exception e) {
                    BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
                }
            }
        }).start();
    }

    getGraphs();

    super.onActivityCreated(bundle);
}

From source file:com.irccloud.android.fragment.UsersListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (tapTimer == null)
        tapTimer = new Timer("users-tap-timer");

    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        bid = savedInstanceState.getInt("bid");
        channel = savedInstanceState.getString("channel");
    }//from www  .j a v a2s .c om
}

From source file:com.wareninja.android.opensource.oauth2login.common.Utils.java

/**
 * Connect to an HTTP URL and return the response as a string.
 * //  w  ww . j a v  a 2  s  .c o  m
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 * 
 * @param url - the resource to open: must be a welformed URL
 * @param method - the HTTP method to use ("GET", "POST", etc.)
 * @param params - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String
 * @throws MalformedURLException - if the URL format is invalid
 * @throws IOException - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    // random string as boundary for multi-part http post
    String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
    String endLine = "\r\n";

    OutputStream os;

    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }
    if (AppContext.DEBUG)
        Log.d("Facebook-Util", method + " URL: " + url);
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK");
    if (!method.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {

            /*
             if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
             }
             */
            // YG: added this to avoid fups
            byte[] byteArr = null;
            try {
                byteArr = (byte[]) params.get(key);
            } catch (Exception ex1) {
            }
            if (byteArr != null)
                dataparams.putByteArray(key, byteArr);
        }

        // use method override
        if (!params.containsKey("method")) {
            params.putString("method", method);
        }

        if (params.containsKey("access_token")) {
            String decoded_token = URLDecoder.decode(params.getString("access_token"));
            params.putString("access_token", decoded_token);
        }

        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary);
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

        os.write(("--" + strBoundary + endLine).getBytes());
        os.write((encodePostBody(params, strBoundary)).getBytes());
        os.write((endLine + "--" + strBoundary + endLine).getBytes());

        if (!dataparams.isEmpty()) {

            for (String key : dataparams.keySet()) {
                os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
                os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
                os.write(dataparams.getByteArray(key));
                os.write((endLine + "--" + strBoundary + endLine).getBytes());

            }
        }
        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    }
    if (AppContext.DEBUG)
        Log.d("Facebook-Util", method + " response: " + response);

    return response;
}

From source file:gov.sfmta.sfpark.MainScreenActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    // Restore the previously serialized current dropdown position.
    if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
        getSupportActionBar()//w w  w. j  ava  2s.co m
                .setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
    }
}

From source file:com.example.appf.CS3570.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();//  www. j a v a  2 s.  c  o  m
    Bundle extras = intent.getExtras();
    cam = false;

    // Just in case we are coming from the ServerActivity
    if (extras != null) {
        if (extras.containsKey("server_name"))
            SERVER_IP = extras.getString("server_name");
        if (extras.containsKey("server_port"))
            SERVERPORT = Integer.parseInt(extras.getString("server_port"));
    }
    filter = new IMUfilter(.1f, 5);
    filter.reset();

    // Set up reset button
    Button b = new Button(this);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
        }
    });
    b.setText("Reset");

    // Set up camera mode. Are we going to use this?
    Button c = new Button(this);
    c.setText("Camera Mode");
    c.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
            mGLView.mRenderer.mCamera = new Camera();
            cam = !cam;
        }
    });
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setBackgroundColor(Color.parseColor("#21C9FF"));
    ll.addView(b);
    ll.addView(c);
    // Create a GLSurfaceView instance and set it
    // as the ContentView for this Activity
    mGLView = new MyGLSurfaceView(this, this);
    ll.addView(mGLView);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    gyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    magnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    setContentView(ll);
    new Thread(new SocketThread()).start();
}

From source file:edu.cens.loci.ui.PlaceListActivity.java

/**
 * USE CASES:// www.  j  ava 2 s.com
 * 
 * 1. DEFAULT :
 *       list places and when selected, ACTION_VIEW
 * 
 *       ACTION ... send ACTION_VIEW content://places/pid 
 *       SHOW ...
 *    - Suggested places ... add "View GPS Places"
 *    - Registered places ...
 *    - Blocked places ...
 *    - Filter by tag ...
 * 
 * 2. INSERT_OR_EDIT :
 *    list "create a new place" and "registered" places, when selected, ACTION_EDIT
 *    
 *    ACTION ... send ACTION_EDIT content://places/pid or ACTION_INSERT content://places
 *    - show all suggested/registered/blocked places
 *    SHOW...
 *    - "create a new place" and "registered places"
 *    
 * 3. PICK :
 *       list places and when selected, return with a uri.
 * 
 *       ACTION ... return a data URL back to the caller
 *       SHOW... 
 * 
 * 4. SEARCH :
 *     TBD
 * 
 */

@Override
protected void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    setContentView(R.layout.place_list);

    // Resolve the intent
    final Intent intent = getIntent();

    String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY);
    if (title != null) {
        setTitle(title);
    }

    String action = intent.getAction();

    if (Intent.ACTION_VIEW.equals(action)) {
        mMode = MODE_VIEW;
    } else if (Intents.UI.ACTION_INSERT.equals(action)) {
        mMode = MODE_INSERT;
    } else if (Intents.UI.ACTION_CREATE_OR_ADDTO_FROM_SUGGESTED_PLACE.equals(action)) {
        mMode = MODE_REGISTER_SUGGESTED;
    } else if (Intent.ACTION_PICK.equals(action)) {
        mMode = MODE_PICK;
    }

    MyLog.i(LociConfig.D.UI.DEBUG, TAG, String.format("List: mode=%d (%s)", mMode, action));

    Bundle extras = intent.getExtras();

    if (extras != null) {
        if (extras.containsKey(Intents.UI.FILTER_STATE_EXTRA_KEY))
            mFilterState = extras.getInt(Intents.UI.FILTER_STATE_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.FILTER_TYPE_EXTRA_KEY))
            mFilterType = extras.getInt(Intents.UI.FILTER_TYPE_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.FILTER_TAG_EXTRA_KEY))
            mFilterTag = extras.getString(Intents.UI.FILTER_TAG_EXTRA_KEY);
        if (extras.containsKey(Intents.UI.LIST_ORDER_EXTRA_KEY))
            mListOrder = extras.getInt(Intents.UI.LIST_ORDER_EXTRA_KEY);
    }

    mDbUtils = new LociDbUtils(this);
}

From source file:android.support.v17.leanback.app.SearchSupportFragment.java

private void readArguments(Bundle args) {
    if (null == args) {
        return;//  ww w  .  ja v  a  2s  .c  o m
    }
    if (args.containsKey(ARG_QUERY)) {
        setSearchQuery(args.getString(ARG_QUERY));
    }

    if (args.containsKey(ARG_TITLE)) {
        setTitle(args.getString(ARG_TITLE));
    }
}

From source file:ch.fixme.status.Main.java

private void getHsList(Bundle savedInstanceState) {
    final Bundle data = (Bundle) getLastNonConfigurationInstance();
    if (data == null || (savedInstanceState == null && !savedInstanceState.containsKey(STATE_DIR))) {
        getDirTask = new GetDirTask();
        getDirTask.execute(ParseGeneric.API_DIRECTORY);
    } else {//from w  ww.  j a  v  a  2 s  . c  om
        finishDir = true;
        mResultDir = data.getString(STATE_DIR);
    }
}

From source file:com.microsoft.office365.msgraphsnippetapp.SnippetDetailFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (null != getActivity() && getActivity() instanceof AppCompatActivity) {
        AppCompatActivity activity = (AppCompatActivity) getActivity();
        if (null != activity.getSupportActionBar()) {
            activity.getSupportActionBar().setTitle(mItem.getName());
        }/*from  w w w  .  j a  v  a 2  s . com*/
    }
    if (null != savedInstanceState && savedInstanceState.containsKey(STATUS_COLOR)) {
        int statusColor = savedInstanceState.getInt(STATUS_COLOR, UNSET);
        if (UNSET != statusColor) {
            mStatusColor.setBackgroundColor(statusColor);
            mStatusColor.setTag(statusColor);
        }
    }
}