Example usage for android.os Bundle Bundle

List of usage examples for android.os Bundle Bundle

Introduction

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

Prototype

public Bundle() 

Source Link

Document

Constructs a new, empty Bundle.

Usage

From source file:at.bitfire.davdroid.syncadapter.QueryServerDialogFragment.java

@Override
public void onLoadFinished(Loader<ServerInfo> loader, ServerInfo serverInfo) {
    if (serverInfo.getErrorMessage() != null)
        Toast.makeText(getActivity(), serverInfo.getErrorMessage(), Toast.LENGTH_LONG).show();
    else {/*from www.  ja va  2 s  . c  o  m*/
        SelectCollectionsFragment selectCollections = new SelectCollectionsFragment();
        Bundle arguments = new Bundle();
        arguments.putSerializable(SelectCollectionsFragment.KEY_SERVER_INFO, serverInfo);
        selectCollections.setArguments(arguments);

        getFragmentManager().beginTransaction().replace(R.id.fragment_container, selectCollections)
                .addToBackStack(null).commitAllowingStateLoss();
    }

    getDialog().dismiss();
}

From source file:com.app.jdy.adapter.ImagePagerAdapter.java

@Override
public View getView(int position, View view, ViewGroup container) {
    ViewHolder holder;/*from w w  w .  j  a va 2s.c  om*/
    if (view == null) {
        holder = new ViewHolder();
        view = holder.imageView = new ImageView(context);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    ImagePosition = position;
    holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    holder.imageView.setImageBitmap(imageIdList.get(getPosition(position)));
    holder.imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.i("debug==========position", String.valueOf(getPosition(ImagePosition)));
            if (getPosition(ImagePosition) == 1) {
                Intent intent = new Intent(context, PictureActivity.class);
                Bundle bundle = new Bundle();
                intent.putExtra("title", "");
                intent.putExtra("url", URLs.HONGBAO_INTRODUCE);
                intent.putExtras(bundle);
                context.startActivity(intent);
            } else if (getPosition(ImagePosition) == 0) {
                Intent intent = new Intent(context, PictureActivity.class);
                intent.putExtra("title", "???");
                Bundle bundle = new Bundle();
                intent.putExtra("url", URLs.SHANGXIAN_INTRODUCE);
                context.startActivity(intent);
            }
        }
    });
    return view;
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

public static MainFragment31 newInstance(String text) {
    MainFragment31 mFragment = new MainFragment31();
    Bundle mBundle = new Bundle();
    mBundle.putString(TEXT_FRAGMENT, text);
    mFragment.setArguments(mBundle);//  www  .j  a  va 2  s  . co m
    return mFragment;
}

From source file:com.example.t_danbubbletea.MySelections.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_tea_selections, container, false);
    getActivity().setTitle("Tea Selections");
    // animation when enter home page
    rootView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.image_click));
    //download the URL's asynchronously (put the info in the teaInfo object)
    try {/*from  ww  w.ja v a  2s.c om*/
        teaInfo = new GetTeaInfoTask().execute(new ApiConnector()).get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    //make the gridview, set its adapter
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_tea_selections);
    GridViewCustomAdapter gvAdapter = new GridViewCustomAdapter(getActivity(), teaInfo.imageURLs,
            teaInfo.teaNames);
    gridView.setAdapter(gvAdapter);
    //make the on click listeners
    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Fragment newFragment;
            switch (position) {
            default:
                Bundle teaViewArgs = new Bundle();
                teaViewArgs.putString("teaName", teaInfo.teaNames.get(position));
                teaViewArgs.putString("teaImgUrl", teaInfo.imageURLs.get(position));
                teaViewArgs.putString("teaDesc", teaInfo.teaDescriptions.get(position));
                newFragment = new TeaViewFragment();
                newFragment.setArguments(teaViewArgs);
                break;

            }
            if (newFragment != null) {
                flipCard(newFragment);
            }
        }

        private void flipCard(Fragment newFragment) {
            mShowingBack = true;
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .setCustomAnimations(R.anim.card_flip_right_in, R.anim.card_flip_right_out,
                            R.anim.card_flip_left_in, R.anim.card_flip_left_out)
                    .replace(R.id.frame_container, newFragment).addToBackStack(null).commit(); // create new fragment and allow user to go back to previous fragment          
        }
    });
    return rootView;
}

From source file:com.geozen.demo.foursquare.jiramot.Foursquare.java

private void startDialogAuth(Context activity) {
    CookieSyncManager.createInstance(activity);
    Bundle params = new Bundle();
    dialog(activity, LOGIN, params, new DialogListener() {

        public void onComplete(Bundle values) {
            // ensure any cookies set by the dialog are saved
            CookieSyncManager.getInstance().sync();
            String _token = values.getString(TOKEN);
            setAccessToken(_token);//from  w  ww  .  j  a v  a  2 s .c  om
            if (isSessionValid()) {
                Log.d("Foursquare-authorize", "Login Success! access_token=" + getAccessToken());
                mAuthDialogListener.onComplete(values);
            } else {
                mAuthDialogListener.onFoursquareError(new FoursquareError("Failed to receive access token."));
            }
        }

        public void onError(DialogError error) {
            Log.d("Foursquare-authorize", "Login failed: " + error);
            mAuthDialogListener.onError(error);
        }

        public void onFoursquareError(FoursquareError error) {
            Log.d("Foursquare-authorize", "Login failed: " + error);
            mAuthDialogListener.onFoursquareError(error);
        }

        public void onCancel() {
            Log.d("Foursquare-authorize", "Login canceled");
            mAuthDialogListener.onCancel();
        }
    });
}

From source file:com.creationgroundmedia.popularmovies.sync.MovieSyncAdapter.java

