Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

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

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.facebook.internal.FacebookWebFallbackDialog.java

@Override
protected Bundle parseResponseUri(String url) {
    Uri responseUri = Uri.parse(url);/*from w  w  w. j a va 2s.com*/
    Bundle queryParams = Utility.parseUrlQueryString(responseUri.getQuery());

    // Convert Bridge args to the format that the Native dialog code understands.
    String bridgeArgsJSONString = queryParams.getString(ServerProtocol.FALLBACK_DIALOG_PARAM_BRIDGE_ARGS);
    queryParams.remove(ServerProtocol.FALLBACK_DIALOG_PARAM_BRIDGE_ARGS);

    if (!Utility.isNullOrEmpty(bridgeArgsJSONString)) {
        Bundle bridgeArgs;
        try {
            JSONObject bridgeArgsJSON = new JSONObject(bridgeArgsJSONString);
            bridgeArgs = BundleJSONConverter.convertToBundle(bridgeArgsJSON);
            queryParams.putBundle(NativeProtocol.EXTRA_PROTOCOL_BRIDGE_ARGS, bridgeArgs);
        } catch (JSONException je) {
            Utility.logd(TAG, "Unable to parse bridge_args JSON", je);
        }
    }

    // Convert Method results to the format that the Native dialog code understands.
    String methodResultsJSONString = queryParams.getString(ServerProtocol.FALLBACK_DIALOG_PARAM_METHOD_RESULTS);
    queryParams.remove(ServerProtocol.FALLBACK_DIALOG_PARAM_METHOD_RESULTS);

    if (!Utility.isNullOrEmpty(methodResultsJSONString)) {
        methodResultsJSONString = Utility.isNullOrEmpty(methodResultsJSONString) ? "{}"
                : methodResultsJSONString;
        Bundle methodResults;
        try {
            JSONObject methodArgsJSON = new JSONObject(methodResultsJSONString);
            methodResults = BundleJSONConverter.convertToBundle(methodArgsJSON);
            queryParams.putBundle(NativeProtocol.EXTRA_PROTOCOL_METHOD_RESULTS, methodResults);
        } catch (JSONException je) {
            Utility.logd(TAG, "Unable to parse bridge_args JSON", je);
        }
    }

    // The web host does not send a numeric version back. Put the latest known version in there so NativeProtocol
    // can continue parsing the response.
    queryParams.remove(ServerProtocol.FALLBACK_DIALOG_PARAM_VERSION);
    queryParams.putInt(NativeProtocol.EXTRA_PROTOCOL_VERSION, NativeProtocol.getLatestKnownVersion());

    return queryParams;
}

From source file:net.idlesoft.android.apps.github.activities.tabs.ClosedIssues.java

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {//from w w  w  .  ja v a  2s  .  c  o m
        if (savedInstanceState.containsKey("json")) {
            mJson = new JSONArray(savedInstanceState.getString("json"));
        } else {
            return;
        }
    } catch (final Exception e) {
        e.printStackTrace();
        return;
    }
    if (mJson != null) {
        mAdapter.loadData(mJson);
        mAdapter.pushData();
    }
}

From source file:com.onesignal.OneSignal.java

private static void fireIntentFromNotificationOpen(Context inContext, JSONArray data) {
    PackageManager packageManager = inContext.getPackageManager();

    boolean isCustom = false;

    Intent intent = new Intent().setAction("com.onesignal.NotificationOpened.RECEIVE")
            .setPackage(inContext.getPackageName());

    List<ResolveInfo> resolveInfo = packageManager.queryBroadcastReceivers(intent,
            PackageManager.GET_INTENT_FILTERS);
    if (resolveInfo.size() > 0) {
        intent.putExtra("onesignal_data", data.toString());
        inContext.sendBroadcast(intent);
        isCustom = true;/*from w  w w . j a  v a 2  s. c om*/
    }

    // Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag.
    resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfo.size() > 0) {
        if (!isCustom)
            intent.putExtra("onesignal_data", data.toString());
        isCustom = true;
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
        inContext.startActivity(intent);
    }

    if (!isCustom) {
        try {
            ApplicationInfo ai = inContext.getPackageManager().getApplicationInfo(inContext.getPackageName(),
                    PackageManager.GET_META_DATA);
            Bundle bundle = ai.metaData;
            String defaultStr = bundle.getString("com.onesignal.NotificationOpened.DEFAULT");
            isCustom = "DISABLE".equals(defaultStr);
        } catch (Throwable t) {
            Log(LOG_LEVEL.ERROR, "", t);
        }
    }

    if (!isCustom) {
        Intent launchIntent = inContext.getPackageManager()
                .getLaunchIntentForPackage(inContext.getPackageName());

        if (launchIntent != null) {
            launchIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
            inContext.startActivity(launchIntent);
        }
    }
}

From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java

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

    Bundle args = getArguments();
    mKey = args.getString(ARG_KEY);
    mPage = (ConnectPage) mCallbacks.onGetPage(mKey);
}

From source file:com.noah.lol.network.RequestNetwork.java

