Example usage for android.os Bundle putSerializable

List of usage examples for android.os Bundle putSerializable

Introduction

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

Prototype

@Override
public void putSerializable(@Nullable String key, @Nullable Serializable value) 

Source Link

Document

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

Usage

From source file:com.mummyding.app.leisure.ui.science.BaseScienceFragment.java

@Override
protected PagerAdapter initPagerAdapter() {
    pagerAdapter = new PagerAdapter(getChildFragmentManager(), ScienceApi.channel_title) {
        @Override/*from w  w  w  .j  ava  2s .c o m*/
        public Fragment getItem(int position) {
            ScienceFragment fragment = new ScienceFragment();
            Bundle bundle = new Bundle();
            bundle.putInt(getString(R.string.id_pos), position);
            bundle.putSerializable(getString(R.string.id_category), ScienceApi.channel_tag[position]);
            fragment.setArguments(bundle);
            return fragment;
        }
    };
    return pagerAdapter;
}

From source file:net.reichholf.dreamdroid.activities.SearchEpgActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putSerializable("currentItem", mCurrentItem);
    super.onSaveInstanceState(outState);
}

From source file:fr.julienvermet.bugdroid.service.ProductsIntentService.java

private void sendResult(Intent intent, ArrayList<Product> products) {
    Bundle extras = intent.getExtras();//from w w w  .  ja  va  2 s. com
    Messenger messenger = (Messenger) extras.get(MESSENGER);
    if (messenger != null) {
        Message msg = Message.obtain();
        Bundle data = new Bundle();
        data.putSerializable(PRODUCTS, products);
        msg.setData(data);
        try {
            messenger.send(msg);
        } catch (android.os.RemoteException e1) {
            Log.w(getClass().getName(), "Exception sending message", e1);
        }
    }
}

From source file:com.juick.android.ExploreActivity.java

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

    setContentView(R.layout.explore);/*from   w  w  w .  ja v a2  s. c  om*/

    etSearch = (EditText) findViewById(R.id.editSearch);
    (findViewById(R.id.buttonFind)).setOnClickListener(this);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    TagsFragment tf = new TagsFragment();
    tf.saveMineAll = true;
    Bundle args = new Bundle();
    args.putSerializable("messagesSource", getIntent().getSerializableExtra("messagesSource"));
    uid = getIntent().getIntExtra("uid", -1);
    uname = getIntent().getStringExtra("uname");
    args.putSerializable("uid", uid);
    tf.setArguments(args);
    ft.add(R.id.tagsfragment, tf);
    ft.commit();
    MainActivity.restyleChildrenOrWidget(getWindow().getDecorView());
}

From source file:com.mpgtracker.tallmatt.mpgtracker.ui.dialogfragments.NewCarDialogFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    boolean cancellable = getArguments().getBoolean(KEY_CANCELLABLE);

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override/*w w w . j  a  v  a  2s .  co  m*/
        public void onClick(View v) {
            NewCarDialogFragment.this.dismiss();
        }
    });
    if (!cancellable) {
        cancelButton.setClickable(cancellable);
        cancelButton.setAlpha(0.5f);
    }

    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // save it
            if (nameEdit.getText().toString().isEmpty()) {
                requiredText.setVisibility(View.VISIBLE);
                return;
            }

            if (dialogListener != null) {
                Bundle args = new Bundle();
                args.putSerializable(KEY_NEW_CARMODEL,
                        new Car(-1, makeEdit.getText().toString(), modelEdit.getText().toString(),
                                yearEdit.getText().toString(), licenseEdit.getText().toString(),
                                nameEdit.getText().toString()));

                dialogListener.onDialogClose(args);

                dismiss();
            }
        }
    });
}

From source file:com.kangsoo.pharmacy.fragment.HomePagerAdapter.java

