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.LoginURLFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.next:
        FragmentTransaction ft = getFragmentManager().beginTransaction();

        Bundle args = new Bundle();
        try {/*  w  w w  .  ja  v a  2 s.  c o  m*/
            args.putString(QueryServerDialogFragment.EXTRA_BASE_URI, getBaseURI().toString());
        } catch (URISyntaxException e) {
        }
        args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
        args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
        args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());

        DialogFragment dialog = new QueryServerDialogFragment();
        dialog.setArguments(args);
        dialog.show(ft, QueryServerDialogFragment.class.getName());
        break;
    default:
        return false;
    }
    return true;
}

From source file:edu.htl3r.schoolplanner.gui.selectScreen.ViewTypeSpinnerOnItemSelectedListener.java

/**
 * Fires event but does not remember position.
 * @param viewTypeId ID of the ViewType, retrieved via {@link ViewType#getId()}.
 *///from w ww  .  j  a  v  a  2  s.com
public void fireEventByIdAndDontRemember(int viewTypeId) {
    ViewType item = null;
    for (ViewType viewType : list) {
        if (viewType.getId() == viewTypeId) {
            item = viewType;
            break;
        }
    }
    Assert.notNull(item, "ViewType for ID " + viewTypeId + " not found. Unable to continue.");

    Bundle bundle = new Bundle();
    bundle.putSerializable(BundleConstants.SELECTED_VIEW_TYPE, item);
    intent.putExtras(bundle);
    this.parent.startActivity(intent);
}

From source file:com.facebook.android.GraphExplorer.java

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

    mHandler = new Handler();

    setContentView(R.layout.graph_explorer);

    url = BASE_GRAPH_URL; // Base URL

    mInputId = (EditText) findViewById(R.id.inputId);
    mOutput = (TextView) findViewById(R.id.output);
    mSubmitButton = (Button) findViewById(R.id.submitButton);
    mViewURLButton = (Button) findViewById(R.id.viewURLButton);
    mGetPermissionsButton = (Button) findViewById(R.id.accessTokenButton);
    mFieldsConnectionsButton = (Button) findViewById(R.id.fieldsAndConnectionsButton);
    mBackParentButton = (Button) findViewById(R.id.backParentButton);

    mScrollView = (ScrollView) findViewById(R.id.ScrollView01);

    mTextDeleteButton = (Button) findViewById(R.id.textDeleteButton);
    mMeButton = (Button) findViewById(R.id.meButton);
    if (Utility.mFacebook.isSessionValid()) {
        mMeButton.setVisibility(View.VISIBLE);
    }//from   w ww  .j a  v  a2 s  .c o  m

    params = new Bundle();
    mSubmitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mInputId.getWindowToken(), 0);

            // Prepare the URL to be shown on 'View URL' click action. This
            // is not used by the SDK
            url = BASE_GRAPH_URL; // Base URL

            /*
             * Source Tag: graph_explorer
             */
            rootString = mInputId.getText().toString();
            if (!TextUtils.isEmpty(rootString)) {
                dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.please_wait), true,
                        true);
                params.putString("metadata", "1");
                Utility.mAsyncRunner.request(rootString, params, new graphApiRequestListener());
                url += "/" + rootString; // Relative Path provided by you
            }

        }
    });

    mViewURLButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setText(url);
            Linkify.addLinks(mOutput, Linkify.WEB_URLS);
        }
    });

    mGetPermissionsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Utility.mFacebook.isSessionValid()) {
                dialog = ProgressDialog.show(GraphExplorer.this, "",
                        getString(R.string.fetching_current_permissions), true, true);
                Bundle params = new Bundle();
                params.putString("access_token", Utility.mFacebook.getAccessToken());
                Utility.mAsyncRunner.request("me/permissions", params, new permissionsRequestListener());
            } else {
                new PermissionsDialog(GraphExplorer.this).show();
            }
        }
    });

    mFieldsConnectionsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (metadataObject == null) {
                makeToast("No fields, connections availalbe for this object.");
            } else {
                new FieldsConnectionsDialog(GraphExplorer.this, metadataObject).show();
            }
        }
    });

    mTextDeleteButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            url = BASE_GRAPH_URL; // Base URL
            mParentObjectId = "";
            mInputId.setText("");
            params.clear();
            metadataObject = null;
            setText("");
            mBackParentButton.setVisibility(View.INVISIBLE);
        }
    });

    mMeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mInputId.setText("me");
            mSubmitButton.performClick();
        }
    });

    mBackParentButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mInputId.setText(mParentObjectId);
            mParentObjectId = "";
            mSubmitButton.performClick();
        }
    });
}

