Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

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

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

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

Usage

From source file:com.nextgis.firereporter.HttpGetter.java

@Override
protected Void doInBackground(String... urls) {
    if (IsNetworkAvailible(mContext)) {
        try {/*from   ww w . java2s.  co  m*/
            String sURL = urls[0];

            httpget = new HttpGet(sURL);

            Log.d("MainActivity", "HTTPGet URL " + sURL);

            if (urls.length > 1) {
                httpget.setHeader("Cookie", urls[1]);
            }

            //TODO: move timeouts to parameters
            HttpParams httpParameters = new BasicHttpParams();
            int timeoutConnection = 1500;
            HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
            // Set the default socket timeout (SO_TIMEOUT) 
            // in milliseconds which is the timeout for waiting for data.
            int timeoutSocket = 3000;
            HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

            HttpClient Client = new DefaultHttpClient(httpParameters);

            HttpResponse response = Client.execute(httpget);
            //ResponseHandler<String> responseHandler = new BasicResponseHandler();
            //mContent = Client.execute(httpget, responseHandler);
            HttpEntity entity = response.getEntity();

            Bundle bundle = new Bundle();
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                bundle.putBoolean(GetFiresService.ERROR, false);
                mContent = EntityUtils.toString(entity);
                bundle.putString(GetFiresService.JSON, mContent);
            } else {
                bundle.putBoolean(GetFiresService.ERROR, true);
                bundle.putString(GetFiresService.ERR_MSG, response.getStatusLine().getStatusCode() + ": "
                        + response.getStatusLine().getReasonPhrase());
            }

            bundle.putInt(GetFiresService.SOURCE, mnType);

            Message msg = new Message();
            msg.setData(bundle);
            if (mEventReceiver != null) {
                mEventReceiver.sendMessage(msg);
            }

        } catch (ClientProtocolException e) {
            mError = e.getMessage();
            cancel(true);
        } catch (IOException e) {
            mError = e.getMessage();
            cancel(true);
        }
    } else {
        Bundle bundle = new Bundle();
        bundle.putBoolean(GetFiresService.ERROR, true);
        bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork));
        bundle.putInt(GetFiresService.SOURCE, mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    }
    return null;
}

From source file:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java

@Override
public void onInflate(Activity a, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(a, attrs, savedInstanceState);
    TypedArray array = a.obtainStyledAttributes(attrs, R.styleable.SprocketsPreferenceFragment);
    Bundle args = Fragments.arguments(this);
    args.putInt(PREFS, array.getResourceId(R.styleable.SprocketsPreferenceFragment_preferences, 0));
    args.putBoolean(TRACK_CHANGES,
            array.getBoolean(R.styleable.SprocketsPreferenceFragment_trackChanges, false));
    array.recycle();//from   w w w. j av a  2s . c  om
}

From source file:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mIsAddingNewSubtype) {
        outState.putBoolean(KEY_IS_ADDING_NEW_SUBTYPE, true);
    }//from  ww w . ja  va2 s.c  o  m
    if (mSubtypeEnablerNotificationDialog != null && mSubtypeEnablerNotificationDialog.isShowing()) {
        outState.putBoolean(KEY_IS_SUBTYPE_ENABLER_NOTIFICATION_DIALOG_OPEN, true);
        outState.putString(KEY_SUBTYPE_FOR_SUBTYPE_ENABLER, mSubtypePreferenceKeyForSubtypeEnabler);
    }
}

From source file:app.hacked.ChallengeDetailsActivity.java

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

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    getActionBar().setIcon(R.drawable.ic_ab_logo);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    ////w ww . j a  v a 2 s  .c  o m
    // http://developer.android.com/guide/components/fragments.html
    //
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putString(ChallengeDetailsFragment.TITLE,
                getIntent().getStringExtra(ChallengeDetailsFragment.TITLE));
        arguments.putString(ChallengeDetailsFragment.DETAILS,
                getIntent().getStringExtra(ChallengeDetailsFragment.DETAILS));
        arguments.putBoolean(ProjectDetailsFragment.ARG_2PANE,
                getIntent().getBooleanExtra(ProjectDetailsFragment.ARG_2PANE, false));

        ChallengeDetailsFragment fragment = new ChallengeDetailsFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().replace(R.id.ChallengeDetails, fragment).commit();
    }
}

From source file:com.android.gallery3d.app.Gallery.java

private void startGetContent(Intent intent) {
    Bundle data = intent.getExtras() != null ? new Bundle(intent.getExtras()) : new Bundle();
    data.putBoolean(KEY_GET_CONTENT, true);
    int typeBits = GalleryUtils.determineTypeBits(this, intent);
    data.putInt(KEY_TYPE_BITS, typeBits);
    data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(typeBits));
    getStateManager().setLaunchGalleryOnTop(true);
    getStateManager().startState(AlbumSetPage.class, data);
}

