Example usage for android.content Intent getBooleanExtra

List of usage examples for android.content Intent getBooleanExtra

Introduction

In this page you can find the example usage for android.content Intent getBooleanExtra.

Prototype

public boolean getBooleanExtra(String name, boolean defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:br.com.bioscada.apps.biotracks.services.TrackRecordingService.java

/**
 * Handles start command.//from   ww  w  .j  ava  2  s.  c o  m
 *
 * @param intent  the intent
 * @param startId the start id
 */
private void handleStartCommand(Intent intent, int startId) {
    // Check if the service is called to resume track (from phone reboot)
    if (intent != null && intent.getBooleanExtra(RESUME_TRACK_EXTRA_NAME, false)) {
        if (!shouldResumeTrack()) {
            Log.i(TAG, "Stop resume track.");
            updateRecordingState(PreferencesUtils.RECORDING_TRACK_ID_DEFAULT, true);
            stopSelfResult(startId);
            return;
        }
    }
}

From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java

@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    if (currentFragment != null && intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) {
        if (slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
            closeNowPlaying();//from  w  w w  . j  a  va 2 s.co m
        }

        if (currentFragment instanceof SearchFragment) {
            String query = intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY);
            boolean autoplay = intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
            String artist = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ARTIST);
            String album = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ALBUM);
            String title = intent.getStringExtra(MediaStore.EXTRA_MEDIA_TITLE);

            if (query != null) {
                ((SearchFragment) currentFragment).search(query, autoplay, artist, album, title);
            }
            getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_QUERY);
        } else {
            setIntent(intent);

            SearchFragment fragment = new SearchFragment();
            replaceFragment(fragment, fragment.getSupportTag());
        }
    } else if (intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, false)) {
        if (slideUpPanel.getPanelState() != SlidingUpPanelLayout.PanelState.EXPANDED) {
            openNowPlaying();
        }
    } else {
        if (slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
            closeNowPlaying();
        }
        setIntent(intent);
    }
    if (drawer != null) {
        drawer.closeDrawers();
    }
}

From source file:com.hangulo.powercontact.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // supprot two pane mode
    mTwoPane = getResources().getBoolean(R.bool.two_pane); // two_pane mode check

    // Analytics tracking start
    ((AnalyticsApplication) getApplication()).startTracking();

    // use toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
    setSupportActionBar(toolbar); // ?  

    // setting left drawer
    setleftMenuDrawer(toolbar);//w  w w . j a va  2s .c  o m

    mTopFrameLayout = (FrameLayout) findViewById(R.id.top_frame_layout); //   ?
    mTopLayout = (android.support.design.widget.AppBarLayout) findViewById(R.id.layout_toolbar); //  ?? ?
    mProgressCircle = (ProgressBar) findViewById(R.id.loading_circle); // loading circle

    //  ?? ?  ?? . (? ? .)
    mGeocoder = new Geocoder(this, Locale.KOREA); //  public Geocoder (Context context, Locale locale) // why korea??? -=--> ? ?. ? ??.

    mTextDemoMode = (TextView) findViewById(R.id.text_demo_mode);
    mMakeDemoButton = (FloatingActionButton) findViewById(R.id.fab_make_demo);
    mMakeDemoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            makeDemoData(200);
            getSupportLoaderManager().restartLoader(Constants.POWERCONTACT_LOADER, null, MainActivity.this); // reset Loader

        }
    });

    readDefaultSettings(mPowerContactSettings); //  ? ?. (? ??  .)

    if (savedInstanceState != null) { // ? ? ? ....
        // If we're restoring state after this fragment was recreated then
        // retrieve previous search term and previously selected search
        // result.

        mSearchKeyword = savedInstanceState.getString(QUERY_KEY);
        mPreviousSearchKeyword = mSearchKeyword; // ?
        mPowerContactSettings = savedInstanceState.getParcelable(POWER_CONTACT_SETTINGS_KEY);
        demoCreated = savedInstanceState.getBoolean(DEMO_CREATED_KEY);

        // https://developers.google.com/android/guides/api-client
        mResolvingError = savedInstanceState.getBoolean(STATE_RESOLVING_ERROR, false);
        mIsExpandedFragment = savedInstanceState.getBoolean("IS_EXPANDED", false); //  ? ? ?
        // Update the value of mCurrentLocation from the Bundle and update the UI to show the
        // correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation
            // is not null.
            mCurrentLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
    }

    Intent intent = getIntent();

    if (intent != null) {
        FROM_WIDGET = intent.getBooleanExtra(Constants.FROM_WIDGET_KEY, false);

        if (FROM_WIDGET) {
            Log.v(LOG_TAG, "From Widget distance");
            setDistance(0.0f); // distance all
            mPowerContactSettings.setDemoMode(false);
        }

    }
    //  ? ??

    toggleDemoMode(mPowerContactSettings.isDemoMode()); // demo mode false!

    buildGoogleApiClient(); //   

    // https://github.com/umano/AndroidSlidingUpPanel/blob/master/demo/src/com/sothree/slidinguppanel/demo/DemoActivity.java
    mMapFragment = (MapViewFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT_PANE1);
    mListFragment = (ContactsListFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT_PANE2);
    if (mMapFragment == null)
        mMapFragment = new MapViewFragment();

    if (mListFragment == null)
        mListFragment = new ContactsListFragment();

    getSupportFragmentManager().beginTransaction()
            .replace(R.id.contact_map_view_container, mMapFragment, TAG_FRAGMENT_PANE1).commit();
    getSupportFragmentManager().beginTransaction()
            .replace(R.id.contact_list_view_container, mListFragment, TAG_FRAGMENT_PANE2).commit();

}