From source file:com.facebook.login.LoginMethodHandler.java

protected void logWebLoginCompleted(String e2e) {
    String applicationId = loginClient.getPendingRequest().getApplicationId();
    AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(loginClient.getActivity(), applicationId);

    Bundle parameters = new Bundle();
    parameters.putString(AnalyticsEvents.PARAMETER_WEB_LOGIN_E2E, e2e);
    parameters.putLong(AnalyticsEvents.PARAMETER_WEB_LOGIN_SWITCHBACK_TIME, System.currentTimeMillis());
    parameters.putString(AnalyticsEvents.PARAMETER_APP_ID, applicationId);

    appEventsLogger.logSdkEvent(AnalyticsEvents.EVENT_WEB_LOGIN_COMPLETE, null, parameters);
}

From source file:com.facebook.android.Example.java

/** Called when the activity is first created. */
@Override/*ww  w .  java 2 s. c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (APP_ID == null) {
        Util.showAlert(this, "Warning",
                "Facebook Applicaton ID must be " + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);
    mLoginButton = (LoginButton) findViewById(R.id.login);
    mText = (TextView) Example.this.findViewById(R.id.txt);
    mRequestButton = (Button) findViewById(R.id.requestButton);
    mPostButton = (Button) findViewById(R.id.postButton);
    mDeleteButton = (Button) findViewById(R.id.deletePostButton);
    mUploadButton = (Button) findViewById(R.id.uploadButton);

    mFacebook = new Facebook(APP_ID);
    mAsyncRunner = new AsyncFacebookRunner(mFacebook);

    SessionStore.restore(mFacebook, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());
    mLoginButton.init(this, mFacebook);

    mRequestButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mAsyncRunner.request("me", new SampleRequestListener());
        }
    });
    mRequestButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE);

    mUploadButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Bundle params = new Bundle();
            params.putString("method", "photos.upload");

            URL uploadFileUrl = null;
            try {
                uploadFileUrl = new URL("http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            try {
                HttpURLConnection conn = (HttpURLConnection) uploadFileUrl.openConnection();
                conn.setDoInput(true);
                conn.connect();
                int length = conn.getContentLength();

                byte[] imgData = new byte[length];
                InputStream is = conn.getInputStream();
                is.read(imgData);
                params.putByteArray("picture", imgData);

            } catch (IOException e) {
                e.printStackTrace();
            }

            mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
        }
    });
    mUploadButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE);

    mPostButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mFacebook.dialog(Example.this, "feed", new SampleDialogListener());
        }
    });
    mPostButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE);
}

From source file:de.elanev.studip.android.app.frontend.forums.ForumEntryFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (isAdded()) {
        switch (item.getItemId()) {
        case android.R.id.home:
            getActivity().onBackPressed();

            return true;
        case R.id.forum_area_add:
            Bundle args = new Bundle();
            args.putString(ForumEntry.ID, mEntryId);
            args.putSerializable(ForumEntryComposeFragment.ENTRY_TYPE,
                    ForumEntryComposeFragment.EntryType.REPLY_ENTRY);

            Intent intent = new Intent(getActivity(), ForumEntryComposeActivity.class);
            intent.putExtras(args);/*from  ww w  .j  a  v a2  s .co m*/
            startActivityForResult(intent, CREATE_ENTRY);

            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
    return true;
}

From source file:com.familygraph.android.Example.java