@Override
public Fragment getItem(int position) {

    Fragment fragment = new Fragment();
    switch (position) {
    case 0://from   w  w w  .j  a  va2  s  .co  m
        fragment = new CameraActivity();
        break;

    case 1:
        fragment = new PhotoActivity();
        break;

    case 2:
        fragment = new BeaconRangeActivity();
        break;

    case 3:
        fragment = new ShoppingCategoryListFragment();
        break;

    case 4:
        fragment = new ShoppingItemListFragment();
        break;
    }

    if (fragment != null) {
        Bundle args = new Bundle();
        args.putSerializable("org", org);
        fragment.setArguments(args);
    }
    return fragment;
}

From source file:augsburg.se.alltagsguide.settings.PrefFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(PAGE_KEY, new ArrayList<>(mPages));
    super.onSaveInstanceState(outState);
}

From source file:com.lewa.crazychapter11.Dict.java

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

    dbHelper = new MyDatabaseHelper(this, "myDict.db3", 1);

    insert = (Button) findViewById(R.id.btn_insert);
    search = (Button) findViewById(R.id.btn_search);

    insert.setOnClickListener(new OnClickListener() {
        @Override//from   w w  w  .  ja v  a 2  s .  c  o  m
        public void onClick(View source) {
            String word = ((EditText) findViewById(R.id.word)).getText().toString();
            String detail = ((EditText) findViewById(R.id.detail)).getText().toString();

            insertData(dbHelper.getReadableDatabase(), word, detail);
            Toast.makeText(Dict.this, "??", Toast.LENGTH_SHORT).show();

        }
    });

    search.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View source) {
            String key = ((EditText) findViewById(R.id.key)).getText().toString();

            Cursor cursor = dbHelper.getReadableDatabase().rawQuery(
                    "select*from dict where word like ? or detail like ?",
                    new String[] { "%" + key + "%" + "%" + key + "%" });
            Bundle data = new Bundle();
            data.putSerializable("data", converCursorToList(cursor));

            Intent intent = new Intent(Dict.this, ResultActivity.class);
            intent.putExtras(data);
            startActivity(intent);
        }
    });
}

From source file:com.github.mobile.ui.repo.RepositoryViewActivity.java

@Override
public boolean onSearchRequested() {
    if (pager.getCurrentItem() == 1) {
        Bundle args = new Bundle();
        args.putSerializable(EXTRA_REPOSITORY, repository);
        startSearch(null, false, args, false);
        return true;
    } else/* ww  w.  j a  va 2 s.com*/
        return false;
}

From source file:com.example.firstapp.AbstractGetNameTask.java

/**
 * Contacts the user info server to get the profile of the user and extracts
 * the first name of the user from the profile. In order to authenticate
 * with the user info server the method first fetches an access token from
 * Google Play services./*from w w w  .  j ava 2  s . c  om*/
 * @return 
 * @return 
 * 
 * @throws IOException
 *             if communication with user info server failed.
 * @throws JSONException
 *             if the response from the server could not be parsed.
 */
private void fetchNameFromProfileServer() throws IOException, JSONException {
    String token = fetchToken();
    URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    int sc = con.getResponseCode();
    if (sc == 200) {
        InputStream is = con.getInputStream();
        GOOGLE_USER_DATA = readResponse(is);
        is.close();

        Intent intent = new Intent(mActivity, HomeActivity.class);
        Bundle b = new Bundle();
        b.putSerializable("object", ob);
        intent.putExtras(b);
        intent.putExtra("email_id", mEmail);
        mActivity.startActivity(intent);
        mActivity.finish();
        return;
    } else if (sc == 401) {
        GoogleAuthUtil.invalidateToken(mActivity, token);
        onError("Server auth error, please try again.", null);
        //Toast.makeText(mActivity, "Please try again", Toast.LENGTH_SHORT).show();
        //mActivity.finish();
        return;
    } else {
        onError("Server returned the following error code: " + sc, null);
        return;
    }
}