From source file:com.freeme.filemanager.view.FileViewFragment.java

public void init() {
    long time1 = System.currentTimeMillis();
    //Debug.startMethodTracing("file_view");
    ViewStub stub = (ViewStub) mRootView.findViewById(R.id.viewContaniner);
    stub.setLayoutResource(R.layout.file_explorer_list);
    stub.inflate();//from ww  w  .  j a v  a 2 s.  com
    ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity);

    mFileCagetoryHelper = new FileCategoryHelper(mActivity);
    mFileViewInteractionHub = new FileViewInteractionHub(this, 1);
    // */ modify by droi liuhaoran for stop run
    /*/ Added by tyd wulianghuan 2013-12-12
    mCleanUpDatabaseHelper = new CleanUpDatabaseHelper(mActivity);
    mDatabase = mCleanUpDatabaseHelper.openDatabase();
    mFolderNameMap = new HashMap<String, String>();
    //*/

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication = (FileManagerApplication) mActivity.getApplication();
    // */

    // notifyFileChanged();
    Intent intent = mActivity.getIntent();
    String action = intent.getAction();
    if (!TextUtils.isEmpty(action)
            && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) {
        mFileViewInteractionHub.setMode(Mode.Pick);

        boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false);
        if (!pickFolder) {
            String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY);
            if (exts != null) {
                mFileCagetoryHelper.setCustomCategory(exts);
            }
        } else {
            mFileCagetoryHelper.setCustomCategory(new String[] {} /*
                                                                  * folder
                                                                  * only
                                                                  */);
            mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE);

            mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    try {
                        Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0);
                        mActivity.setResult(Activity.RESULT_OK, intent);
                        mActivity.finish();
                    } catch (URISyntaxException e) {
                        e.printStackTrace();
                    }
                }
            });

            mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    mActivity.finish();
                }
            });
        }
    } else {
        mFileViewInteractionHub.setMode(Mode.View);
    }
    mVolumeSwitch = (ImageButton) mRootView.findViewById(R.id.volume_navigator);
    updateVolumeSwitchState();
    mGalleryNavigationBar = (RelativeLayout) mRootView.findViewById(R.id.gallery_navigation_bar);
    mVolumeSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            int visibility = getVolumesListVisibility();
            if (visibility == View.GONE) {
                buildVolumesList();
                showVolumesList(true);
            } else if (visibility == View.VISIBLE) {
                showVolumesList(false);
            }
        }

    });
    mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list);
    mFileIconHelper = new FileIconHelper(mActivity);
    mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList,
            mFileViewInteractionHub, mFileIconHelper);

    boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD,
            !FileExplorerPreferenceActivity.isReadRoot(mActivity));
    Log.i(LOG_TAG, "baseSd = " + baseSd);

    String rootDir = intent.getStringExtra(ROOT_DIRECTORY);
    if (!TextUtils.isEmpty(rootDir)) {
        if (baseSd && this.sdDir.startsWith(rootDir)) {
            rootDir = this.sdDir;
        }
    } else {
        rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH;
    }

    String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity);
    Uri uri = intent.getData();
    if (uri != null) {
        if (baseSd && this.sdDir.startsWith(uri.getPath())) {
            currentDir = this.sdDir;
        } else {
            currentDir = uri.getPath();
        }
    }
    initVolumeState();
    mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action)
            || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT)));

    mFileListView.setAdapter(mAdapter);
    IntentFilter intentFilter = new IntentFilter();
    // add by xueweili for get sdcard
    intentFilter.setPriority(1000);

    /*
     * intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_EJECT);
     */
    if (!mReceiverTag) {
        mReceiverTag = true;
        intentFilter.addAction(GlobalConsts.BROADCAST_REFRESH);
        intentFilter.addDataScheme("file");
        mActivity.registerReceiver(mReceiver, intentFilter);
    }

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication.addSDCardChangeListener(this);
    // */

    setHasOptionsMenu(true);

    // add by mingjun for load file
    mRootView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
                int arg7, int arg8) {
            isLayout = arg1;
        }
    });
    loadDialog = new ProgressDialog(mRootView.getContext());
}

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

