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.android.dialer.voicemail.VoicemailPlaybackPresenter.java

/**
 * Update variables which are activity-dependent or state-dependent.
 *//*from  ww w.j  av  a  2s  .  c o  m*/
protected void init(Activity activity, Bundle savedInstanceState) {
    mActivity = activity;
    mContext = activity;

    mInitialOrientation = mContext.getResources().getConfiguration().orientation;
    mActivity.setVolumeControlStream(VoicemailAudioManager.PLAYBACK_STREAM);

    if (savedInstanceState != null) {
        // Restores playback state when activity is recreated, such as after rotation.
        mVoicemailUri = (Uri) savedInstanceState.getParcelable(VOICEMAIL_URI_KEY);
        mIsPrepared = savedInstanceState.getBoolean(IS_PREPARED_KEY);
        mPosition = savedInstanceState.getInt(CLIP_POSITION_KEY, 0);
        mIsPlaying = savedInstanceState.getBoolean(IS_PLAYING_STATE_KEY, false);
        mIsSpeakerphoneOn = savedInstanceState.getBoolean(IS_SPEAKERPHONE_ON_KEY, false);
    }

    if (mMediaPlayer == null) {
        mIsPrepared = false;
        mIsPlaying = false;
    }
}

From source file:com.synox.android.ui.activity.FileActivity.java

/**
 * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
 * the {@link FileActivity}./*w  w  w  . ja v a2 s  . co  m*/
 * <p/>
 * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
 * is requested to create a new one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper
                .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }

    AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager
    // or database

    setAccount(account, savedInstanceState != null);

    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE);

    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection,
                Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }

}

From source file:com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setImmersive();//from  www.  j a v  a 2 s. c o m
    mCastConsumer = new MyCastConsumer();
    Bundle bundle = getArguments();
    if (bundle == null) {
        return;
    }
    Bundle extras = bundle.getBundle(EXTRAS);
    Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA);

    // Retain this fragment across configuration changes.
    setRetainInstance(true);
    mCastManager.addTracksSelectedListener(this);
    boolean explicitStartActivity = mCastManager.getPreferenceAccessor()
            .getBooleanFromPreference(VideoCastManager.PREFS_KEY_START_ACTIVITY, false);
    if (explicitStartActivity) {
        mIsFresh = true;
    }
    mCastManager.getPreferenceAccessor().saveBooleanToPreference(VideoCastManager.PREFS_KEY_START_ACTIVITY,
            false);
    if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) {
        if (mIsFresh) {
            mOverallState = OverallState.AUTHORIZING;
            mMediaAuthService = mCastManager.getMediaAuthService();
            handleMediaAuthTask(mMediaAuthService);
            showImage(Utils.getImageUri(mMediaAuthService.getMediaInfo(), 1));
        }
    } else if (mediaWrapper != null) {
        mOverallState = OverallState.PLAYBACK;
        boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START);
        String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA);
        int nextPreviousVisibilityPolicy = extras.getInt(VideoCastManager.EXTRA_NEXT_PREVIOUS_VISIBILITY_POLICY,
                VideoCastController.NEXT_PREV_VISIBILITY_POLICY_DISABLED);
        mCastController.setNextPreviousVisibilityPolicy(nextPreviousVisibilityPolicy);
        JSONObject customData = null;
        if (!TextUtils.isEmpty(customDataStr)) {
            try {
                customData = new JSONObject(customDataStr);
            } catch (JSONException e) {
                LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e);
            }
        }
        MediaInfo info = Utils.bundleToMediaInfo(mediaWrapper);
        int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0);
        onReady(info, shouldStartPlayback && explicitStartActivity, startPoint, customData);
    }
}