/** Called when the activity is first created. */
@Override/*from  w  w  w  .  j  a va  2s  .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (CLIENT_ID == null) {
        Util.showAlert(this, "Warning", "FamilyGraph Applicaton ID must be "
                + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);
    mLoginButton = (LoginButton) findViewById(R.id.loginButton);
    mText = (TextView) Example.this.findViewById(R.id.txt);
    mPersonalPhoto = (ImageView) Example.this.findViewById(R.id.personalPhoto);
    mRequestButton = (Button) findViewById(R.id.requestButton);

    mFamilyGraph = new FamilyGraph(CLIENT_ID);
    mAsyncRunner = new AsyncFamilyGraphRunner(mFamilyGraph);

    SessionStore.restore(mFamilyGraph, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());

    String[] permissions = { "basic", "offline_access" };
    mLoginButton.init(this, mFamilyGraph, permissions);

    mRequestButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mFamilyGraph.isSessionValid()) {
                Bundle params = new Bundle();
                params.putString("fields", "name,picture");
                mAsyncRunner.request("me", params, new SampleRequestListener());
            }
        }
    });
    int visibility = mFamilyGraph.isSessionValid() ? View.VISIBLE : View.INVISIBLE;
    mRequestButton.setVisibility(visibility);
    mPersonalPhoto.setVisibility(View.INVISIBLE);
}

From source file:com.facebook.unity.UnityParams.java

public Bundle getStringParams() {
    Bundle result = new Bundle();
    Iterator<?> keys = json.keys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        try {/*from ww w.  j  a  v a 2 s .co  m*/
            String value = json.getString(key);
            if (value != null) {
                result.putString(key, value);
            }
        } catch (JSONException e) {
        }
    }
    return result;
}

From source file:com.tangrainc.inappbilling.InAppBillingHelper.java

public ListenableFuture<JSONObject[]> getProducts() {
    return _executor.submit(new Callable<JSONObject[]>() {
        @Override/*from  w w  w . ja va  2 s  .c  om*/
        public JSONObject[] call() throws Exception {
            // Wait for the service to be initialized (if call too soon after constructor)
            int loop = 0;
            while (_service == null || loop < 20) {
                Thread.sleep(500);
                loop++;
            }
            if (_service == null) {
                throw new Exception(
                        "Billing service could not be connected for 10 secs! May be running on an emulator w/o Google Service?");
            }

            Bundle queryProducts = new Bundle();
            queryProducts.putStringArrayList("ITEM_ID_LIST",
                    new ArrayList<>(Arrays.asList(_productIdentifiers)));

            Bundle productDetails = _service.getSkuDetails(3, _context.getPackageName(), "inapp",
                    queryProducts);
            ArrayList<JSONObject> result = new ArrayList<>();

            int response = productDetails.getInt("RESPONSE_CODE");
            if (response == 0) {
                ArrayList<String> responseList = productDetails.getStringArrayList("DETAILS_LIST");

                for (String thisResponse : responseList) {
                    result.add(new JSONObject(thisResponse));
                }

                return result.toArray(new JSONObject[0]);
            } else {
                throw new Exception("Response from service: " + response);
            }
        }
    });
}

From source file:com.mobli.android.AsyncMobliRunner.java

/**
 * Make a request to the Mobli API without any parameters.
 * //ww w .j  a v a2s  .  c o m
 * See http://developers.mobli.com/documentation
 * 
 * Note that this method is asynchronous and the callback will be invoked in
 * a background thread; operations that affect the UI will need to be posted
 * to the UI thread or an appropriate handler.
 * 
 * @param relativePath
 *            Relative path to resource in the Mobli API, e.g., to fetch
 *            data about the currently logged authenticated user, provide
 *            "me", which will fetch https://api.mobli.com/me
 * @param listener
 *            Callback interface to notify the application when the request
 *            has completed.
 * @param state
 *            An arbitrary object used to identify the request when it
 *            returns to the callback. This has no effect on the request
 *            itself.
 */
public void request(String relativePath, RequestListener listener, final Object state) {
    request(relativePath, new Bundle(), "GET", listener, state);
}