Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

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

Prototype

public boolean getBoolean(String key) 

Source Link

Document

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

Usage

From source file:com.vegnab.vegnab.MainVNActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (LDebug.ON)
        Log.d(LOG_TAG, "In 'onRestoreInstanceState'");
    mSubplotTypeId = savedInstanceState.getLong(ARG_SUBPLOT_TYPE_ID);
    mVisitId = savedInstanceState.getLong(ARG_VISIT_ID);
    mConnectionRequested = savedInstanceState.getBoolean(ARG_CONNECTION_REQUESTED);
    mExistingPhCodes = (HashMap<String, Long>) savedInstanceState.getSerializable(ARG_PH_EXISTING_SET);
    mNewPurcRecId = savedInstanceState.getLong(ARG_PURCH_REC_ID);

}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ???/*from   w  ww.ja v a  2  s  .c o m*/
 *
 * @param savedInstanceState Bundle
 */
private void loadActivitySavedData(Bundle savedInstanceState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    String fieldName = f.getName();
                    @SuppressWarnings("rawtypes")
                    Class cls = f.getType();
                    if (cls == int.class || cls == Integer.class) {
                        f.setInt(this, savedInstanceState.getInt(fieldName));
                    } else if (String.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getString(fieldName));
                    } else if (Serializable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getSerializable(fieldName));
                    } else if (cls == long.class || cls == Long.class) {
                        f.setLong(this, savedInstanceState.getLong(fieldName));
                    } else if (cls == short.class || cls == Short.class) {
                        f.setShort(this, savedInstanceState.getShort(fieldName));
                    } else if (cls == boolean.class || cls == Boolean.class) {
                        f.setBoolean(this, savedInstanceState.getBoolean(fieldName));
                    } else if (cls == byte.class || cls == Byte.class) {
                        f.setByte(this, savedInstanceState.getByte(fieldName));
                    } else if (cls == char.class || cls == Character.class) {
                        f.setChar(this, savedInstanceState.getChar(fieldName));
                    } else if (CharSequence.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getCharSequence(fieldName));
                    } else if (cls == float.class || cls == Float.class) {
                        f.setFloat(this, savedInstanceState.getFloat(fieldName));
                    } else if (cls == double.class || cls == Double.class) {
                        f.setDouble(this, savedInstanceState.getDouble(fieldName));
                    } else if (String[].class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getStringArray(fieldName));
                    } else if (Parcelable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getParcelable(fieldName));
                    } else if (Bundle.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getBundle(fieldName));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.ichi2.anki.CardEditor.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(AnkiDroidApp.TAG, "CardEditor: onCreate");
    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    Intent intent = getIntent();//w ww.  j  a va2 s  .c  o  m
    if (savedInstanceState != null) {
        mCaller = savedInstanceState.getInt("caller");
        mAddNote = savedInstanceState.getBoolean("addFact");
    } else {
        mCaller = intent.getIntExtra(EXTRA_CALLER, CALLER_NOCALLER);
        if (mCaller == CALLER_NOCALLER) {
            String action = intent.getAction();
            if (action != null && (ACTION_CREATE_FLASHCARD.equals(action)
                    || ACTION_CREATE_FLASHCARD_SEND.equals(action))) {
                mCaller = CALLER_INDICLASH;
            }
        }
    }
    Log.i(AnkiDroidApp.TAG, "CardEditor: caller: " + mCaller);

    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());

    if (mCaller == CALLER_INDICLASH && preferences.getBoolean("intentAdditionInstantAdd", false)) {
        // save information without showing card editor
        fetchIntentInformation(intent);
        MetaDB.saveIntentInformation(CardEditor.this, Utils.joinFields(mSourceText));
        Themes.showThemedToast(CardEditor.this, getResources().getString(R.string.app_name) + ": "
                + getResources().getString(R.string.CardEditorLaterMessage), false);
        finish();
        return;
    }

    mCol = AnkiDroidApp.getCol();
    if (mCol == null) {
        reloadCollection(savedInstanceState);
        return;
    }

    registerExternalStorageListener();

    View mainView = getLayoutInflater().inflate(R.layout.card_editor, null);
    setContentView(mainView);
    Themes.setWallpaper(mainView);
    Themes.setContentStyle(mainView, Themes.CALLER_CARD_EDITOR);

    mFieldsLayoutContainer = (LinearLayout) findViewById(R.id.CardEditorEditFieldsLayout);

    mSave = (Button) findViewById(R.id.CardEditorSaveButton);
    mCancel = (Button) findViewById(R.id.CardEditorCancelButton);
    mLater = (Button) findViewById(R.id.CardEditorLaterButton);
    mDeckButton = (TextView) findViewById(R.id.CardEditorDeckText);
    mModelButton = (TextView) findViewById(R.id.CardEditorModelText);
    mTagsButton = (TextView) findViewById(R.id.CardEditorTagText);
    mSwapButton = (Button) findViewById(R.id.CardEditorSwapButton);
    mSwapButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            swapText(false);
        }
    });

    mAedictIntent = false;

    switch (mCaller) {
    case CALLER_NOCALLER:
        Log.i(AnkiDroidApp.TAG, "CardEditor: no caller could be identified, closing");
        finish();
        return;

    case CALLER_REVIEWER:
        mCurrentEditedCard = Reviewer.getEditorCard();
        if (mCurrentEditedCard == null) {
            finish();
            return;
        }
        mEditorNote = mCurrentEditedCard.note();
        mAddNote = false;
        break;

    case CALLER_STUDYOPTIONS:
    case CALLER_DECKPICKER:
        mAddNote = true;
        break;

    case CALLER_BIGWIDGET_EDIT:
        // Card widgetCard = AnkiDroidWidgetBig.getCard();
        // if (widgetCard == null) {
        // finish();
        // return;
        // }
        // mEditorNote = widgetCard.getFact();
        // mAddNote = false;
        break;

    case CALLER_BIGWIDGET_ADD:
        mAddNote = true;
        break;

    case CALLER_CARDBROWSER_EDIT:
        mCurrentEditedCard = CardBrowser.sCardBrowserCard;
        if (mCurrentEditedCard == null) {
            finish();
            return;
        }
        mEditorNote = mCurrentEditedCard.note();
        mAddNote = false;
        break;

    case CALLER_CARDBROWSER_ADD:
        mAddNote = true;
        break;

    case CALLER_CARDEDITOR:
        mAddNote = true;
        break;

    case CALLER_CARDEDITOR_INTENT_ADD:
        mAddNote = true;
        break;

    case CALLER_INDICLASH:
        fetchIntentInformation(intent);
        if (mSourceText == null) {
            finish();
            return;
        }
        if (mSourceText[0].equals("Aedict Notepad") && addFromAedict(mSourceText[1])) {
            finish();
            return;
        }
        mAddNote = true;
        break;
    }

    setNote(mEditorNote);

    if (mAddNote) {
        setTitle(R.string.cardeditor_title_add_note);
        // set information transferred by intent
        String contents = null;
        if (mSourceText != null) {
            if (mAedictIntent && (mEditFields.size() == 3) && mSourceText[1].contains("[")) {
                contents = mSourceText[1].replaceFirst("\\[", "\u001f");
                contents = contents.substring(0, contents.length() - 1);
            } else {
                mEditFields.get(0).setText(mSourceText[0]);
                mEditFields.get(1).setText(mSourceText[1]);
            }
        } else {
            contents = intent.getStringExtra(EXTRA_CONTENTS);
        }
        if (contents != null) {
            setEditFieldTexts(contents);
        }

        LinearLayout modelButton = ((LinearLayout) findViewById(R.id.CardEditorModelButton));
        modelButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(DIALOG_MODEL_SELECT);
            }
        });
        modelButton.setVisibility(View.VISIBLE);
        mSave.setText(getResources().getString(R.string.add));
        mCancel.setText(getResources().getString(R.string.close));

        mLater.setVisibility(View.VISIBLE);
        mLater.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = getFieldsText();
                if (content.length() > mEditFields.size() - 1) {
                    MetaDB.saveIntentInformation(CardEditor.this, content);
                    populateEditFields();
                    mSourceText = null;
                    Themes.showThemedToast(CardEditor.this,
                            getResources().getString(R.string.CardEditorLaterMessage), false);
                }
                if (mCaller == CALLER_INDICLASH || mCaller == CALLER_CARDEDITOR_INTENT_ADD) {
                    closeCardEditor();
                }
            }
        });
    } else {
        setTitle(R.string.cardeditor_title_edit_card);
        mSwapButton.setVisibility(View.GONE);
        mSwapButton = (Button) findViewById(R.id.CardEditorLaterButton);
        mSwapButton.setVisibility(View.VISIBLE);
        mSwapButton.setText(getResources().getString(R.string.fact_adder_swap));
        mSwapButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                swapText(false);
            }
        });
    }

    ((LinearLayout) findViewById(R.id.CardEditorDeckButton)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(DIALOG_DECK_SELECT);
        }
    });

    mPrefFixArabic = preferences.getBoolean("fixArabicText", false);
    // if Arabic reshaping is enabled, disable the Save button to avoid
    // saving the reshaped string to the deck
    if (mPrefFixArabic && !mAddNote) {
        mSave.setEnabled(false);
    }

    ((LinearLayout) findViewById(R.id.CardEditorTagButton)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_TAGS_SELECT);
        }
    });

    mSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (duplicateCheck(true)) {
                return;
            }
            boolean modified = false;
            for (FieldEditText f : mEditFields) {
                modified = modified | f.updateField();
            }
            if (mAddNote) {
                DeckTask.launchDeckTask(DeckTask.TASK_TYPE_ADD_FACT, mSaveFactHandler,
                        new DeckTask.TaskData(mEditorNote));
            } else {
                // added tag?
                for (String t : mCurrentTags) {
                    modified = modified || !mEditorNote.hasTag(t);
                }
                // removed tag?
                modified = modified || mEditorNote.getTags().size() > mCurrentTags.size();
                // changed did?
                boolean changedDid = mCurrentEditedCard.getDid() != mCurrentDid;
                modified = modified || changedDid;
                if (modified) {
                    mEditorNote.setTags(mCurrentTags);
                    // set did for card
                    if (changedDid) {
                        mCurrentEditedCard.setDid(mCurrentDid);
                    }
                    mChanged = true;
                }
                closeCardEditor();
                // if (mCaller == CALLER_BIGWIDGET_EDIT) {
                // // DeckTask.launchDeckTask(DeckTask.TASK_TYPE_UPDATE_FACT,
                // // mSaveFactHandler, new
                // // DeckTask.TaskData(Reviewer.UPDATE_CARD_SHOW_QUESTION,
                // // mDeck, AnkiDroidWidgetBig.getCard()));
                // } else if (!mCardReset) {
                // // Only send result to save if something was actually
                // // changed
                // if (mModified) {
                // setResult(RESULT_OK);
                // } else {
                // setResult(RESULT_CANCELED);
                // }
                // closeCardEditor();
                // }

            }
        }
    });

    mCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            closeCardEditor();
        }

    });
}

