Example usage for android.os Bundle putLong

List of usage examples for android.os Bundle putLong

Introduction

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

Prototype

public void putLong(@Nullable String key, long value) 

Source Link

Document

Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java

private void checkAlerts() {
    final PackageInfo packageInfo = getWalletApplication().packageInfo();
    final int versionNameSplit = packageInfo.versionName.indexOf('-');
    final String base = Constants.VERSION_URL
            + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : "");
    final String url = base + "?package=" + packageInfo.packageName + "&current=" + packageInfo.versionCode;

    new HttpGetThread(getAssets(), url, application.httpUserAgent()) {
        @Override/*  ww w. ja  va 2 s . c  om*/
        protected void handleLine(final String line, final long serverTime) {
            final int serverVersionCode = Integer.parseInt(line.split("\\s+")[0]);

            log.info("according to \"" + url + "\", strongly recommended minimum app version is "
                    + serverVersionCode);

            if (serverTime > 0) {
                final long diffMinutes = Math
                        .abs((System.currentTimeMillis() - serverTime) / DateUtils.MINUTE_IN_MILLIS);

                if (diffMinutes >= 60) {
                    log.info(
                            "according to \"" + url + "\", system clock is off by " + diffMinutes + " minutes");

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            final Bundle args = new Bundle();
                            args.putLong("diff_minutes", diffMinutes);
                            showDialog(DIALOG_TIMESKEW_ALERT, args);
                        }
                    });

                    return;
                }
            }

            if (serverVersionCode > packageInfo.versionCode) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        showDialog(DIALOG_VERSION_ALERT);
                    }
                });

                return;
            }
        }

        @Override
        protected void handleException(final Exception x) {
            if (x instanceof UnknownHostException || x instanceof SocketException
                    || x instanceof SocketTimeoutException) {
                // swallow
                log.debug("problem reading", x);
            } else {
                CrashReporter.saveBackgroundTrace(new RuntimeException(url, x), packageInfo);
            }
        }
    }.start();

    if (CrashReporter.hasSavedCrashTrace()) {
        final StringBuilder stackTrace = new StringBuilder();

        try {
            CrashReporter.appendSavedCrashTrace(stackTrace);
        } catch (final IOException x) {
            log.info("problem appending crash info", x);
        }

        final ReportIssueDialogBuilder dialog = new ReportIssueDialogBuilder(this,
                R.string.report_issue_dialog_title_crash, R.string.report_issue_dialog_message_crash) {
            @Override
            protected CharSequence subject() {
                return Constants.REPORT_SUBJECT_CRASH + " " + packageInfo.versionName;
            }

            @Override
            protected CharSequence collectApplicationInfo() throws IOException {
                final StringBuilder applicationInfo = new StringBuilder();
                CrashReporter.appendApplicationInfo(applicationInfo, application);
                return applicationInfo;
            }

            @Override
            protected CharSequence collectStackTrace() throws IOException {
                if (stackTrace.length() > 0)
                    return stackTrace;
                else
                    return null;
            }

            @Override
            protected CharSequence collectDeviceInfo() throws IOException {
                final StringBuilder deviceInfo = new StringBuilder();
                CrashReporter.appendDeviceInfo(deviceInfo, WalletActivity.this);
                return deviceInfo;
            }

            @Override
            protected CharSequence collectWalletDump() {
                return application.getWallet().toString(false, true, true, null);
            }
        };

        dialog.show();
    }
}

From source file:com.facebook.FacebookActivityTestCase.java

protected Bundle getNativeLinkingExtras(String token, String userId) {
    readApplicationIdAndSecret();//w w  w .  j  a v a  2  s  . c  o  m

    Bundle extras = new Bundle();
    String extraLaunchUriString = String.format(
            "fbrpc://facebook/nativethirdparty?app_id=%s&package_name=com.facebook.sdk.tests&class_name=com.facebook.FacebookActivityTests$FacebookTestActivity&access_token=%s",
            applicationId, token);
    extras.putString("extra_launch_uri", extraLaunchUriString);
    extras.putString("expires_in", "3600");
    extras.putLong("app_id", Long.parseLong(applicationId));
    extras.putString("access_token", token);
    if (userId != null && !userId.isEmpty()) {
        extras.putString("user_id", userId);
    }

    return extras;
}

From source file:com.mci.firstidol.activity.MainActivity.java

