Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

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

Prototype

public long getLong(String key) 

Source Link

Document

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Usage

From source file:bucci.dev.freestyle.TimerActivity.java

private void manageRecreatingActivity(Bundle savedInstanceState) {
    if (isTimerResumedFromNotification()) {
        if (DEBUG)
            Log.d(TAG, "Timer resumed from notification");
        if (getIntent().getStringExtra(START_PAUSE_STATE_PARAM).equals(PLAY_BUTTON_START_STATE))
            setPlayButtonState(PLAY_BUTTON_START_STATE);
        else//from   w w  w . ja  v a  2 s .com
            setPlayButtonState(PLAY_BUTTON_PAUSE_STATE);

        setTimer(getIntent().getLongExtra(TIME_LEFT_PARAM, 0));
        timeLeft = getIntent().getLongExtra(TIME_LEFT_PARAM, 0);
        getIntent().removeExtra(START_PAUSE_STATE_PARAM);
    } else {
        if (savedInstanceState == null || savedInstanceState.getLong(TIME_LEFT_PARAM) == 0) {
            if (DEBUG)
                Log.d(TAG, "Timer set to start time");
            setTimer(startTime);
        } else {
            if (DEBUG)
                Log.d(TAG, "Timer set to savedTime");
            long savedTimeLeft = savedInstanceState.getLong(TIME_LEFT_PARAM);
            if (savedTimeLeft > 0) {
                timeLeft = savedTimeLeft;
                setTimer(savedTimeLeft);
            }
        }

        if (savedInstanceState != null) {
            if (savedInstanceState.getString(START_PAUSE_STATE_PARAM) != null) {
                if (savedInstanceState.getString(START_PAUSE_STATE_PARAM).equals(PLAY_BUTTON_START_STATE))
                    setPlayButtonState(PLAY_BUTTON_START_STATE);
                else
                    setPlayButtonState(PLAY_BUTTON_PAUSE_STATE);
            }

            if (savedInstanceState.getBoolean(SHOW_EXTRA_ROUND_BUTTON_PARAM))
                showExtraRoundButton();
        }
    }
}

From source file:com.fsm.storybook.launcher.WebViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);

    context = this;
    bkdb = new BookDatabase(getApplicationContext());
    globalApp = (GlobalApplication) this.getApplicationContext();
    util = new ActivityUtil(this);
    currentOrientation = String.valueOf(util.getScreenOrientation());
    gestureListener = new ContentGestureListener(this);
    //gestureListener = new WebViewGestureDetector();

    mWebview = (WebView) findViewById(R.id.webview);
    //mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mWebview.setOnClickListener(WebViewActivity.this);
    mWebview.setOnTouchListener(gestureListener);
    //mHiddenWebview = (WebView) findViewById(R.id.webview_hidden);
    //mHiddenWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mPageInfo = (TextView) findViewById(R.id.page_info);
    mPageSlider = (SeekBar) findViewById(R.id.page_slider);
    mPageSlider.setOnSeekBarChangeListener(this);
    mPageInfo.setVisibility(View.GONE);
    mPageSlider.setVisibility(View.GONE);

    Intent intent = getIntent();/* ww  w.j  a  v  a2 s. c o  m*/
    Bundle extras = intent.getExtras();

    if (extras == null)
        return;
    //if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) {

    mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID));
    if (mContainer == null) {
        finish();
        return;
    }
    mPackage = mContainer.getDefaultPackage();

    //?
    int bookCode = extras.getInt(Constants.BOOK_CODE);
    mBookData = bkdb.fetchBook(bookCode);
    setTitle(mBookData.getTitle());

    //??spineitem?spineitem??
    List<SpineItem> spineItems = mPackage.getSpineItems();
    for (SpineItem item : spineItems) {
        String idref = item.getIdRef();
        mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_PORTRAIT), idref, 1);
        mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_LANDSCAPE), idref, 1);
    }
    bkdb.updateBook(mBookData);

    /*
    mBookmarkList = bkdb.fetchBookmarkList(bookCode);
    mHighlightList = bkdb.fetchHighlightList(bookCode);
    */
    mViewerSettings = new ViewerSettings(mBookData.getSpreadCount() == 2, mBookData.getFontSize(), 20);
    try {
        Log.d(TAG, "openPageRequest JSON:" + extras.getString(Constants.OPEN_PAGE_REQUEST_DATA));
        mOpenPageRequestData = OpenPageRequest.fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA));
    } catch (JSONException e) {
        Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e);
    }

    //???
    if (mBookData.getTotalPageCount(currentOrientation) <= 0) {
        pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_NONE;
    } else {
        pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_DONE;
    }

    //epub web server
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, false);
            mServer.startServer();
            return null;
        }
    }.execute();

    //??hidden webview
    /*
    initHiddenWebView();
    mHiddenWebview.loadUrl(HIDDEN_READER_SKELETON);
    mReadiumJSApiForHiddenWebView = new ReadiumJSApi(new ReadiumJSApi.JSLoader() {
     @Override
     public void loadJS(String javascript) {
        mHiddenWebview.loadUrl(javascript);
     }
    });
    */

    //?webview
    initWebView();
    mWebview.loadUrl(READER_SKELETON);
    mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() {
        @Override
        public void loadJS(String javascript) {
            mWebview.loadUrl(javascript);
        }
    });

    //}

}