From source file:com.android.deskclock.AlarmClockFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    // Inflate the layout for this fragment
    final View v = inflater.inflate(R.layout.alarm_clock, container, false);

    long expandedId = INVALID_ID;
    long[] repeatCheckedIds = null;
    long[] selectedAlarms = null;
    Bundle previousDayMap = null;//w w  w  . j a  v a2 s .  c o  m
    if (savedState != null) {
        expandedId = savedState.getLong(KEY_EXPANDED_ID);
        repeatCheckedIds = savedState.getLongArray(KEY_REPEAT_CHECKED_IDS);
        mRingtoneTitleCache = savedState.getBundle(KEY_RINGTONE_TITLE_CACHE);
        mDeletedAlarm = savedState.getParcelable(KEY_DELETED_ALARM);
        mUndoShowing = savedState.getBoolean(KEY_UNDO_SHOWING);
        selectedAlarms = savedState.getLongArray(KEY_SELECTED_ALARMS);
        previousDayMap = savedState.getBundle(KEY_PREVIOUS_DAY_MAP);
        mSelectedAlarm = savedState.getParcelable(KEY_SELECTED_ALARM);
    }

    mExpandInterpolator = new DecelerateInterpolator(EXPAND_DECELERATION);
    mCollapseInterpolator = new DecelerateInterpolator(COLLAPSE_DECELERATION);

    if (USE_TRANSITION_FRAMEWORK) {
        mAddRemoveTransition = new AutoTransition();
        mAddRemoveTransition.setDuration(ANIMATION_DURATION);

        /// M: Scrap the views in ListView and request layout again, then alarm item will be
        /// attached correctly. This is to avoid the case when some items are not correctly
        ///  attached after animation end  @{
        mAddRemoveTransition.addListener(new Transition.TransitionListenerAdapter() {
            @Override
            public void onTransitionEnd(Transition transition) {
                mAlarmsList.clearScrapViewsIfNeeded();
            }
        });
        /// @}

        mRepeatTransition = new AutoTransition();
        mRepeatTransition.setDuration(ANIMATION_DURATION / 2);
        mRepeatTransition.setInterpolator(new AccelerateDecelerateInterpolator());

        mEmptyViewTransition = new TransitionSet().setOrdering(TransitionSet.ORDERING_SEQUENTIAL)
                .addTransition(new Fade(Fade.OUT)).addTransition(new Fade(Fade.IN))
                .setDuration(ANIMATION_DURATION);
    }

    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    View menuButton = v.findViewById(R.id.menu_button);
    if (menuButton != null) {
        if (isLandscape) {
            menuButton.setVisibility(View.GONE);
        } else {
            menuButton.setVisibility(View.VISIBLE);
            setupFakeOverflowMenuButton(menuButton);
        }
    }

    mEmptyView = v.findViewById(R.id.alarms_empty_view);

    mMainLayout = (FrameLayout) v.findViewById(R.id.main);
    mAlarmsList = (ListView) v.findViewById(R.id.alarms_list);

    mUndoBar = (ActionableToastBar) v.findViewById(R.id.undo_bar);
    mUndoFrame = v.findViewById(R.id.undo_frame);
    mUndoFrame.setOnTouchListener(this);

    mFooterView = v.findViewById(R.id.alarms_footer_view);
    mFooterView.setOnTouchListener(this);

    mAdapter = new AlarmItemAdapter(getActivity(), expandedId, repeatCheckedIds, selectedAlarms, previousDayMap,
            mAlarmsList);
    mAdapter.registerDataSetObserver(new DataSetObserver() {

        private int prevAdapterCount = -1;

        @Override
        public void onChanged() {

            final int count = mAdapter.getCount();
            if (mDeletedAlarm != null && prevAdapterCount > count) {
                showUndoBar();
            }

            if (USE_TRANSITION_FRAMEWORK && ((count == 0 && prevAdapterCount > 0) || /* should fade  in */
            (count > 0 && prevAdapterCount == 0) /* should fade out */)) {
                TransitionManager.beginDelayedTransition(mMainLayout, mEmptyViewTransition);
            }
            mEmptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE);

            // Cache this adapter's count for when the adapter changes.
            prevAdapterCount = count;
            super.onChanged();
        }
    });

    if (mRingtoneTitleCache == null) {
        mRingtoneTitleCache = new Bundle();
    }

    mAlarmsList.setAdapter(mAdapter);
    mAlarmsList.setVerticalScrollBarEnabled(true);
    mAlarmsList.setOnCreateContextMenuListener(this);

    if (mUndoShowing) {
        showUndoBar();
    }
    return v;
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    listViewSavedTopIndex = (savedInstanceState == null) ? -1 : savedInstanceState.getInt(LIST_TOP_INDEX);
    listViewSavedTopOffset = (savedInstanceState == null) ? 0 : savedInstanceState.getInt(LIST_TOP_OFFSET);
    composingViewSavedState = (savedInstanceState == null) ? null
            : savedInstanceState.getParcelable(COMPOSING_EDITTEXT_STATE);
    pendingWhoCardName = (savedInstanceState == null) ? null : savedInstanceState.getParcelable(WHO_CARD_NAME);
    pendingWhoCardEmail = (savedInstanceState == null) ? null
            : savedInstanceState.getParcelable(WHO_CARD_EMAIL);
    pendingWhoCardAvatarFile = (savedInstanceState == null) ? null
            : savedInstanceState.getString(WHO_CARD_AVATAR_FILE);
    pendingWhoCardMode = savedInstanceState != null && savedInstanceState.getBoolean(WHO_CARD_MODE);
    return inflater.inflate(R.layout.apptentive_message_center, container, false);
}