protected void asyncRequestGet(final String url, final NetworkListener<String> listener) {

    if (url == null) {
        return;// w  w  w.j  av a 2  s .  co m
    }

    try {
        environmentCheck();
    } catch (EnvironmentException e) {
        if (listener != null) {
            e.setStatus(BAD_REQUEST_ENVIRONMENT_CONFIG);
            listener.onNetworkFail(BAD_REQUEST_ENVIRONMENT_CONFIG, e);
        }
        return;
    }

    final Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            Bundle bundle = msg.getData();
            switch (msg.what) {
            case REQUEST_SUCCESS:
                String responseBody = bundle.getString(RESPONSE_KEY);

                if (listener != null && responseBody != null) {
                    listener.onSuccess(responseBody);
                }
                break;
            case REQUEST_FAIL:
                NetworkException e = (NetworkException) bundle.getSerializable(EXCEPTION_KEY);
                if (listener != null) {
                    listener.onNetworkFail(e.getStatus(), e);
                }
                break;
            }
        }
    };

    new Thread(new Runnable() {

        @Override
        public void run() {

            String responseBody = null;
            Message message = new Message();

            try {
                responseBody = syncRequestGet(url);
                Bundle bundle = new Bundle();
                bundle.putString(RESPONSE_KEY, responseBody);
                message = Message.obtain(handler, REQUEST_SUCCESS);
                message.setData(bundle);
                handler.sendMessage(message);
            } catch (NetworkException e) {
                Bundle bundle = new Bundle();
                bundle.putSerializable(EXCEPTION_KEY, e);
                message = Message.obtain(handler, REQUEST_FAIL);
                message.setData(bundle);
                handler.sendMessage(message);
                e.printStackTrace();
            }

        }
    }).start();

}

From source file:net.idlesoft.android.apps.github.activities.CreateIssue.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.create_issue);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey("repo_owner")) {
            mRepositoryOwner = extras.getString("repo_owner");
        } else {// w  ww. jav a  2s  .co m
            mRepositoryOwner = mUsername;
        }
        if (extras.containsKey("repo_name")) {
            mRepositoryName = extras.getString("repo_name");
        }
    } else {
        mRepositoryOwner = mUsername;
    }

    mCreateIssueTask = (CreateIssueTask) getLastNonConfigurationInstance();
    if (mCreateIssueTask == null) {
        mCreateIssueTask = new CreateIssueTask();
    }
    mCreateIssueTask.activity = this;

    if (mCreateIssueTask.getStatus() == AsyncTask.Status.RUNNING) {
        mProgressDialog = ProgressDialog.show(CreateIssue.this, "Please Wait...", "Creating issue...", true);
    }

    ((TextView) findViewById(R.id.tv_page_title)).setText("New Issue");

    ((Button) findViewById(R.id.btn_create_issue_submit)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            if (mCreateIssueTask.getStatus() == AsyncTask.Status.FINISHED) {
                mCreateIssueTask = new CreateIssueTask();
                mCreateIssueTask.activity = CreateIssue.this;
            }
            if (mCreateIssueTask.getStatus() == AsyncTask.Status.PENDING) {
                mCreateIssueTask.execute();
            }
        }
    });
}

From source file:com.sababado.network.AsyncServiceCallTask.java

@Override
protected void onPostExecute(Bundle result) {
    String errMsg = result.getString(EXTRA_ERR_MSG);
    if (errMsg == null) {
        mAsyncServiceListener.onServiceCallSuccess(result);
    } else {//from   ww  w.  j  ava2 s.com
        int errCd = result.getInt(EXTRA_ERR_CODE, ERR_CODE_MISSING_ERR_CODE);
        mAsyncServiceListener.onServiceCallFailure(errMsg, errCd);
    }
    mRunning = false;
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

public void parseMessage(Message message) {
    Utility.logDebug(TAG, "parsing Message");
    Bundle data = message.getData();
    String str = data.getString(BUNDLE_DATA);
    try {/*from w ww.  j a v  a 2  s .  co m*/
        JSONObject jObj = new JSONObject(str);
        int type = jObj.getInt("type");
        if (type == TYPE_FILE_PATH) {
            String fileName = jObj.getString("filename");
            Utility.logDebug(TAG, "fileName = " + fileName);
            messageReceiver.setImage(fileName);
        } else if (type == TYPE_CONNECTION_STATUS) {
            boolean isConnected = jObj.getBoolean("connection");
            Utility.logDebug(TAG, "isConnected = " + isConnected);
            messageReceiver.onConnectionStatusReceived(isConnected);
        } else if (type == TYPE_HEARTBEAT_COUNT) {
            int count = jObj.getInt("heartbeat");
            Utility.logDebug(TAG, "heartbeat count = " + Integer.toString(count));
            messageReceiver.onHeartbeatsReceived(count);
        } else if (type == TYPE_STEPS_COUNT) {
            int count = jObj.getInt("steps");
            Utility.logDebug(TAG, "steps count = " + Integer.toString(count));
            messageReceiver.onStepsReceived(count);
        } else if (type == TYPE_TEXT) {
            String text = jObj.getString("text");
            Utility.logDebug(TAG, "text = " + text);
            messageReceiver.onMessageReceived(text);
        } else {
            Utility.logError(TAG, "unsupported type (" + type + ")");
        }

    } catch (JSONException e) {
        Utility.logError(TAG, "", e);
    }
}

From source file:com.reicast.emulator.debug.About.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_fragment);
    handler = new Handler();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        buildId = extras.getString("hashtag");
    }/*  ww w  . j a  v  a 2  s  .c  o  m*/

    try {
        String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
        TextView version = (TextView) findViewById(R.id.revision_text);
        String revision = getString(R.string.revision_text, versionName, String.valueOf(versionCode));
        if (!buildId.equals("")) {
            String ident = buildId.substring(0, 7);
            if (Config.isCustom) {
                ident = "LK-" + ident;
            }
            revision = getString(R.string.revision_text, versionName, ident);
        }
        version.setText(revision);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    slidingGithub = (SlidingDrawer) findViewById(R.id.slidingGithub);
    slidingGithub.setOnDrawerOpenListener(new OnDrawerOpenListener() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        public void onDrawerOpened() {
            retrieveGitTask queryGithub = new retrieveGitTask();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                queryGithub.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Config.git_api);
            } else {
                queryGithub.execute(Config.git_api);
            }
        }
    });
    slidingGithub.open();
}