From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java

/**
 * Called when the activity is first created.
 *///from  w w  w. j a  va2s  .c  om
@Override
public void onCreate(Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receive_coins_activity);
    ButterKnife.bind(this);

    _mbwManager = MbwManager.getInstance(getApplication());

    // Get intent parameters
    _address = Preconditions.checkNotNull((Address) getIntent().getSerializableExtra("address"));
    _havePrivateKey = getIntent().getBooleanExtra("havePrivateKey", false);
    _showIncomingUtxo = getIntent().getBooleanExtra("showIncomingUtxo", false);

    // Load saved state
    if (savedInstanceState != null) {
        _amount = (CurrencyValue) savedInstanceState.getSerializable(AMOUNT);
        _receivingSince = savedInstanceState.getLong(RECEIVING_SINCE);
        _lastAddressBalance = (CurrencyValue) savedInstanceState.getSerializable(LAST_ADDRESS_BALANCE);
        _syncErrors = savedInstanceState.getInt(SYNC_ERRORS);
    } else {
        _receivingSince = new Date().getTime();
    }

    // Amount Hint
    tvAmount.setHint(getResources().getString(R.string.amount_hint_denomination,
            _mbwManager.getBitcoinDenomination().toString()));
    shareByNfc();
}

From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java

@Override
protected Dialog onCreateDialog(final int id, final Bundle args) {
    if (id == DIALOG_IMPORT_KEYS)
        return createImportKeysDialog();
    else if (id == DIALOG_EXPORT_KEYS)
        return createExportKeysDialog();
    else if (id == DIALOG_TIMESKEW_ALERT)
        return createTimeskewAlertDialog(args.getLong("diff_minutes"));
    else if (id == DIALOG_VERSION_ALERT)
        return createVersionAlertDialog();
    else if (id == DIALOG_LOW_STORAGE_ALERT)
        return createLowStorageAlertDialog();
    else/*from w ww  . j  a  va  2  s.  co  m*/
        throw new IllegalArgumentException();
}

From source file:de.schildbach.wallet.ui.WalletActivity.java

@Override
protected Dialog onCreateDialog(final int id, final Bundle args) {
    if (id == DIALOG_BACKUP_WALLET_PERMISSION)
        return createBackupWalletPermissionDialog();
    else if (id == DIALOG_RESTORE_WALLET_PERMISSION)
        return createRestoreWalletPermissionDialog();
    else if (id == DIALOG_RESTORE_WALLET)
        return createRestoreWalletDialog();
    else if (id == DIALOG_TIMESKEW_ALERT)
        return createTimeskewAlertDialog(args.getLong("diff_minutes"));
    else if (id == DIALOG_VERSION_ALERT)
        return createVersionAlertDialog();
    else if (id == DIALOG_LOW_STORAGE_ALERT)
        return createLowStorageAlertDialog();
    else/*from  www.  ja  v  a  2  s .co  m*/
        throw new IllegalArgumentException();
}

From source file:com.android.calendar.alerts.AlertService.java