From source file:cn.suishen.email.activity.MessageViewFragmentBase.java

private void restoreInstanceState(Bundle state) {
    if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
        Log.d(Logging.LOG_TAG, this + " restoreInstanceState");
    }//from   ww  w.  j  a v  a  2s.c  o  m
    // At this point (in onCreate) no tabs are visible (because we don't know if the message has
    // an attachment or invite before loading it).  We just remember the tab here.
    // We'll make it current when the tab first becomes visible in updateTabs().
    mRestoredTab = state.getInt(BUNDLE_KEY_CURRENT_TAB);
    mRestoredPictureLoaded = state.getBoolean(BUNDLE_KEY_PICTURE_LOADED);
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public void onCreate(Bundle state) {
    ThemeHelper.setTheme(this, R.style.Library);
    super.onCreate(state);

    if (state == null) {
        checkForLaunch(getIntent());// w ww .  j av a2  s  . co m
    }

    setContentView(R.layout.library_content);

    mLimiterScroller = (HorizontalScrollView) findViewById(R.id.limiter_scroller);
    mLimiterViews = (ViewGroup) findViewById(R.id.limiter_layout);

    LibraryPagerAdapter pagerAdapter = new LibraryPagerAdapter(this, mLooper);
    mPagerAdapter = pagerAdapter;

    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(pagerAdapter);
    mViewPager = pager;

    SharedPreferences settings = PlaybackService.getSettings(this);

    mBottomBarControls = (BottomBarControls) findViewById(R.id.bottombar_controls);
    mBottomBarControls.setOnClickListener(this);
    mBottomBarControls.setOnQueryTextListener(this);
    mBottomBarControls.enableOptionsMenu(this);

    if (PermissionRequestActivity.havePermissions(this) == false) {
        PermissionRequestActivity.showWarning(this, getIntent());
    }

    mVanillaTabLayout = (VanillaTabLayout) findViewById(R.id.sliding_tabs);
    mVanillaTabLayout.setOnPageChangeListener(pagerAdapter);

    loadTabOrder();
    int page = settings.getInt(PrefKeys.LIBRARY_PAGE, PrefDefaults.LIBRARY_PAGE);
    if (page != 0) {
        pager.setCurrentItem(page);
    }

    loadLimiterIntent(getIntent());
    bindControlButtons();

    if (state != null && state.getBoolean("launch_search")) {
        mBottomBarControls.showSearch(true);
    }
}