@Override
public void onResume() {
    super.onResume();

    Intent intent = getActivity().getIntent();
    String action = intent.getAction();

    Drug drug = null;/*from w  w  w . j ava  2 s .  co m*/

    mWrapper = new DrugWrapper();
    mFocusOnCurrentSupply = false;

    if (Intent.ACTION_EDIT.equals(action)) {
        final int drugId = intent.getIntExtra(DrugEditActivity2.EXTRA_DRUG_ID, -1);
        if (drugId == -1)
            throw new IllegalStateException("ACTION_EDIT requires EXTRA_DRUG_ID");

        drug = Drug.get(drugId);

        if (LOGV)
            Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, "drug");

        mWrapper.set(drug);
        mDrugHash = drug.hashCode();
        mIsEditing = true;

        if (intent.getBooleanExtra(DrugEditActivity2.EXTRA_FOCUS_ON_CURRENT_SUPPLY, false))
            mFocusOnCurrentSupply = true;

        setActivityTitle(drug.getName());
    } else if (Intent.ACTION_INSERT.equals(action)) {
        mIsEditing = false;
        mWrapper.set(new Drug());
        setActivityTitle(R.string._title_new_drug);
    } else
        throw new IllegalArgumentException("Unhandled action " + action);

    if (mWrapper.refillSize == 0)
        mWrapper.currentSupply = Fraction.ZERO;

    OTPM.mapToPreferenceHierarchy(getPreferenceScreen(), mWrapper);
    getPreferenceScreen().setOnPreferenceChangeListener(mListener);

    if (!mIsEditing) {
        final Preference p = findPreference("active");
        if (p != null)
            p.setEnabled(false);
    }

    if (mWrapper.refillSize == 0) {
        final Preference p = findPreference("currentSupply");
        if (p != null)
            p.setEnabled(false);
    }

    if (mFocusOnCurrentSupply) {
        Log.i(TAG, "Will focus on current supply preference");
        performPreferenceClick("currentSupply");
    }

    getActivity().supportInvalidateOptionsMenu();
}