From source file:com.android.calendar.event.EditEventFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(BUNDLE_KEY_MODEL)) {
            mRestoreModel = (CalendarEventModel) savedInstanceState.getSerializable(BUNDLE_KEY_MODEL);
        }// ww  w .j a  v  a  2  s.  co m
        if (savedInstanceState.containsKey(BUNDLE_KEY_EDIT_STATE)) {
            mModification = savedInstanceState.getInt(BUNDLE_KEY_EDIT_STATE);
        }
        if (savedInstanceState.containsKey(BUNDLE_KEY_EDIT_ON_LAUNCH)) {
            mShowModifyDialogOnLaunch = savedInstanceState.getBoolean(BUNDLE_KEY_EDIT_ON_LAUNCH);
        }
        if (savedInstanceState.containsKey(BUNDLE_KEY_EVENT)) {
            mEventBundle = (EventBundle) savedInstanceState.getSerializable(BUNDLE_KEY_EVENT);
        }
        if (savedInstanceState.containsKey(BUNDLE_KEY_READ_ONLY)) {
            mIsReadOnly = savedInstanceState.getBoolean(BUNDLE_KEY_READ_ONLY);
        }
        if (savedInstanceState.containsKey("EditEventView_timebuttonclicked")) {
            mTimeSelectedWasStartTime = savedInstanceState.getBoolean("EditEventView_timebuttonclicked");
        }
        if (savedInstanceState.containsKey(BUNDLE_KEY_DATE_BUTTON_CLICKED)) {
            mDateSelectedWasStartDate = savedInstanceState.getBoolean(BUNDLE_KEY_DATE_BUTTON_CLICKED);
        }
        if (savedInstanceState.containsKey(BUNDLE_KEY_SHOW_COLOR_PALETTE)) {
            mShowColorPalette = savedInstanceState.getBoolean(BUNDLE_KEY_SHOW_COLOR_PALETTE);
        }

    }
}

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

