Example usage for android.os Bundle keySet

List of usage examples for android.os Bundle keySet

Introduction

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

Prototype

public Set<String> keySet() 

Source Link

Document

Returns a Set containing the Strings used as keys in this Bundle.

Usage

From source file:com.gh4a.fragment.RepositoryIssueListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(Constants.LOG_TAG, ">>>>>>>>>>> onCreate RepositoryIssueListFragment");
    super.onCreate(savedInstanceState);

    mFilterData = new HashMap<String, String>();

    Bundle args = getArguments();
    Iterator<String> i = args.keySet().iterator();
    while (i.hasNext()) {
        String key = i.next();//from   ww w.j a  v a 2 s  . com
        if (Constants.User.USER_LOGIN != key && Constants.Repository.REPO_NAME != key) {
            mFilterData.put(key, args.getString(key));
        }
    }
}

From source file:com.gh4a.CompareActivity.java

private void fillData2() {
    ListView listView = (ListView) findViewById(R.id.list_view);

    CompareAdapter compareAdapter = new CompareAdapter(this, new ArrayList<String[]>());
    listView.setAdapter(compareAdapter);
    listView.setOnItemClickListener(this);

    Bundle extra = getIntent().getExtras();
    Iterator<String> iter = extra.keySet().iterator();

    List<String[]> commits = new ArrayList<String[]>();
    while (iter.hasNext()) {
        String key = iter.next();
        if (key.startsWith("commit")) {
            String[] commitInfo = extra.getStringArray(key);
            commits.add(commitInfo);/*from  w  ww .ja v  a2s  . c  om*/
        }

    }

    if (commits != null && commits.size() > 0) {
        for (String[] commitInfo : commits) {
            compareAdapter.add(commitInfo);
        }
    }
    compareAdapter.notifyDataSetChanged();
}

From source file:org.openmidaas.app.services.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent message) {
    Log.d(TAG, "Received push message");
    Bundle extras = message.getExtras();
    for (String key : extras.keySet()) {
        Logger.debug(getClass(), "Received key: " + key + " and value as: " + extras.getString(key));
        if (key.equals("url")) {
            if (!extras.getString(key).isEmpty() && extras.getString(key) != null) {
                Log.d(TAG, "Received key as 'url' and value as " + extras.getString(key));
                Intent intent = new Intent(getBaseContext(), SplashActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.setAction(Constants.IntentActionMessages.PROCESS_URL);
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                intent.putExtra("url", extras.getString(key));
                //Check for the lock before continuing
                if (SessionManager.getBusyness() == false) {
                    getApplication().startActivity(intent);
                } else {
                    Log.d(TAG, "Received push message but won't process the URL as session is locked.");
                }/*from www. j  av a2  s  . c o m*/

            } else {
                Log.d(TAG, "Received push message but vaue of key:\"url\" is empty or null. ");
            }
        }
    }

}

From source file:h4311.hexanome.insa.lyonrewards.di.module.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*from w  ww  .  ja  v a 2  s  .  c  o  m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    Log.d(TAG, "Message: " + data.getString("score"));
    for (String key : data.keySet()) {
        Log.d(TAG, "Message: " + key);
    }

    String message = "todo";
    Log.d(TAG, "From: " + from);

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    Intent messageReceived = new Intent(QuickstartPreferences.GCM_MESSAGE_RECEIVED);
    // todo : set constant
    messageReceived.putExtra(MainActivity.ARG_ID_OFFER_READ, data.getString(DATA_ID_OFFER));
    messageReceived.putExtra(MainActivity.ARG_POINTS_OFFER_READ, data.getString(DATA_SCORE));
    LocalBroadcastManager.getInstance(this).sendBroadcast(messageReceived);

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    sendNotification(data.getString(DATA_ID_OFFER), data.getString(DATA_SCORE), data.getString("title"));
    // [END_EXCLUDE]
}