void processMessage(Message msg) {
    Bundle bundle = (Bundle) msg.obj;

    // On reboot, update the notification bar with the contents of the
    // CalendarAlerts table.
    String action = bundle.getString("action");
    if (DEBUG) {//from www  .j av  a2 s  .c  o  m
        Log.d(TAG, bundle.getLong(android.provider.CalendarContract.CalendarAlerts.ALARM_TIME) + " Action = "
                + action);
    }

    // Some OEMs had changed the provider's EVENT_REMINDER broadcast to their own event,
    // which broke our unbundled app's reminders.  So we added backup alarm scheduling to the
    // app, but we know we can turn it off if we ever receive the EVENT_REMINDER broadcast.
    boolean providerReminder = action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER);
    if (providerReminder) {
        if (sReceivedProviderReminderBroadcast == null) {
            sReceivedProviderReminderBroadcast = Utils.getSharedPreference(this, PROVIDER_REMINDER_PREF_KEY,
                    false);
        }

        if (!sReceivedProviderReminderBroadcast) {
            sReceivedProviderReminderBroadcast = true;
            Log.d(TAG, "Setting key " + PROVIDER_REMINDER_PREF_KEY + " to: true");
            Utils.setSharedPreference(this, PROVIDER_REMINDER_PREF_KEY, true);
        }
    }

    if (providerReminder || action.equals(Intent.ACTION_PROVIDER_CHANGED)
            || action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER)
            || action.equals(AlertReceiver.EVENT_REMINDER_APP_ACTION)
            || action.equals(Intent.ACTION_LOCALE_CHANGED)) {

        // b/7652098: Add a delay after the provider-changed event before refreshing
        // notifications to help issue with the unbundled app installed on HTC having
        // stale notifications.
        if (action.equals(Intent.ACTION_PROVIDER_CHANGED)) {
            try {
                Thread.sleep(5000);
            } catch (Exception e) {
                // Ignore.
            }
        }

        updateAlertNotification(this);
    } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
        // The provider usually initiates this setting up of alarms on startup,
        // but there was a bug (b/7221716) where a race condition caused this step to be
        // skipped, resulting in missed alarms.  This is a stopgap to minimize this bug
        // for devices that don't have the provider fix, by initiating this a 2nd time here.
        // However, it would still theoretically be possible to hit the race condition
        // the 2nd time and still miss alarms.
        //
        // TODO: Remove this when the provider fix is rolled out everywhere.
        Intent intent = new Intent();
        intent.setClass(this, InitAlarmsService.class);
        startService(intent);
    } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
        doTimeChanged();
    } else if (action.equals(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS)) {
        dismissOldAlerts(this);
    } else {
        Log.w(TAG, "Invalid action: " + action);
    }

    // Schedule the alarm for the next upcoming reminder, if not done by the provider.
    if (sReceivedProviderReminderBroadcast == null || !sReceivedProviderReminderBroadcast) {
        Log.d(TAG, "Scheduling next alarm with AlarmScheduler. " + "sEventReminderReceived: "
                + sReceivedProviderReminderBroadcast);
        AlarmScheduler.scheduleNextAlarm(this);
    }
}

From source file:com.androzic.navigation.NavigationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        Intent activity = new Intent(this, MainActivity.class)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        String action = intent.getAction();
        if (action == null)
            return 0;
        Bundle extras = intent.getExtras();
        if (action.equals(NAVIGATE_MAPOBJECT)) {
            MapObject mo = new MapObject();
            mo.name = extras.getString(EXTRA_NAME);
            mo.latitude = extras.getDouble(EXTRA_LATITUDE);
            mo.longitude = extras.getDouble(EXTRA_LONGITUDE);
            mo.proximity = extras.getInt(EXTRA_PROXIMITY);
            activity.putExtra(MainActivity.LAUNCH_ACTIVITY, HSIActivity.class);
            contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity,
                    PendingIntent.FLAG_CANCEL_CURRENT);
            navigateTo(mo);/*from  w ww .j a  v a2  s  .  co  m*/
        }
        if (action.equals(NAVIGATE_MAPOBJECT_WITH_ID)) {
            long id = extras.getLong(EXTRA_ID);
            MapObject mo = application.getMapObject(id);
            if (mo == null)
                return 0;
            activity.putExtra(MainActivity.LAUNCH_ACTIVITY, HSIActivity.class);
            contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity,
                    PendingIntent.FLAG_CANCEL_CURRENT);
            navigateTo(mo);
        }
        if (action.equals(NAVIGATE_ROUTE)) {
            int index = extras.getInt(EXTRA_ROUTE_INDEX);
            int dir = extras.getInt(EXTRA_ROUTE_DIRECTION, DIRECTION_FORWARD);
            int start = extras.getInt(EXTRA_ROUTE_START, -1);
            activity.putExtra(MainActivity.SHOW_FRAGMENT, RouteDetails.class);
            activity.putExtra("index", index);
            contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity,
                    PendingIntent.FLAG_CANCEL_CURRENT);
            Route route = application.getRoute(index);
            if (route == null)
                return 0;
            navigateTo(route, dir);
            if (start != -1)
                setRouteWaypoint(start);
        }
    }
    return START_STICKY;
}