public boolean init() {
    boolean bRet = true;
    codePointStore.init();//from w  w w .ja  v a2s . c om
    /* If Message Center feature has never been used before, don't initialize message polling thread.
     * Message Center feature will be seen as used, if one of the following conditions has been met:
     * 1. Message Center has been opened for the first time
     * 2. The first Push is received which would open Message Center
     * 3. An unreadMessageCountListener() is set up
     */
    boolean featureEverUsed = prefs.getBoolean(Constants.PREF_KEY_MESSAGE_CENTER_FEATURE_USED, false);
    if (featureEverUsed) {
        messageManager.init();
    }
    conversationToken = prefs.getString(Constants.PREF_KEY_CONVERSATION_TOKEN, null);
    conversationId = prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, null);
    personId = prefs.getString(Constants.PREF_KEY_PERSON_ID, null);
    apptentiveToolbarTheme = appContext.getResources().newTheme();

    boolean apptentiveDebug = false;
    String logLevelOverride = null;
    String manifestApiKey = null;
    try {
        appPackageName = appContext.getPackageName();
        PackageManager packageManager = appContext.getPackageManager();
        PackageInfo packageInfo = packageManager.getPackageInfo(appPackageName,
                PackageManager.GET_META_DATA | PackageManager.GET_RECEIVERS);
        ApplicationInfo ai = packageInfo.applicationInfo;

        Bundle metaData = ai.metaData;
        if (metaData != null) {
            manifestApiKey = Util.trim(metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_API_KEY));
            logLevelOverride = Util.trim(metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_LOG_LEVEL));
            apptentiveDebug = metaData.getBoolean(Constants.MANIFEST_KEY_APPTENTIVE_DEBUG);
        }

        // Used for application theme inheritance if the theme is an AppCompat theme.
        setApplicationDefaultTheme(ai.theme);

        AppRelease appRelease = AppRelease.generateCurrentAppRelease(appContext);

        isAppDebuggable = appRelease.getDebug();
        currentVersionCode = appRelease.getVersionCode();
        currentVersionName = appRelease.getVersionName();

        VersionHistoryEntry lastVersionEntrySeen = VersionHistoryStore.getLastVersionSeen();

        if (lastVersionEntrySeen == null) {
            onVersionChanged(null, currentVersionCode, null, currentVersionName, appRelease);
        } else {
            int lastSeenVersionCode = lastVersionEntrySeen.getVersionCode();
            Apptentive.Version lastSeenVersionNameVersion = new Apptentive.Version();
            lastSeenVersionNameVersion.setVersion(lastVersionEntrySeen.getVersionName());
            if (!(currentVersionCode == lastSeenVersionCode)
                    || !currentVersionName.equals(lastSeenVersionNameVersion.getVersion())) {
                onVersionChanged(lastVersionEntrySeen.getVersionCode(), currentVersionCode,
                        lastVersionEntrySeen.getVersionName(), currentVersionName, appRelease);
            }
        }
        defaultAppDisplayName = packageManager
                .getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0)).toString();

        // Prevent delayed run-time exception if the app upgrades from pre-2.0 and doesn't remove NetworkStateReceiver from manifest
        ActivityInfo[] registered = packageInfo.receivers;
        if (registered != null) {
            for (ActivityInfo activityInfo : registered) {
                // Throw assertion error when relict class found in manifest.
                if (activityInfo.name.equals("com.apptentive.android.sdk.comm.NetworkStateReceiver")) {
                    throw new AssertionError(
                            "NetworkStateReceiver has been removed from Apptentive SDK, please make sure it's also removed from manifest file");
                }
            }
        }

    } catch (Exception e) {
        ApptentiveLog.e("Unexpected error while reading application or package info.", e);
        bRet = false;
    }

    // Set debuggable and appropriate log level.
    if (apptentiveDebug) {
        ApptentiveLog.i("Apptentive debug logging set to VERBOSE.");
        setMinimumLogLevel(ApptentiveLog.Level.VERBOSE);
    } else if (logLevelOverride != null) {
        ApptentiveLog.i("Overriding log level: %s", logLevelOverride);
        setMinimumLogLevel(ApptentiveLog.Level.parse(logLevelOverride));
    } else {
        if (isAppDebuggable) {
            setMinimumLogLevel(ApptentiveLog.Level.VERBOSE);
        }
    }
    ApptentiveLog.i("Debug mode enabled? %b", isAppDebuggable);

    String lastSeenSdkVersion = prefs.getString(Constants.PREF_KEY_LAST_SEEN_SDK_VERSION, "");
    if (!lastSeenSdkVersion.equals(Constants.APPTENTIVE_SDK_VERSION)) {
        onSdkVersionChanged(appContext, lastSeenSdkVersion, Constants.APPTENTIVE_SDK_VERSION);
    }

    // The apiKey can be passed in programmatically, or we can fallback to checking in the manifest.
    if (TextUtils.isEmpty(apiKey) && !TextUtils.isEmpty(manifestApiKey)) {
        apiKey = manifestApiKey;
    }
    if (TextUtils.isEmpty(apiKey) || apiKey.contains(Constants.EXAMPLE_API_KEY_VALUE)) {
        String errorMessage = "The Apptentive API Key is not defined. You may provide your Apptentive API Key in Apptentive.register(), or in as meta-data in your AndroidManifest.xml.\n"
                + "<meta-data android:name=\"apptentive_api_key\"\n"
                + "           android:value=\"@string/your_apptentive_api_key\"/>";
        if (isAppDebuggable) {
            throw new RuntimeException(errorMessage);
        } else {
            ApptentiveLog.e(errorMessage);
        }
    } else {
        ApptentiveLog.d("Using cached Apptentive API Key");
    }
    ApptentiveLog.d("Apptentive API Key: %s", apiKey);

    // Grab app info we need to access later on.
    androidId = Settings.Secure.getString(appContext.getContentResolver(),
            android.provider.Settings.Secure.ANDROID_ID);
    ApptentiveLog.d("Android ID: ", androidId);
    ApptentiveLog.d("Default Locale: %s", Locale.getDefault().toString());
    ApptentiveLog.d("Conversation id: %s", prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, "null"));
    return bRet;
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