From source file:edu.cmu.sei.cloudlet.client.ska.adb.InDataService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "Received data.");
    Bundle extras = intent.getExtras();
    Log.v(TAG, "Number of items: " + extras.size());

    JSONObject jsonData = new JSONObject();
    for (String key : extras.keySet()) {
        try {// w  w w.java2s . c om
            jsonData.put(key, extras.getString(key));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    String result = mDataHandler.handleData(jsonData, this);

    Log.v(TAG, "Writing result to file.");
    FileHandler.writeToFile(ADBConstants.OUT_FILE_PATH, result);
    Log.v(TAG, "Finished writing result to file.");

    // We don't need this service to run anymore.
    stopSelf();
    return START_NOT_STICKY;
}

From source file:com.gh4a.fragment.IssueListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRepoOwner = getArguments().getString(Constants.Repository.REPO_OWNER);
    mRepoName = getArguments().getString(Constants.Repository.REPO_NAME);
    mState = getArguments().getString("state");

    mFilterData = new HashMap<String, String>();

    Bundle args = getArguments();
    Iterator<String> i = args.keySet().iterator();
    while (i.hasNext()) {
        String key = i.next();/*from w  w  w . j  av a 2  s. c o m*/
        if (Constants.Repository.REPO_OWNER != key && Constants.Repository.REPO_NAME != key) {
            mFilterData.put(key, args.getString(key));
        }
    }
}

From source file:com.ds.kaixin.Util.java

/**
 * http/*from   ww  w  . j  a va 2 s  . c  om*/
 * 
 * @param context
 *            
 * @param requestURL
 *            
 * @param httpMethod
 *            GET  POST
 * @param params
 *            key-valuekeyvalueString
 *            byte[]
 * @param photos
 *            key-value keyfilename
 *            valueInputStreambyte[]
 *            InputStreamopenUrl
 * @return JSON
 * @throws IOException
 */
public static String openUrl(Context context, String requestURL, String httpMethod, Bundle params,
        Map<String, Object> photos) throws IOException {

    OutputStream os;

    if (httpMethod.equals("GET")) {
        requestURL = requestURL + "?" + encodeUrl(params);
    }

    URL url = new URL(requestURL);
    HttpsURLConnection conn = (HttpsURLConnection) getConnection(context, url);

    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " KaixinAndroidSDK");

    conn.setDoInput(true);
    conn.setUseCaches(false);
    conn.setRequestProperty("Connection", "close");
    conn.setRequestProperty("Charsert", "UTF-8");

    if (!httpMethod.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {
            if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
            }
        }

        String BOUNDARY = Util.md5(String.valueOf(System.currentTimeMillis())); // 
        String endLine = "\r\n";

        conn.setRequestMethod("POST");

        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY);

        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

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

        if (!dataparams.isEmpty()) {

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

        if (photos != null && !photos.isEmpty()) {

            for (String key : photos.keySet()) {

                Object obj = photos.get(key);
                if (obj instanceof InputStream) {
                    InputStream is = (InputStream) obj;
                    try {
                        os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\""
                                + endLine).getBytes());
                        os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes());
                        byte[] data = new byte[UPLOAD_BUFFER_SIZE];
                        int nReadLength = 0;
                        while ((nReadLength = is.read(data)) != -1) {
                            os.write(data, 0, nReadLength);
                        }
                        os.write((endLine + "--" + BOUNDARY + endLine).getBytes());
                    } finally {
                        try {
                            if (null != is) {
                                is.close();
                            }
                        } catch (Exception e) {
                            Log.e(LOG_TAG, "Exception on closing input stream", e);
                        }
                    }
                } else if (obj instanceof byte[]) {
                    byte[] byteArray = (byte[]) obj;
                    os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine)
                            .getBytes());
                    os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes());
                    os.write(byteArray);
                    os.write((endLine + "--" + BOUNDARY + endLine).getBytes());
                } else {
                    Log.e(LOG_TAG, "");
                }
            }
        }

        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        response = read(conn.getErrorStream());
    }
    return response;
}

From source file:com.kaixin.connect.Util.java

