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:cn.sharesdk.analysis.server.ServiceHelper.java

@Override
public boolean handleMessage(Message msg) {
    if (!Thread.currentThread().isInterrupted()) {
        // ?//ww w .j  a  va  2  s  . c om
        switch (msg.what) {
        case UPLOAD_LOG:
            uploadAllLog();
            break;
        case SAVE_SEND_LOG:
            Bundle bundle = msg.getData();
            String jsonString = bundle.getString("value");
            // Ln.i("insert msg ==>>", jsonString);
            sendIsAppExitMsg();
            MessageUtils.insertMsg(context, bundle.getString("action"), jsonString);
            uploadAllLog();
            break;
        case EXIT_APP:
            // exit app when the app in the background 15s
            if (appBackRunning) {
                return true;
            }
            appBackRunning = true;
            appExitCount = 0;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (appBackRunning) {
                        try {
                            if (isAppExit()) {
                                appExitCount++;
                                Ln.i("exit app after background seconds ==>>", appExitCount + "");
                                if (appExitCount == 15) {
                                    preference.setAppExitDate();
                                    Ln.i("exit app ==>>", " upload all log ");
                                    MessageUtils.insertMsg(context, MessageUtils.EXIT_DATA, getExitAppString());
                                    sendUploadLogMsg();
                                } else if (appExitCount >= 30) {
                                    appBackRunning = false;
                                }
                            } else {
                                appExitCount = 0;
                            }
                            Thread.sleep(1000);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();
            break;
        }
    }
    return false;
}

From source file:com.apptentive.android.sdk.ViewActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    returnToPushCallbackActivity = savedInstanceState.getBoolean("returnToPushCallbackActivity", false);
    pushCallbackActivityName = savedInstanceState.getString("pushCallbackActivityName");
    if (activityContent != null) {
        activityContent.onRestoreInstanceState(savedInstanceState);
    }// w  w w.  j  a  v  a 2 s. c  o  m
}

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

public void addLocalGame(final Bundle game) {
    final Object[] data = { game.getString("name"), game.getLong("ctime"), game.getLong("stime"),
            game.getInt("gametype"), game.getInt("opponent"), game.getString("history"),
            game.getString("zfen") };

    db.execSQL(//from   w ww.jav  a 2s  .  c  o  m
            "INSERT INTO localgames (name, ctime, stime, gametype, opponent, history, zfen) VALUES (?, ?, ?, ?, ?, ?, ?);",
            data);
}

From source file:org.jprofit.wsfscanner.ScannerActivity.java

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

    // Set layout
    setContentView(R.layout.activity_main);

    // Deal with orientation change restart by restoring webview content
    if (savedInstanceState != null) {
        webViewContent = savedInstanceState.getString(HTML_KEY);
        if (webViewContent != null) {
            updateWebView();//from w w  w .j  a v a 2 s.c o  m
        }
    }

    // Initialize members
    pbar = (ProgressBar) findViewById(R.id.progressBar);

    // Start in scanning mode automatically (the first time)
    if (savedInstanceState == null) {
        IntentIntegrator.initiateScan(this);
    }
}

From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java

/**
 * Queries the {@link android.content.pm.PackageManager} for any installed {@link
 * com.battlelancer.seriesguide.api.SeriesGuideExtension} extensions. Their info is extracted
 * into {@link com.battlelancer.seriesguide.extensions.ExtensionManager.Extension} objects.
 *//*  w ww  .ja  v a 2s . co m*/
public List<Extension> queryAllAvailableExtensions() {
    Intent queryIntent = new Intent(SeriesGuideExtension.ACTION_SERIESGUIDE_EXTENSION);
    PackageManager pm = mContext.getPackageManager();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA);

    List<Extension> extensions = new ArrayList<>();
    for (ResolveInfo info : resolveInfos) {
        Extension extension = new Extension();
        // get label, icon and component name
        extension.label = info.loadLabel(pm).toString();
        extension.icon = info.loadIcon(pm);
        extension.componentName = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name);
        // get description
        Context packageContext;
        try {
            packageContext = mContext.createPackageContext(extension.componentName.getPackageName(), 0);
            Resources packageRes = packageContext.getResources();
            extension.description = packageRes.getString(info.serviceInfo.descriptionRes);
        } catch (SecurityException | PackageManager.NameNotFoundException | Resources.NotFoundException e) {
            Timber.e(e, "Reading description for extension " + extension.componentName + " failed");
            extension.description = "";
        }
        // get (optional) settings activity
        Bundle metaData = info.serviceInfo.metaData;
        if (metaData != null) {
            String settingsActivity = metaData.getString("settingsActivity");
            if (!TextUtils.isEmpty(settingsActivity)) {
                extension.settingsActivity = ComponentName
                        .unflattenFromString(info.serviceInfo.packageName + "/" + settingsActivity);
            }
        }

        Timber.d("queryAllAvailableExtensions: found extension " + extension.label + " "
                + extension.componentName);
        extensions.add(extension);
    }

    return extensions;
}