/**
 * EventBus listener for Event Bundle//from  w w  w .ja  v  a2s  . c o  m
 * @param {Bundle} event
 */
@Subscribe
public void onEventMainThread(Bundle event) {
    if (event.containsKey("request")) {
        return;
    }
    String name = event.getString("name");

    if (BackgroundGeolocationService.ACTION_START.equalsIgnoreCase(name)) {
        onStarted(event);
    } else if (BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE.equalsIgnoreCase(name)) {
        boolean nowMoving = event.getBoolean("isMoving");
        try {
            JSONObject locationData = new JSONObject(event.getString("location"));
            onMotionChange(nowMoving, locationData);
        } catch (JSONException e) {
            Log.e(TAG, "Error decoding JSON");
            e.printStackTrace();
        }
    } else if (BackgroundGeolocationService.ACTION_GET_LOCATIONS.equalsIgnoreCase(name)) {
        try {
            JSONObject params = new JSONObject();
            params.put("locations", new JSONArray(event.getString("data")));
            params.put("taskId", "android-bg-task-id");
            PluginResult result = new PluginResult(PluginResult.Status.OK, params);
            getLocationsCallback.sendPluginResult(result);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            PluginResult result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
            getLocationsCallback.sendPluginResult(result);
        }
    } else if (BackgroundGeolocationService.ACTION_SYNC.equalsIgnoreCase(name)) {
        Boolean success = event.getBoolean("success");
        if (success) {
            try {
                JSONObject params = new JSONObject();
                params.put("locations", new JSONArray(event.getString("data")));
                params.put("taskId", "android-bg-task-id");
                PluginResult result = new PluginResult(PluginResult.Status.OK, params);
                syncCallback.sendPluginResult(result);
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            PluginResult result = new PluginResult(PluginResult.Status.IO_EXCEPTION,
                    event.getString("message"));
            syncCallback.sendPluginResult(result);
        }
    } else if (BackgroundGeolocationService.ACTION_RESET_ODOMETER.equalsIgnoreCase(name)) {
        this.onResetOdometer(event);
    } else if (BackgroundGeolocationService.ACTION_CHANGE_PACE.equalsIgnoreCase(name)) {
        this.onChangePace(event);
    } else if (BackgroundGeolocationService.ACTION_GET_GEOFENCES.equalsIgnoreCase(name)) {
        try {
            JSONArray json = new JSONArray(event.getString("data"));
            PluginResult result = new PluginResult(PluginResult.Status.OK, json);
            getGeofencesCallback.sendPluginResult(result);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            PluginResult result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
            getGeofencesCallback.sendPluginResult(result);
        }
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GOOGLE_PLAY_SERVICES_CONNECT_ERROR)) {
        GoogleApiAvailability.getInstance()
                .getErrorDialog(this.cordova.getActivity(), event.getInt("errorCode"), 1001).show();
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_LOCATION_ERROR)) {
        this.onLocationError(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_ADD_GEOFENCE)) {
        this.onAddGeofence(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_ADD_GEOFENCES)) {
        this.onAddGeofence(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_HTTP_RESPONSE)) {
        this.onHttpResponse(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION)) {
        this.onLocationError(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_INSERT_LOCATION)) {
        this.onInsertLocation(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GET_COUNT)) {
        this.onGetCount(event);
    }
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/**
 * Constructor//from w  ww.  j  a v a2  s .  c o  m
 */