public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().syncPeriodic(syncInterval, flexTime)
                .setSyncAdapter(account, authority).setExtras(new Bundle()).build();
        ContentResolver.requestSync(request);
    } else {//w ww.  j  a  v a  2 s .c om
        ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval);
    }
}

From source file:com.facebook.share.internal.WebDialogParameters.java

public static Bundle create(ShareOpenGraphContent shareOpenGraphContent) {
    Bundle params = new Bundle();

    Utility.putNonEmptyString(params, ShareConstants.WEB_DIALOG_PARAM_ACTION_TYPE,
            shareOpenGraphContent.getAction().getActionType());

    try {//from   www. j  a va  2s .c om
        JSONObject ogJSON = ShareInternalUtility.toJSONObjectForWeb(shareOpenGraphContent);
        ogJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(ogJSON, false);
        if (ogJSON != null) {
            Utility.putNonEmptyString(params, ShareConstants.WEB_DIALOG_PARAM_ACTION_PROPERTIES,
                    ogJSON.toString());
        }
    } catch (JSONException e) {
        throw new FacebookException("Unable to serialize the ShareOpenGraphContent to JSON", e);
    }

    return params;
}

From source file:com.cloudbees.gasp.fragment.TwitterSearchResponderFragment.java

private void setTweets() {
    TwitterRESTServiceActivity activity = (TwitterRESTServiceActivity) getActivity();

    if (mTweets == null && activity != null) {
        // This is where we make our REST call to the service. We also pass in our ResultReceiver
        // defined in the RESTResponderFragment super class.

        // We will explicitly call our Service since we probably want to keep it as a private
        // component in our app. You could do this with Intent actions as well, but you have
        // to make sure you define your intent filters correctly in your manifest.
        Intent intent = new Intent(activity, RESTService.class);
        intent.setData(Uri.parse("http://search.twitter.com/search.json"));

        // Here we are going to place our REST call parameters. Note that
        // we could have just used Uri.Builder and appendQueryParameter()
        // here, but I wanted to illustrate how to use the Bundle params.
        Bundle params = new Bundle();
        params.putString("q", "cloudbees");

        intent.putExtra(RESTService.EXTRA_PARAMS, params);
        intent.putExtra(RESTService.EXTRA_RESULT_RECEIVER, getResultReceiver());

        // Here we send our Intent to our RESTService.
        activity.startService(intent);/*from   w ww  . j  a  v  a  2  s  .co  m*/
    } else if (activity != null) {
        // Here we check to see if our activity is null or not.
        // We only want to update our views if our activity exists.

        ArrayAdapter<String> adapter = activity.getArrayAdapter();

        // Load our list adapter with our Tweets.
        adapter.clear();
        for (String tweet : mTweets) {
            adapter.add(tweet);
        }
    }
}

From source file:com.foxykeep.datadroidpoc.data.operation.ComputeSquareOperation.java

@Override
public Bundle execute(Context context, Request request)
        throws ConnectionException, DataException, CustomRequestException {
    String url;//w  w w. j ava 2  s.  c om
    NetworkConnection.Method method;

    switch (request.getInt(PARAM_METHOD)) {
    case 0: // GET
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        break;
    case 1: // POST
        url = WSConfig.WS_REQUEST_TYPES_POST;
        method = NetworkConnection.Method.POST;
        break;
    case 2: // PUT
        // TODO for now hack to keep it as a GET method as my server doesn't accept PUT
        // requests
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        //                url = WSConfig.WS_REQUEST_TYPES_PUT;
        //                method = NetworkConnection.Method.PUT;
        break;
    case 3: // DELETE
        // TODO for now hack to keep it as a GET method as my server doesn't accept
        // DELETE requests
        url = WSConfig.WS_REQUEST_TYPES_GET;
        method = NetworkConnection.Method.GET;
        //                url = WSConfig.WS_REQUEST_TYPES_DELETE;
        //                method = NetworkConnection.Method.DELETE;
        break;
    default:
        throw new IllegalArgumentException("Unknown method: " + request.getInt(PARAM_METHOD));
    }

    NetworkConnection connection = new NetworkConnection(context, url);
    connection.setMethod(method);
    ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair(WSConfig.WS_REQUEST_TYPE_NUMBER, request.getIntAsString(PARAM_NUMBER)));
    connection.setParameters(params);
    NetworkConnection.ConnectionResult result = connection.execute();

    // Parse the result
    Bundle bundle = new Bundle();
    try {
        JSONObject root = new JSONObject(result.body);
        bundle.putInt(PoCRequestFactory.BUNDLE_EXTRA_SQUARE, root.getInt(JSONTag.REQUEST_TYPE_VALUE));
    } catch (JSONException e) {
        throw new DataException(e);
    }

    return bundle;
}

From source file:Main.java

public static ResponseHandler<String> GetResponseHandlerInstance(final Handler handler) {
    final ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
        @Override/*from   w w w  .  j a  va2s  . c o m*/
        public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
            Message message = handler.obtainMessage();
            Bundle bundle = new Bundle();
            StatusLine status = response.getStatusLine();
            HttpEntity entity = response.getEntity();
            String result = null;
            if (entity != null) {
                try {
                    result = InputStreamToString(entity.getContent());
                    bundle.putString("RESPONSE", result);
                    message.setData(bundle);
                    handler.sendMessage(message);
                } catch (IOException e) {
                    bundle.putString("RESPONSE", "Error - " + e.getMessage());
                    message.setData(bundle);
                    handler.sendMessage(message);
                }
            } else {
                bundle.putString("RESPONSE", "Error - " + response.getStatusLine().getReasonPhrase());
                message.setData(bundle);
                handler.sendMessage(message);
            }
            return result;
        }
    };

    return responseHandler;
}