From source file:at.jclehner.rxdroid.NotificationReceiver.java

private void scheduleNextBeginOrEndAlarm(DoseTimeInfo dtInfo, boolean scheduleEnd) {
    final int doseTime = scheduleEnd ? dtInfo.activeDoseTime() : dtInfo.nextDoseTime();
    final Calendar time = dtInfo.currentTime();
    final Date doseTimeDate = scheduleEnd ? dtInfo.activeDate() : dtInfo.nextDoseTimeDate();

    final Bundle alarmExtras = new Bundle();
    alarmExtras.putSerializable(EXTRA_DATE, doseTimeDate);
    alarmExtras.putInt(EXTRA_DOSE_TIME, doseTime);
    alarmExtras.putBoolean(EXTRA_IS_DOSE_TIME_END, scheduleEnd);
    alarmExtras.putBoolean(EXTRA_SILENT, false);

    long offset;//from ww  w.jav  a 2 s .c  o  m

    if (scheduleEnd)
        offset = Settings.getMillisUntilDoseTimeEnd(time, doseTime);
    else
        offset = Settings.getMillisUntilDoseTimeBegin(time, doseTime);

    long triggerAtMillis = time.getTimeInMillis() + offset;

    final long alarmRepeatMins = Settings.getStringAsInt(Settings.Keys.ALARM_REPEAT, 0);
    final long alarmRepeatMillis = alarmRepeatMins == -1 ? 10000 : alarmRepeatMins * 60000;

    if (alarmRepeatMillis > 0) {
        alarmExtras.putBoolean(EXTRA_FORCE_UPDATE, true);

        final long base = dtInfo.activeDate().getTime();
        int i = 0;

        while (base + (i * alarmRepeatMillis) < time.getTimeInMillis())
            ++i;

        // We must tell the receiver whether the alarm is an actual dose time's
        // end or begin, or merely a repetition.

        final long triggerAtMillisWithRepeatedAlarm = base + i * alarmRepeatMillis;
        if (triggerAtMillisWithRepeatedAlarm < triggerAtMillis) {
            triggerAtMillis = triggerAtMillisWithRepeatedAlarm;
            alarmExtras.putBoolean(EXTRA_IS_ALARM_REPETITION, true);
        }

        //triggerAtMillis = base + (i * alarmRepeatMillis);
    }

    final long triggerDiffFromNow = triggerAtMillis - System.currentTimeMillis();
    if (triggerDiffFromNow < 0) {
        if (triggerDiffFromNow < -50000)
            Log.w(TAG, "Alarm time is in the past by less than 5 seconds.");
        else {
            Log.w(TAG, "Alarm time is in the past. Ignoring...");
            return;
        }
    }

    if (alarmExtras.getBoolean(EXTRA_IS_ALARM_REPETITION))
        Log.i(TAG, "Scheduling next alarm for " + DateTime.toString(triggerAtMillis));
    else {
        Log.i(TAG, "Scheduling " + (scheduleEnd ? "end" : "begin") + " of doseTime " + doseTime + " on date "
                + DateTime.toDateString(doseTimeDate) + " for " + DateTime.toString(triggerAtMillis));
    }

    Log.i(TAG, "Alarm will go off in " + Util.millis(triggerDiffFromNow));

    mAlarmMgr.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, createOperation(alarmExtras));
}