@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    acList = new ArrayList<InitDestFrame>();
    r = getResources();

    //Calls the initAutoComplete method, adding the autocomplete listeners to acTo and acFrom
    initAutocomplete();

    //Calls the initAddDestButton method, adding the driving through button
    initAddDestButton();

    //Sets hasDrawn to false
    hasDrawn = false;

    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        inEditMode = extras.getBoolean("editMode");
        positionOfRoute = extras.getInt("routePosition");
    }

    //Hides the checkbox
    chk_saveRoute = (CheckBox) findViewById(R.id.checkBoxSave);
    chk_saveRoute.setVisibility(8);

    //Initialises the draw/next button
    final Button button = ((Button) findViewById(R.id.btnChooseRoute));

    //Adjustments to the gui if in editmode
    if (inEditMode) {
        chk_saveRoute.setVisibility(View.GONE);
        button.setText("Update the route");
        button.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
        fillFieldsInEdit();
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                createInputDialog("Route", "Insert name of Route", false);
            }
        });
    } else {
        button.setText("Show on map");
        button.setEnabled(false);
    }

    //Initialises the textviews and the clear buttons
    final AutoCompleteTextView acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom);
    final AutoCompleteTextView acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo);
    ImageView bClearFrom = ((ImageView) findViewById(R.id.etGoingFromClearIcon));
    ImageView bClearTo = ((ImageView) findViewById(R.id.etGoingToClearIcon));

    //If map is drawn fill the textviews
    if (selectedRoute.getMapPoints().size() != 0) {
        fillFieldsOnClick();
    }

    /**
     * onClickListener on the clearButton on the acFrom field {@link OnClickListener()}
     */
    //Adds onClickListener to the clearbutton on the acFrom field
    bClearFrom.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            acFrom.setText("");
            button.setEnabled(false);
            button.setText("Show on Map");

        }

    });

    /**
     * onClickListener on the clearButton on the acTo field {@link OnClickListener}
     */
    //Adds onClickListener to the clearbutton on the acTo field
    bClearTo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            acTo.setText("");
            button.setEnabled(false);
            button.setText("Show on Map");

        }

    });

    /**
     * TextWatcher to the acFrom {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()}
     */
    //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality
    acFrom.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            hasDrawn = false;
            if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) {
                button.setEnabled(true);
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) {
                button.setEnabled(true);
                button.setText("Show on Map");

            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                button.setEnabled(true);
                button.setText("Show on map");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
                button.setText("Show on map");
                button.setEnabled(false);
            } else if (inEditMode) {

            } else {
                button.setText("Show on map");
                button.setEnabled(false);
            }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

    });

    /**
     * TextWatcher to the acTo {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()}
     */
    //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality
    acTo.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            hasDrawn = false;
            if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) {
                button.setEnabled(true);
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == false) {
                button.setEnabled(true);
                button.setText("Show on Map");

            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                button.setEnabled(true);
                button.setText("Show on map");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
                button.setText("Show on map");
                button.setEnabled(false);
            } else if (inEditMode) {

            } else {
                button.setText("Show on map");
                button.setEnabled(false);
            }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

    });

    /**
     * onClickListener on the button(draw/next) {@link OnClickListener}
     */
    //adds the onclickListener to the draw/next button
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

            if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) {
                button.setText("Next");
                createOneTimeJourney();

            } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) {
                mapView.getOverlays().clear();
                createMap();
                button.setText("Next");
            } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) {
                mapView.getOverlays().clear();
                createMap();
                button.setText("Next");

            } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) {
            } else if (inEditMode) {
                createInputDialog("Route", "Insert name of Route", false);
                button.setText("Next");

            } else {

            }
        }
    });

}

From source file:com.wirelessmoves.cl.MainActivity.java