private void obtainBaiduPushClickEvent(String customContentString) {
    // TODO Auto-generated method stub
    long articleId = 0, articleType = 0, channelId = 0, modelType = 0;
    // ??mykeymyvalue?
    if (!TextUtils.isEmpty(customContentString)) {
        JSONObject customJson = null;//from  w w  w.j a  v a2 s  .  co m
        try {
            customJson = new JSONObject(customContentString);
            articleId = customJson.getLong("rel_id");
            articleType = customJson.getLong("rel_type");
            channelId = customJson.getLong("rel_channel");
            modelType = customJson.getLong("rel_modeltype");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    // // Demo???
    // updateContent(context, notifyString);
    //
    //
    // Intent intent = new Intent();
    // intent.setClass(context.getApplicationContext(),
    // LoginActivity.class);
    // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // context.getApplicationContext().startActivity(intent);

    // ?ChannelId  ModelType????
    // SquareLiveModel squareLiveModel = headers.get(position);
    if (channelId == 49) {// ?
        if (modelType == 2) {// ?
            Bundle bundle = new Bundle();
            bundle.putBoolean("IsVideo", true);
            bundle.putLong(Constant.IntentKey.articleID, articleId);
            Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true);
        } else {// ?
            Bundle bundle = new Bundle();
            bundle.putLong(Constant.IntentKey.articleID, articleId);
            Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true);
        }
    } else if (channelId == 44) {// 
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        mbuBundle.putString(Constant.IntentKey.typeCode, Constant.IntentValue.ACTIVITY_SHOPPING);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    } else if (channelId == 43) {// ?
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    } else if (channelId == 47) {// 
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareLiveActivity.class, mbuBundle, true);
    } else {// ,web
        Bundle mbuBundle = new Bundle();
        mbuBundle.putBoolean("IsFromFound", true);
        mbuBundle.putBoolean(Constant.IntentKey.isSearch, true);
        mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId);
        Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true);
    }
}

From source file:com.zsxj.pda.ui.client.LoginActivity.java

@Override
public void onReponse(Object id, InputStream data) throws IOException {
    if (null != mUpdateDataId && mUpdateDataId.toString().equals(id.toString())) {

        try {/*  w w w  .  j ava2  s .c  om*/
            String rtnData = new String(Util.readDataFromIS(data));
            if (null == rtnData || rtnData.equals("")) {
                sendCheckUpdateRequest();
                return;
            }

            JSONObject result = new JSONObject(rtnData);
            // Message return 
            Bundle bundle = new Bundle();
            bundle.putInt("update_type", result.optJSONObject("init_response").optInt("update_type"));
            bundle.putInt("update_method", result.optJSONObject("init_response").optInt("update_method"));
            bundle.putString("update_url", result.optJSONObject("init_response").optString("update_url"));
            bundle.putString("update_ver", result.optJSONObject("init_response").optString("update_ver"));
            bundle.putLong("update_size", result.optJSONObject("init_response").optLong("update_size"));
            bundle.putString("update_msg", result.optJSONObject("init_response").optString("update_msg"));
            Message message = new Message();
            message.what = HandlerCases.UPDATE_CHECK;
            message.setData(bundle);
            handler.sendMessage(message);
        } catch (Exception e) {
        }
    }
}

From source file:org.telegram.ui.LaunchActivity.java