/**
 * http/* w  ww . j a v  a  2s .c  o  m*/
 * 
 * @param context
 *            
 * @param requestURL
 *            
 * @param httpMethod
 *            GET  POST
 * @param params
 *            key-valuekeyvalueStringbyte[]
 * @param photos
 *            key-value keyfilename
 *            valueInputStreambyte[]
 *            InputStreamopenUrl
 * @return JSON
 * @throws IOException
 */
public static String openUrl(Context context, String requestURL, String httpMethod, Bundle params,
        Map<String, Object> photos) throws IOException {

    OutputStream os;

    if (httpMethod.equals("GET")) {
        requestURL = requestURL + "?" + encodeUrl(params);
    }

    URL url = new URL(requestURL);
    HttpsURLConnection conn = (HttpsURLConnection) getConnection(context, url);

    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " KaixinAndroidSDK");

    conn.setDoInput(true);
    conn.setUseCaches(false);
    conn.setRequestProperty("Connection", "close");
    conn.setRequestProperty("Charsert", "UTF-8");

    if (!httpMethod.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {
            if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
            }
        }

        String BOUNDARY = Util.md5(String.valueOf(System.currentTimeMillis())); // 
        String endLine = "\r\n";

        conn.setRequestMethod("POST");

        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY);

        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

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

        if (!dataparams.isEmpty()) {

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

        if (photos != null && !photos.isEmpty()) {

            for (String key : photos.keySet()) {

                Object obj = photos.get(key);
                if (obj instanceof InputStream) {
                    InputStream is = (InputStream) obj;
                    try {
                        os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\""
                                + endLine).getBytes());
                        os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes());
                        byte[] data = new byte[UPLOAD_BUFFER_SIZE];
                        int nReadLength = 0;
                        while ((nReadLength = is.read(data)) != -1) {
                            os.write(data, 0, nReadLength);
                        }
                        os.write((endLine + "--" + BOUNDARY + endLine).getBytes());
                    } finally {
                        try {
                            if (null != is) {
                                is.close();
                            }
                        } catch (Exception e) {
                            Log.e(LOG_TAG, "Exception on closing input stream", e);
                        }
                    }
                } else if (obj instanceof byte[]) {
                    byte[] byteArray = (byte[]) obj;
                    os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine)
                            .getBytes());
                    os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes());
                    os.write(byteArray);
                    os.write((endLine + "--" + BOUNDARY + endLine).getBytes());
                } else {
                    Log.e(LOG_TAG, "");
                }
            }
        }

        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        response = read(conn.getErrorStream());
    }
    return response;
}

From source file:com.secbro.qark.exportedcomponent.exportedactivity.IntentParamsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_CODE: {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                Map resultMap = new HashMap<Object, Object>();
                Bundle bundle = data.getExtras();
                for (String key : bundle.keySet()) {
                    Object value = bundle.get(key);
                    Log.d("key", key);
                    Log.d("value", value.toString());
                    resultMap.put(key, value);
                }//from  w w w  .j av  a 2s .c  o m
                //Call container activity back to display result
                if (mListener != null) {
                    mListener.onActivityResultListener(resultMap);
                } else {
                    Log.e(LOG_TAG, "mListener is null");
                }
            }
        } else {
            Log.d("INFO", "No data received");
        }
    }
    }
}

From source file:edu.cmu.sei.cloudlet.client.ska.adb.OutDataService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "Received data request.");
    Bundle extras = intent.getExtras();
    Log.v(TAG, "Number of items requested: " + extras.size());

    JSONObject jsonData = new JSONObject();
    for (String key : extras.keySet()) {
        try {//from w w w  .ja  va  2 s.  c  om
            jsonData.put(key, extras.getString(key));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    String jsonDataAsString = mDataHandler.getData(jsonData, this);

    Log.v(TAG, "Writing to file.");
    FileHandler.writeToFile(ADBConstants.OUT_FILE_PATH, jsonDataAsString);
    Log.v(TAG, "Finished writing to file.");

    // We don't need this service to run anymore.
    stopSelf();
    return START_NOT_STICKY;
}