From source file:com.chess.genesis.activity.GameListOnlineFrag.java

@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    act.lastContextMenu = getBTag();/*from   ww  w  .  ja  v a 2s  .  co m*/

    if (v.getId() == R.id.menu) {
        act.getMenuInflater().inflate(R.menu.options_gamelist_online, menu);
        return;
    }

    switch (pager.getCurrentItem()) {
    case THEIR_PAGE:
        final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        final GameListAdapter listAdapter = gamelistadapter_arr[pager.getCurrentItem()];
        final Bundle bundle = (Bundle) listAdapter.getItem((int) info.id);

        if (bundle.getString("idle").equals("1")) {
            act.getMenuInflater().inflate(R.menu.context_gamelist_online_nudge, menu);
            break;
        }
    case YOUR_PAGE:
        act.getMenuInflater().inflate(R.menu.context_gamelist_online, menu);
        break;
    case ARCHIVE_PAGE:
        act.getMenuInflater().inflate(R.menu.context_gamelist_archive, menu);
        break;
    }
}

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

@Override
public void setSettingsFromBundle(Bundle inState) {
    super.setSettingsFromBundle(inState);
    if (inState != null) {
        if (inState.containsKey(USER_ID_BUNDLE_KEY)) {
            setUserId(inState.getString(USER_ID_BUNDLE_KEY));
        }//from   w w w . jav  a2s .c  o  m
        setMultiSelect(inState.getBoolean(MULTI_SELECT_BUNDLE_KEY, multiSelect));
        if (inState.containsKey(FRIEND_PICKER_TYPE_KEY)) {
            try {
                friendPickerType = FriendPickerType.valueOf(inState.getString(FRIEND_PICKER_TYPE_KEY));
            } catch (Exception e) {
                // NOOP
            }
        }
    }
}

From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java

private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the
    // map.// www  . ja v  a2s.c o  m
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            // Hide the zoom controls as the button panel will cover it.
            mMap.getUiSettings().setZoomControlsEnabled(false);

            // Get the csv data from intent and then proceed
            Bundle bundle = getIntent().getExtras();
            final String csvHeader = bundle.getString(AppConstants.KEY_SPEEDTEST_CSV_HEADER);
            final String csvData = bundle.getString(AppConstants.KEY_SPEEDTEST_CSV_DATA);

            // create task if not created, otherwise re-use same task
            if (mDataProcessorTask == null) {
                mDataProcessorTask = new MarkerDataProcessorTask();
            }
            // Dispatch an asynctask to calculate required data for markers
            mDataProcessorTask.execute(csvHeader, csvData);
        }
    }
}

From source file:com.zapto.park.ParkActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    /*/*from  ww  w .j a  v a2  s  . co  m*/
     * Once a user has typed in their ID to clock and pressed Done,
     * the Pad will close and save the user's clock-in information
     * in the database clock.db
     * */
    if (resultCode == Activity.RESULT_OK && requestCode == ACTIVITY_RESULT_PAD) {
        Log.i(LOG_TAG, "onActivityResult()");
        Bundle extras = data.getExtras();
        String id = extras.getString("id");

        //this clocks in the user
        employeeCheck(id, true);

        Log.i(LOG_TAG, "Result: " + id);
    } else {
        Log.i(LOG_TAG, "onActivityResult(). Problem!");
    }
}

From source file:de.hackerspacebremen.fragments.ChangeStatusFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Bundle extras = getArguments();/*from www . ja  v a 2 s . c  om*/
    if (savedInstanceState != null && savedInstanceState.containsKey("change_json")
            && savedInstanceState.getString("change_json") != null) {
        this.change = ChangeDataJsonParser.parse(savedInstanceState.getString("change_json"));
    } else if (extras != null && extras.containsKey("change_json") && extras.getString("change_json") != null) {
        this.change = ChangeDataJsonParser.parse(extras.getString("change_json"));
    }
    super.onCreate(savedInstanceState);
}