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:de.appplant.cordova.plugin.notification.AbstractTriggerReceiver.java

/**
 * Called when an alarm was triggered.//from w  w  w.  j av  a  2  s  . co m
 *
 * @param context
 *      Application context
 * @param intent
 *      Received intent with content data
 */
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Options options;

    try {
        String data = bundle.getString(Options.EXTRA);
        JSONObject dict = new JSONObject(data);

        options = new Options(context).parse(dict);
    } catch (JSONException e) {
        e.printStackTrace();
        return;
    }

    if (options == null)
        return;

    if (isFirstAlarmInFuture(options))
        return;

    Builder builder = new Builder(options);
    Notification notification = buildNotification(builder);
    boolean updated = notification.isUpdate();

    onTrigger(notification, updated);
}

From source file:gov.wa.wsdot.android.wsdot.ui.MountainPassItemForecastFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    Bundle args = activity.getIntent().getExtras();
    forecastsArray = args.getString("Forecasts");

    JSONArray forecasts;//w  w  w  . j  a va 2 s .c  om
    ForecastItem f = null;
    forecastItems = new ArrayList<ForecastItem>();

    try {
        forecasts = new JSONArray(forecastsArray);
        int numForecasts = forecasts.length();
        for (int i = 0; i < numForecasts; i++) {
            JSONObject forecast = forecasts.getJSONObject(i);
            f = new ForecastItem();
            f.setDay(forecast.getString("Day"));
            f.setForecastText(forecast.getString("ForecastText"));
            f.setWeatherIcon(forecast.getInt("weather_icon"));
            forecastItems.add(f);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.notifry.android.remote.BackendClient.java

private String getAuthToken(Context context, Account account) throws PendingAuthException {
    String authToken = null;//from   w  w w .jav a  2 s. c  om
    AccountManager accountManager = AccountManager.get(context);
    try {
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, "ah", false, null, null);
        Bundle bundle = future.getResult();
        authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
        // User will be asked for "App Engine" permission.
        if (authToken == null) {
            // No auth token - will need to ask permission from user.
            Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
            if (intent != null) {
                // User input required
                context.startActivity(intent);
                throw new PendingAuthException("Asking user for permission.");
            }
        }
    } catch (OperationCanceledException e) {
        Log.w(TAG, e.getMessage());
    } catch (AuthenticatorException e) {
        Log.w(TAG, e.getMessage());
    } catch (IOException e) {
        Log.w(TAG, e.getMessage());
    }

    return authToken;
}

From source file:org.liberty.android.fantastischmemo.downloader.dropbox.DownloadDBFileListFragment.java

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Bundle args = getArguments();
    assert args != null : "The DownloadDBFileListFragment must have authToken and autoTokenSecret";
    String authToken = args.getString(EXTRA_AUTH_TOKEN);
    String authTokenSecret = args.getString(EXTRA_AUTH_TOKEN_SECRET);
    downloadHelper = downloadHelperFactory.create(authToken, authTokenSecret);
}

From source file:com.amanmehara.programming.android.activities.LanguageActivity.java

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

    sharedPreferences = getSharedPreferences("Programming", MODE_PRIVATE);

    setContentView(R.layout.activity_language);
    setActionBar(R.id.toolbar, true);//  ww  w.  j  a  v a 2  s.co m
    recyclerView = setRecyclerView(R.id.language_recycler_view);

    Bundle bundle = getIntent().getExtras();
    accessToken = bundle.getString("accessToken");
    String url = Constants.ENDPOINT + LANGUAGES_PATH;

    if (isConnected()) {
        String response = sharedPreferences.getString(url, null);
        if (Objects.nonNull(response)) {
            getLanguagesResponseCallback(url, true).accept(response);
        } else {
            new GithubAPIClient(this, getLanguagesResponseCallback(url, false)).execute(withAccessToken(url));
        }
    } else {
        setAdapter();
        Map<String, Serializable> extrasMap = new HashMap<>();
        extrasMap.put("enumeration.Activity", Activity.LANGUAGE);
        extrasMap.put("accessToken", accessToken);
        startActivity(ConnectionActivity.class, extrasMap);
    }
}

From source file:com.facebook.login.GetTokenLoginMethodHandler.java