From source file:com.clanofthecloud.cloudbuilder.pushnotifications.RegistrationIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    try {/*from   www .jav  a  2  s .  c  o m*/
        // In the (unlikely) event that multiple refresh operations occur simultaneously,
        // ensure that they are processed sequentially.
        synchronized (TAG) {
            // [START register_for_gcm]
            // Initially this call goes out to the network to retrieve the token, subsequent calls
            // are local.
            // [START get_token]
            InstanceID instanceID = InstanceID.getInstance(this);
            ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
                    PackageManager.GET_META_DATA);
            Object senderId = ai.metaData.get("cotc.GcmSenderId");
            if (senderId == null) {
                Log.e(TAG,
                        "!!!!!!!!! cotc.GcmSenderId not configured in manifest, push notifications won't work !!!!!!!!!");
                senderId = "";
            }
            if (CloudBuilder.sVerboseLog)
                Log.v(TAG, "Using senderId: " + senderId.toString());
            String token = instanceID.getToken(senderId.toString(), GoogleCloudMessaging.INSTANCE_ID_SCOPE,
                    null);
            // [END get_token]
            if (CloudBuilder.sVerboseLog)
                Log.v(TAG, "GCM Registration Token: " + token);

            registrationToken = token;

            // Subscribe to topic channels
            if (intent.getBooleanExtra(UNREGISTER_PARAM, false)) {
                unsubscribeTopics(token);
            } else {
                subscribeTopics(token);
            }
            // [END register_for_gcm]

            // Call handler
            if (handlerCalledWhenRegistrationTokenReceived != null) {
                JSONObject obj = new JSONObject();
                obj.put("token", token);
                handlerCalledWhenRegistrationTokenReceived.onDone(EErrorCode.enNoErr, obj, null);
            }
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed to complete token refresh", e);
        // If an exception happens while fetching the new token or updating our registration data
        // on a third-party server, this ensures that we'll attempt the update at a later time.
        //            sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(Controller.REGISTRATION_COMPLETE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

From source file:ch.ethz.twimight.net.opportunistic.ScanningService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    super.onStartCommand(intent, flags, startId);
    Log.d(T, "onStartCommand()");
    // Thread.setDefaultUncaughtExceptionHandler(new
    // CustomExceptionHandler());
    ScanningAlarm.releaseWakeLock();/* w w  w  .  j a v a  2s  .c om*/
    getWakeLock(this);
    // Register for broadcasts when discovery has finished
    registerDevicesReceiver();

    float probability;

    if (intent != null && intent.getBooleanExtra(FORCED_BLUE_SCAN, true))
        probability = 0;
    else {
        // get a random number
        Random r = new Random(System.currentTimeMillis());
        probability = r.nextFloat();
    }
    initiateScanningRound(probability);

    return START_STICKY;
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    if (DEBUG)/*from   w w w  .j a v a  2 s .  c  o  m*/
        Log.d(TAG, "New intent received " + intent.toString());
    // Don't change the date if we're just returning to the app's home
    if (Intent.ACTION_VIEW.equals(action) && !intent.getBooleanExtra(Utils.INTENT_KEY_HOME, false)) {
        long millis = parseViewAction(intent);
        if (millis == -1) {
            millis = Utils.timeFromIntentInMillis(intent);
        }
        if (millis != -1 && mViewEventId == -1 && mController != null) {
            Time time = new Time(mTimeZone);
            time.set(millis);
            time.normalize(true);
            mController.sendEvent(this, EventType.GO_TO, time, time, -1, ViewType.CURRENT);
        }
    }
}