From source file:es.uniovi.imovil.fcrtrainer.TwosComplementExerciseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView;/*from w w  w  .j a  v  a 2 s .co m*/
    rootView = inflater.inflate(R.layout.fragment_twos_complement, container, false);

    rel_cards = (RelativeLayout) rootView.findViewById(R.id.rel_cards);
    but_check = (Button) rootView.findViewById(R.id.bCheck);
    but_solution = (Button) rootView.findViewById(R.id.bSeesolution);
    but_setMode = (Button) rootView.findViewById(R.id.bSetconversion);
    edi_answer = (EditText) rootView.findViewById(R.id.etAnswer);
    tex_tittle = (TextView) rootView.findViewById(R.id.txTittle);
    tex_numberToConvert = (TextView) rootView.findViewById(R.id.txNumbertoconvert);

    but_check.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (GameMode == false) {
                if (but_check.getText().equals(getResources().getString((R.string.next_numb)))) {
                    edi_answer.setText("");
                    but_check.setText(getResources().getString(R.string.check));
                    generateRand(modeToDecimal);
                } else {
                    checkAnswer();
                }
            } else {
                checkAnswer();
            }
        }
    });

    but_solution.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            seeSolution();
        }
    });

    but_setMode.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            modeToDecimal = !modeToDecimal;
            generateRand(modeToDecimal);
            edi_answer.setText("");
        }
    });

    Log.i(getClass().getSimpleName(), "onViewCreated");

    if (savedInstanceState != null) {
        Log.i(getClass().getSimpleName(), "Inside savedInstanceState");
        modeToDecimal = savedInstanceState.getBoolean("modeToDecimal");
        numbToConvert = savedInstanceState.getString("numbToConvert");

        updateUI();
    } else
        generateRand(modeToDecimal);

    return rootView;
}