void complete(final LoginClient.Request request, final Bundle result) {
    String userId = result.getString(NativeProtocol.EXTRA_USER_ID);
    // If the result is missing the UserId request it
    if (userId == null || userId.isEmpty()) {
        loginClient.notifyBackgroundProcessingStart();

        String accessToken = result.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);
        Utility.getGraphMeRequestWithCacheAsync(accessToken, new Utility.GraphMeRequestWithCacheCallback() {
            @Override/*from w w  w .  jav a 2  s  . c o m*/
            public void onSuccess(JSONObject userInfo) {
                try {
                    String userId = userInfo.getString("id");
                    result.putString(NativeProtocol.EXTRA_USER_ID, userId);
                    onComplete(request, result);
                } catch (JSONException ex) {
                    loginClient.complete(LoginClient.Result.createErrorResult(loginClient.getPendingRequest(),
                            "Caught exception", ex.getMessage()));
                }
            }

            @Override
            public void onFailure(FacebookException error) {
                loginClient.complete(LoginClient.Result.createErrorResult(loginClient.getPendingRequest(),
                        "Caught exception", error.getMessage()));
            }
        });
    } else {
        onComplete(request, result);
    }

}

From source file:com.geekandroid.sdk.sample.JPushReceiver.java

private void processCustomMessage(Context context, Bundle bundle) {
    //       if (MainActivity.isForeground) {
    String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
    String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
    Intent msgIntent = new Intent(MESSAGE_RECEIVED_ACTION);
    msgIntent.putExtra(KEY_MESSAGE, message);
    if (!isEmpty(extras)) {
        try {/*from  w  w w.j a  va 2 s  .  co m*/
            JSONObject extraJson = new JSONObject(extras);
            if (null != extraJson && extraJson.length() > 0) {
                msgIntent.putExtra(KEY_EXTRAS, extras);
            }
        } catch (JSONException e) {

        }

    }
    context.sendBroadcast(msgIntent);
    //      }
}

From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationProvider.java

public void broadcastLocation(Location location) {
    final LocationProxy bgLocation = LocationProxy.fromAndroidLocation(location);
    bgLocation.setServiceProvider(config.getServiceProvider());

    if (config.isDebugging()) {
        bgLocation.setDebug(true);//from  w w w .  j  a va  2  s  .  c om
        persistLocation(bgLocation);
    }

    Log.d(TAG, "Broadcasting update message: " + bgLocation.toString());
    try {
        String locStr = bgLocation.toJSONObject().toString();
        Intent intent = new Intent(Constant.ACTION_FILTER);
        intent.putExtra(Constant.ACTION, Constant.ACTION_LOCATION_UPDATE);
        intent.putExtra(Constant.DATA, locStr);
        if (config.getUrl() != null) {
            Log.i(TAG, "Sending URL detail");
            intent.putExtra("url", config.getUrl());
            intent.putExtra("method", config.getMethod());
            intent.putExtra("headers", config.getHeaders());
            intent.putExtra("params", config.getParams());
        } else {
            Log.i(TAG, "No URL defined");
        }
        context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
            // @SuppressLint("NewApi")
            @Override
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "Final Result Receiver");
                Bundle results = getResultExtras(true);
                if (results.getString(Constant.LOCATION_SENT_INDICATOR) == null) {
                    Log.w(TAG, "Main activity seems to be killed");
                    if (config.getStopOnTerminate() == false) {
                        bgLocation.setDebug(false);
                        persistLocation(bgLocation);
                        Log.d(TAG, "Persisting location. Reason: Main activity was killed.");
                    }
                }
            }
        }, null, Activity.RESULT_OK, null, null);
    } catch (JSONException e) {
        Log.w(TAG, "Failed to broadcast location");
    }
}

From source file:com.flowzr.budget.holo.export.flowzr.FlowzrBillTask.java

protected void onGetAuthToken(Bundle bundle) {
    String auth_token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
    new GetCookieTask().execute(auth_token);
}

From source file:com.fanfou.app.opensource.update.AppVersionInfo.java

public void readFromBundle(final Bundle bundle) {
    this.versionCode = bundle.getInt("versionCode");
    this.versionName = bundle.getString("versionName");
    this.releaseDate = bundle.getString("releaseDate");
    this.changelog = bundle.getString("changelog");
    this.downloadUrl = bundle.getString("downloadUrl");
    this.versionType = bundle.getString("versionType");
    this.packageName = bundle.getString("packageName");
    this.forceUpdate = bundle.getBoolean("forceUpdate");
}