@SuppressWarnings("deprecation")
@Override//from   www .ja v  a2 s  .  com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /* If saved variable state exists from last run, recover it */
    if (savedInstanceState != null) {
        NumberOfSignalStrengthUpdates = savedInstanceState.getLong("NumberOfSignalStrengthUpdates");

        LastCellId = savedInstanceState.getLong("LastCellId");
        NumberOfCellChanges = savedInstanceState.getLong("NumberOfCellChanges");

        LastLacId = savedInstanceState.getLong("LastLacId");
        NumberOfLacChanges = savedInstanceState.getLong("NumberOfLacChanges");

        PreviousCells = savedInstanceState.getLongArray("PreviousCells");
        PreviousCellsIndex = savedInstanceState.getInt("PreviousCellsIndex");
        NumberOfUniqueCellChanges = savedInstanceState.getLong("NumberOfUniqueCellChanges");

        outputDebugInfo = savedInstanceState.getBoolean("outputDebugInfo");

        CurrentLocationLong = savedInstanceState.getDouble("CurrentLocationLong");
        CurrentLocationLat = savedInstanceState.getDouble("CurrentLocationLat");

        /* attempt to restore the previous gps location information object */
        PrevLocation = (Location) getLastNonConfigurationInstance();

    } else {
        /* Initialize PreviousCells Array to defined values */
        for (int x = 0; x < PreviousCells.length; x++)
            PreviousCells[x] = 0;
    }

    /* Get a handle to the telephony manager service */
    /* A listener will be installed in the object from the onResume() method */
    MyListener = new MyPhoneStateListener();
    Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    /* get a handle to the power manager and set a wake lock so the screen saver
     * is not activated after a timeout */
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");

    /* Get a handle to the location system for getting GPS information */
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    gpsListener = new myLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);

}

From source file:com.buddi.client.dfu.DfuActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feature_dfu);
    isBLESupported();/*from ww  w.  j  ava 2s. c o m*/
    if (!isBLEEnabled()) {
        showBLEDialog();
    }
    setGUI();

    ensureSamplesExist();

    // restore saved state
    mFileType = DfuService.TYPE_APPLICATION; // Default
    if (savedInstanceState != null) {
        mFileType = savedInstanceState.getInt(DATA_FILE_TYPE);
        mFileTypeTmp = savedInstanceState.getInt(DATA_FILE_TYPE_TMP);
        mFilePath = savedInstanceState.getString(DATA_FILE_PATH);
        mFileStreamUri = savedInstanceState.getParcelable(DATA_FILE_STREAM);
        mSelectedDevice = savedInstanceState.getParcelable(DATA_DEVICE);
        mStatusOk = mStatusOk || savedInstanceState.getBoolean(DATA_STATUS);
        mUploadButton.setEnabled(mSelectedDevice != null && mStatusOk);
    }
    //mSelectedDevice= getIntent().getParcelableExtra(ModuleActivity.EXTRA_BLE_DEVICE);
}

From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java

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

    if (savedInstanceState == null) {
        final DialogPreference preference = getPreference();
        mDialogTitle = preference.getDialogTitle();
        mDialogMessage = preference.getDialogMessage();

        if (preference instanceof ListPreference) {
            mMulti = false;//w w  w  .  j a  v a 2  s  . c om
            mEntries = ((ListPreference) preference).getEntries();
            mEntryValues = ((ListPreference) preference).getEntryValues();
            mInitialSelection = ((ListPreference) preference).getValue();
        } else if (preference instanceof MultiSelectListPreference) {
            mMulti = true;
            mEntries = ((MultiSelectListPreference) preference).getEntries();
            mEntryValues = ((MultiSelectListPreference) preference).getEntryValues();
            mInitialSelections = ((MultiSelectListPreference) preference).getValues();
        } else {
            throw new IllegalArgumentException(
                    "Preference must be a ListPreference or " + "MultiSelectListPreference");
        }
    } else {
        mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE);
        mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE);
        mMulti = savedInstanceState.getBoolean(SAVE_STATE_IS_MULTI);
        mEntries = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRIES);
        mEntryValues = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRY_VALUES);
        if (mMulti) {
            final String[] initialSelections = savedInstanceState.getStringArray(SAVE_STATE_INITIAL_SELECTIONS);
            mInitialSelections = new ArraySet<>(initialSelections != null ? initialSelections.length : 0);
            if (initialSelections != null) {
                Collections.addAll(mInitialSelections, initialSelections);
            }
        } else {
            mInitialSelection = savedInstanceState.getString(SAVE_STATE_INITIAL_SELECTION);
        }
    }
}