@Override
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
    if (id == 1234) {
        for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
            fragment.onFragmentDestroy();
        }/*w w w.  j a v a2 s. co m*/
        ApplicationLoader.fragmentsStack.clear();
        Intent intent2 = new Intent(this, IntroActivity.class);
        startActivity(intent2);
        processOnFinish();
        finish();
    } else if (id == GalleryImageViewer.needShowAllMedia) {
        long dialog_id = (Long) args[0];
        MediaActivity fragment = new MediaActivity();
        Bundle bundle = new Bundle();
        if (dialog_id != 0) {
            bundle.putLong("dialog_id", dialog_id);
            fragment.setArguments(bundle);
            presentFragment(fragment, "media_" + dialog_id, false);
        }
    } else if (id == 658) {
        Integer push_user_id = (Integer) NotificationCenter.getInstance().getFromMemCache("push_user_id", 0);
        Integer push_chat_id = (Integer) NotificationCenter.getInstance().getFromMemCache("push_chat_id", 0);
        Integer push_enc_id = (Integer) NotificationCenter.getInstance().getFromMemCache("push_enc_id", 0);

        if (push_user_id != 0) {
            NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
            ChatActivity fragment = new ChatActivity();
            Bundle bundle = new Bundle();
            bundle.putInt("user_id", push_user_id);
            fragment.setArguments(bundle);
            if (fragment.onFragmentCreate()) {
                if (ApplicationLoader.fragmentsStack.size() > 0) {
                    BaseFragment lastFragment = ApplicationLoader.fragmentsStack
                            .get(ApplicationLoader.fragmentsStack.size() - 1);
                    lastFragment.willBeHidden();
                }
                ApplicationLoader.fragmentsStack.add(fragment);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
            }
        } else if (push_chat_id != 0) {
            NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
            ChatActivity fragment = new ChatActivity();
            Bundle bundle = new Bundle();
            bundle.putInt("chat_id", push_chat_id);
            fragment.setArguments(bundle);
            if (fragment.onFragmentCreate()) {
                if (ApplicationLoader.fragmentsStack.size() > 0) {
                    BaseFragment lastFragment = ApplicationLoader.fragmentsStack
                            .get(ApplicationLoader.fragmentsStack.size() - 1);
                    lastFragment.willBeHidden();
                }
                ApplicationLoader.fragmentsStack.add(fragment);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
            }
        } else if (push_enc_id != 0) {
            NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
            ChatActivity fragment = new ChatActivity();
            Bundle bundle = new Bundle();
            bundle.putInt("enc_id", push_enc_id);
            fragment.setArguments(bundle);
            if (fragment.onFragmentCreate()) {
                if (ApplicationLoader.fragmentsStack.size() > 0) {
                    BaseFragment lastFragment = ApplicationLoader.fragmentsStack
                            .get(ApplicationLoader.fragmentsStack.size() - 1);
                    lastFragment.willBeHidden();
                }
                ApplicationLoader.fragmentsStack.add(fragment);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
            }
        }
    } else if (id == 701) {
        if (notificationView != null) {
            MessageObject message = (MessageObject) args[0];
            notificationView.show(message);
        }
    } else if (id == 702) {
        if (args[0] != this) {
            processOnFinish();
        }
    } else if (id == 703) {
        int state = (Integer) args[0];
        if (currentConnectionState != state) {
            FileLog.e("tmessages", "switch to state " + state);
            currentConnectionState = state;
            updateActionBar();
        }
    }
}

From source file:com.bonsai.wallet32.SendBitcoinActivity.java

private DialogFragment showSendConfirmDialog(int acctId, String acctStr, String addrStr, long amount, long fee,
        double rate) {
    DialogFragment df = new SendConfirmDialogFragment();
    Bundle args = new Bundle();
    args.putInt("acctId", acctId);
    args.putString("acctStr", acctStr);
    args.putString("addr", addrStr);
    args.putLong("amount", amount);
    args.putLong("fee", fee);
    args.putDouble("rate", rate);
    df.setArguments(args);/*from w  ww  .jav a2s .  c  o m*/
    df.show(getSupportFragmentManager(), "sendconfirm");
    return df;
}

From source file:com.example.mydemos.view.RingtonePickerActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(SAVE_CLICKED_POS, mSelectedId);
}

From source file:com.javielinux.fragments.MyActivityFragment.java

public void createColumnsLastUser() {

    long lastIdUser = DataFramework.getInstance().getTopEntity("users", "", DataFramework.KEY_ID + " desc")
            .getId();//from  w  ww  .  ja  v  a  2 s  . com

    CreateDefaultColumnsUserDialogFragment frag = new CreateDefaultColumnsUserDialogFragment();
    Bundle args = new Bundle();
    args.putLong("user_id", lastIdUser);
    frag.setArguments(args);
    frag.show(getFragmentManager(), "dialog");
}

From source file:com.facebook.AuthorizationClient.java

private void logAuthorizationMethodStart(String method) {
    Bundle bundle = newAuthorizationLoggingBundle(pendingRequest.getAuthId());
    bundle.putLong(EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());
    bundle.putString(EVENT_PARAM_METHOD, method);

    getAppEventsLogger().logSdkEvent(EVENT_NAME_LOGIN_METHOD_START, null, bundle);
}

From source file:com.brandao.tictactoe.board.BoardFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putInt(SAVED_STATE_PLAYER_ONE_WINS, mPlayerOneWins);
    outState.putInt(SAVED_STATE_PLAYER_TWO_WINS, mPlayerTwoWins);
    outState.putInt(SAVED_STATE_TOTAL_TIES, mTotalTies);

    outState.putLong(SAVED_STATE_START_TIME, mStartTime);

    outState.putInt(SAVED_STATE_LAST_GAME_WINNER, mLastGameWinner);
    outState.putInt(SAVED_STATE_LAST_MOVE_INDEX, mLastMoveIndex);

    outState.putParcelable(SAVED_STATE_BOARD, mBoard);
    outState.putInt(SAVED_STATE_GAME_STATE, mGameState);

    super.onSaveInstanceState(outState);
}