From source file:com.silentcircle.contacts.list.ScContactEntryListFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id == DIRECTORY_LOADER_ID) {
        //  TODO            DirectoryListLoader loader = new DirectoryListLoader(mContext);
        //            mAdapter.configureDirectoryLoader(loader);
        //            return loader;
        return null;
    } else {//from   www.  j a  v a 2s. co m
        CursorLoader loader = createCursorLoader();
        long directoryId = args != null && args.containsKey(DIRECTORY_ID_ARG_KEY)
                ? args.getLong(DIRECTORY_ID_ARG_KEY)
                : Directory.DEFAULT;
        mAdapter.configureLoader(loader, directoryId);
        return loader;
    }
}

From source file:cz.maresmar.sfm.view.credential.CredentialDetailFragment.java

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

    if (getArguments() != null) {
        if (getArguments().getBoolean(ARG_START_WITH_EMPTY)) {
            mUserPrefixUri = getArguments().getParcelable(ARG_USER_PREFIX_URI);
            mPortalUri = getArguments().getParcelable(ARG_PORTAL_URI);
        } else {//ww w  . ja  v  a  2s  .  c o  m
            mCredentialUri = getArguments().getParcelable(ARG_CREDENTIAL_URI);

            getLoaderManager().initLoader(CREDENTIAL_LOADER_ID, null, this);
        }
    }

    if (savedInstanceState != null) {
        mCredentialUri = savedInstanceState.getParcelable(ARG_CREDENTIAL_URI);
        mCredentialTempUri = savedInstanceState.getParcelable(ARG_CREDENTIAL_TEMP_URI);
        mPortalUri = savedInstanceState.getParcelable(ARG_PORTAL_URI);
        mUserPrefixUri = savedInstanceState.getParcelable(ARG_USER_PREFIX_URI);
        mPortalGroupId = savedInstanceState.getLong(ARG_PORTAL_GROUP_ID);
        mLastPlugin = savedInstanceState.getString(ARG_LAST_PLUGIN);
        mLoadDataFromDb = false;
    }
}

From source file:com.narkii.security.info.SecureDataFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    // TODO Auto-generated method stub
    DbCursorLoader cursorLoader = null;//  w  ww  .  ja va  2  s. c o m
    final DbOperations operations = DbOperations.getInstance(getActivity());

    if (id == Constants.ENTERPRISE_INFO_ID) {
        //         final long rowId=bundle.getLong("id");
        //         cursorLoader=new DbCursorLoader(getActivity()) {
        //            
        //            @Override
        //            public Cursor getDbCursor() {
        //               // TODO Auto-generated method stub
        //               String columns[] = { Enterprise.COLUMN_FK_SAFETY_PERMIT_TYPE,
        //                     Enterprise.COLUMN_SITUATION,
        //                     Enterprise.COLUMN_SAFETY_PERMIT_NUM,
        //                     Enterprise.COLUMN_ISSUE_DATE, Enterprise.COLUMN_VALID_DATE,
        //                     Enterprise.COLUMN_SCOPE };
        //               return operations.query(Enterprise.TABLE_NAME, columns, Enterprise._ID+"=?", new String[]{""+rowId});
        //            }
        //         };

    } else if (id == Constants.FILING_ID) {
        final long rowId = bundle.getLong("id");
        cursorLoader = new DbCursorLoader(getActivity()) {

            @Override
            public Cursor getDbCursor() {
                // TODO Auto-generated method stub
                return operations.query(Filing.TABLE_NAME, null, Filing.COLUMN_FK_ENTERPRISE_ID + "=?",
                        new String[] { "" + rowId });
            }
        };
    } else if (id == Constants.SPINNER_SAFETY_PERMIT_TYPE_ID) {
        cursorLoader = new DbCursorLoader(getActivity()) {

            @Override
            public Cursor getDbCursor() {
                // TODO Auto-generated method stub
                return operations.query(SafetyPermitType.TABLE_NAME, null, null, null);
            }
        };
    } else if (id == Constants.SPINNER_VARITY_TYPE_ID) {
        cursorLoader = new DbCursorLoader(getActivity()) {

            @Override
            public Cursor getDbCursor() {
                // TODO Auto-generated method stub
                return operations.query(VarityType.TABLE_NAME, null, null, null);
            }
        };
    }
    return cursorLoader;
}