From source file:gov.wa.wsdot.android.wsdot.service.MountainPassesSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/*from ww w.  j  a v  a 2 s.co m*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED },
                Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "mountain_passes" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min");
            shouldUpdate = (Math.abs(now - lastUpdated) > (15 * DateUtils.MINUTE_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();
        buildWeatherPhrases();

        try {
            URL url = new URL(MOUNTAIN_PASS_URL);
            URLConnection urlConn = url.openConnection();

            BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream());
            GZIPInputStream gzin = new GZIPInputStream(bis);
            InputStreamReader is = new InputStreamReader(gzin);
            BufferedReader in = new BufferedReader(is);

            String mDateUpdated = "";
            String jsonFile = "";
            String line;
            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("GetMountainPassConditionsResult");
            JSONArray passConditions = result.getJSONArray("PassCondition");
            String weatherCondition;
            Integer weather_image;
            Integer forecast_weather_image;
            List<ContentValues> passes = new ArrayList<ContentValues>();

            int numConditions = passConditions.length();
            for (int j = 0; j < numConditions; j++) {
                JSONObject pass = passConditions.getJSONObject(j);
                ContentValues passData = new ContentValues();
                weatherCondition = pass.getString("WeatherCondition");
                weather_image = getWeatherImage(weatherPhrases, weatherCondition);

                String tempDate = pass.getString("DateUpdated");

                try {
                    tempDate = tempDate.replace("[", "");
                    tempDate = tempDate.replace("]", "");

                    String[] a = tempDate.split(",");
                    StringBuilder sb = new StringBuilder();
                    for (int m = 0; m < 5; m++) {
                        sb.append(a[m]);
                        sb.append(",");
                    }
                    tempDate = sb.toString().trim();
                    tempDate = tempDate.substring(0, tempDate.length() - 1);
                    Date date = parseDateFormat.parse(tempDate);
                    mDateUpdated = displayDateFormat.format(date);
                } catch (Exception e) {
                    Log.e(DEBUG_TAG, "Error parsing date: " + tempDate, e);
                    mDateUpdated = "N/A";
                }

                JSONArray forecasts = pass.getJSONArray("Forecast");
                JSONArray forecastItems = new JSONArray();

                int numForecasts = forecasts.length();
                for (int l = 0; l < numForecasts; l++) {
                    JSONObject forecast = forecasts.getJSONObject(l);

                    if (isNight(forecast.getString("Day"))) {
                        forecast_weather_image = getWeatherImage(weatherPhrasesNight,
                                forecast.getString("ForecastText"));
                    } else {
                        forecast_weather_image = getWeatherImage(weatherPhrases,
                                forecast.getString("ForecastText"));
                    }

                    forecast.put("weather_icon", forecast_weather_image);

                    if (l == 0) {
                        if (weatherCondition.equals("")) {
                            weatherCondition = forecast.getString("ForecastText").split("\\.")[0] + ".";
                            weather_image = forecast_weather_image;
                        }
                    }

                    forecastItems.put(forecast);
                }

                passData.put(MountainPasses.MOUNTAIN_PASS_ID, pass.getString("MountainPassId"));
                passData.put(MountainPasses.MOUNTAIN_PASS_NAME, pass.getString("MountainPassName"));
                passData.put(MountainPasses.MOUNTAIN_PASS_WEATHER_ICON, weather_image);
                passData.put(MountainPasses.MOUNTAIN_PASS_FORECAST, forecastItems.toString());
                passData.put(MountainPasses.MOUNTAIN_PASS_WEATHER_CONDITION, weatherCondition);
                passData.put(MountainPasses.MOUNTAIN_PASS_DATE_UPDATED, mDateUpdated);
                passData.put(MountainPasses.MOUNTAIN_PASS_CAMERA, pass.getString("Cameras"));
                passData.put(MountainPasses.MOUNTAIN_PASS_ELEVATION, pass.getString("ElevationInFeet"));
                passData.put(MountainPasses.MOUNTAIN_PASS_TRAVEL_ADVISORY_ACTIVE,
                        pass.getString("TravelAdvisoryActive"));
                passData.put(MountainPasses.MOUNTAIN_PASS_ROAD_CONDITION, pass.getString("RoadCondition"));
                passData.put(MountainPasses.MOUNTAIN_PASS_TEMPERATURE,
                        pass.getString("TemperatureInFahrenheit"));
                JSONObject restrictionOne = pass.getJSONObject("RestrictionOne");
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_ONE,
                        restrictionOne.getString("RestrictionText"));
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_ONE_DIRECTION,
                        restrictionOne.getString("TravelDirection"));
                JSONObject restrictionTwo = pass.getJSONObject("RestrictionTwo");
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_TWO,
                        restrictionTwo.getString("RestrictionText"));
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_TWO_DIRECTION,
                        restrictionTwo.getString("TravelDirection"));

                if (starred.contains(Integer.parseInt(pass.getString("MountainPassId")))) {
                    passData.put(MountainPasses.MOUNTAIN_PASS_IS_STARRED, 1);
                }

                passes.add(passData);

            }

            // Purge existing mountain passes covered by incoming data
            resolver.delete(MountainPasses.CONTENT_URI, null, null);
            // Bulk insert all the new mountain passes
            resolver.bulkInsert(MountainPasses.CONTENT_URI, passes.toArray(new ContentValues[passes.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?",
                    new String[] { "mountain_passes" });

            responseString = "OK";
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }

    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.MOUNTAIN_PASSES_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {

        UpdateListView();/*from  w w w .ja  va 2s  .  c om*/

        getSlidingListFragment().ListViewNotifyDataSetChanged();
    }

    if (requestCode == RESULT_SETTINGS) {
        //Update settings of image Loader
        ((NewsReaderApplication) getApplication()).initImageLoader();

        String oldLayout = data.getStringExtra(SettingsActivity.SP_FEED_LIST_LAYOUT);
        String newLayout = PreferenceManager.getDefaultSharedPreferences(this)
                .getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0");

        if (ThemeChooser.ThemeRequiresRestartOfUI(this) || !newLayout.equals(oldLayout)) {
            finish();
            startActivity(getIntent());
        }
    } else if (requestCode == RESULT_ADD_NEW_FEED) {
        if (data != null) {
            boolean val = data.getBooleanExtra(NewFeedActivity.ADD_NEW_SUCCESS, false);
            if (val)
                startSync();
        }
    }
}