From source file:cl.ipp.katbag.fragment.Board.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.fragment_board, container, false);
    mainActivity = (MainActivity) super.getActivity();

    notRegister = (TextView) v.findViewById(R.id.board_not_register);

    boardListView = (DragSortListView) v.findViewById(R.id.board_list_view);
    boardListView.setOnItemClickListener(new OnItemClickListener() {
        @Override/*  w w  w  .j  a  v a2 s . c  o  m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            TextView idApp = (TextView) view.findViewById(R.id.board_row_id);
            TextView typeApp = (TextView) view.findViewById(R.id.board_row_type);
            TextView nameApp = (TextView) view.findViewById(R.id.board_row_name);

            if (typeApp.getText().toString().contentEquals(MainActivity.TYPE_APP_GAME))
                mFragment = new Player();
            else
                mFragment = new PlayerBook();

            Bundle bundle = new Bundle();
            bundle.putLong("id_app", Long.parseLong(idApp.getText().toString()));
            bundle.putString("name_app", nameApp.getText().toString());
            bundle.putString("type_app", typeApp.getText().toString());
            bundle.putBoolean("editMode", false);

            mFragment.setArguments(bundle);
            FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
            t.replace(R.id.fragment_main_container, mFragment);
            t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            t.addToBackStack(mFragment.getClass().getSimpleName());
            t.commit();
        }
    });

    return v;
}

From source file:com.almunt.jgcaap.systemupdater.DownloadService.java

@Override
protected void onHandleIntent(Intent intent) {
    String urlToDownload = "http://download.jgcaap.xyz/files/oneplusone/cm-13.0/"
            + intent.getStringExtra("url");
    filename = intent.getStringExtra("url");
    String newfilename = filename.replace("zip", "temp");
    ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver");
    try {//w  w  w . j  a v a  2 s  .  co  m
        URL url = new URL(urlToDownload);
        URLConnection connection = url.openConnection();
        connection.connect();
        // this will be useful so that you can show a typical 0-100% progress bar
        int fileLength = connection.getContentLength();
        // download the file
        InputStream input = new BufferedInputStream(connection.getInputStream());
        File tempDir = new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/");
        tempDir.mkdir();
        //make a folder for downloading files
        OutputStream output = new FileOutputStream(
                Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename);
        byte data[] = new byte[1024];
        long total = 0;
        int count;
        File temp = new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/nd");
        //temp file is created in case of an error
        while ((count = input.read(data)) != -1 && continuedownload) {
            total += count;
            // publishing the progress....
            Bundle resultData = new Bundle();
            resultData.putInt("progress", (int) total);
            resultData.putInt("total", fileLength);
            resultData.putString("filename", filename);
            resultData.putBoolean("error", false);
            receiver.send(UPDATE_PROGRESS, resultData);
            output.write(data, 0, count);
            if (temp.exists()) {
                continuedownload = false;
                temp.delete();
            }
        }
        output.flush();
        output.close();
        input.close();
    } catch (IOException e) {
        System.out.println(e.getMessage());
        Bundle resultData = new Bundle();
        resultData.putInt("progress", 0);
        resultData.putInt("total", 1);
        resultData.putString("filename", filename);
        resultData.putBoolean("error", true);
        resultData.putString("errordetails", e.getMessage());
        receiver.send(UPDATE_PROGRESS, resultData);
    }
    String dir = Environment.getExternalStorageDirectory() + File.separator + "JgcaapUpdates";
    // copy downloaded file if download is successful
    if (continuedownload) {
        try {
            if (new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename)
                    .length() > 1000)
                copy(new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename),
                        new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/" + filename));

        } catch (IOException e) {
            e.printStackTrace();
        }
        Bundle resultData = new Bundle();
        resultData.putInt("progress", 100);
        receiver.send(UPDATE_PROGRESS, resultData);
    }
    //clear the temporary folder
    File deletefolder = new File(dir + "/temp");
    if (deletefolder.exists()) {
        File[] contents = deletefolder.listFiles();
        if (contents != null) {
            for (File f : contents) {
                f.delete();
            }
        }
    }
    deletefolder.delete();
}

From source file:cn.newgxu.android.bbs.activity.ForumActivity.java

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

    setContentView(R.layout.forum_tabs_pager);
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();//from  ww  w  .  j  av a  2  s  .c  om

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

    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    Bundle forumArgs = new Bundle();
    String fid = getIntent().getStringExtra(ForumsProvider.FID);
    forumArgs.putInt(ForumsProvider.FID, Integer.parseInt(fid));
    mTabsAdapter.addTab(mTabHost.newTabSpec("forum_overview")
            .setIndicator(getResources().getString(R.string.forum_overview)), ForumFragment.class, forumArgs);
    Bundle topicsArgs = new Bundle();
    topicsArgs.putInt(Consts.FID, Integer.parseInt(fid));
    topicsArgs.putString(Consts.URL, "/api/topics?type=3&count=15&fid=" + fid);
    mTabsAdapter.addTab(mTabHost.newTabSpec("topics").setIndicator(getResources().getString(R.string.topics)),
            ForumsTopicsFragment.class, topicsArgs);
    Bundle classicsArgs = new Bundle();
    classicsArgs.putString(Consts.URL, "/api/topics?type=-1&count=15&fid=" + fid);
    classicsArgs.putInt(Consts.FID, Integer.parseInt(fid));
    classicsArgs.putBoolean(Consts.IS_CLASSIC, true);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec("classics").setIndicator(getResources().getString(R.string.classics)),
            ForumsTopicsFragment.class, classicsArgs);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }

    getSupportActionBar().setTitle(getIntent().getStringExtra(ForumsProvider.NAME));
    getSupportActionBar().setIcon(R.drawable.face);
}

From source file:com.oscarsalguero.solartracker.MainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putBoolean(REQUESTING_LOCATION_UPDATES_KEY, mRequestingLocationUpdates);
    savedInstanceState.putParcelable(LOCATION_KEY, mLastLocation);
    savedInstanceState.putString(LAST_UPDATED_TIME_STRING_KEY, mLastUpdateTime);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.grass.caishi.cc.activity.main.SettingsFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (((MainActivity) getActivity()).isConflict) {
        outState.putBoolean("isConflict", true);
    } else if (((MainActivity) getActivity()).getCurrentAccountRemoved()) {
        outState.putBoolean(Constant.ACCOUNT_REMOVED, true);
    }/*from w  w w.  j av a2  s .c  om*/
}