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:com.groupme.sdk.util.HttpUtilsTest.java

public void testSetHttpHeaders() {
    MockHttpClient client = new MockHttpClient();
    client.setContext(getContext());/*  w w  w. j  a  v a2 s  .  c om*/
    String response = null;

    try {
        Bundle headers = new Bundle();
        headers.putString("Authorization", "Let me in");

        response = HttpUtils.openUrl(client, OK_REQUEST, HttpUtils.METHOD_GET, null, null, headers);
    } catch (HttpResponseException e) {
        fail("Received a response exception: " + e.toString());
    }

    Header[] headers = client.getRequest().getHeaders("Authorization");

    if (headers != null && headers.length > 0) {
        assertEquals("Let me in", headers[0].getValue());
    } else {
        fail("Headers are not properly set");
    }

    if (response == null) {
        fail("Unexpected empty response");
    }
}

From source file:com.hyrt.cnp.account.AccountAuthenticator.java

/**
 * The user has requested to add a new account to the system. We return an
 * intent that will launch our login screen if the user has not logged in
 * yet, otherwise our activity will just pass the user's credentials on to
 * the account manager./*from  w w  w  .j a v a2 s.c o  m*/
 */
@Override
public Bundle addAccount(final AccountAuthenticatorResponse response, final String accountType,
        final String authTokenType, final String[] requiredFeatures, final Bundle options)
        throws NetworkErrorException {
    final Intent intent = new Intent(context, LoginActivity.class);
    intent.putExtra(PARAM_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(KEY_INTENT, intent);
    return bundle;
}

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

private void sendResult(Intent intent, int statusCode, String result) {
    Bundle extras = intent.getExtras();//from   ww w.j a v a 2 s . c o  m
    Messenger messenger = (Messenger) extras.get(MESSENGER);
    if (messenger != null) {
        Message msg = Message.obtain();
        Bundle data = new Bundle();
        data.putInt(STATUS_CODE, statusCode);
        data.putString(RESULT, result);
        msg.setData(data);
        try {
            messenger.send(msg);
        } catch (android.os.RemoteException e1) {
            Log.w(getClass().getName(), "Exception sending message", e1);
        }
    }
}

From source file:com.facebook.TestUserManagerTests.java

private int countTestUsers() {
    TestUserManager testUserManager = createTestUserManager();

    String appAccessToken = testUserManager.getAppAccessToken();
    assertNotNull(appAccessToken);/*  w  w  w  .j  a va2  s  .  c o m*/

    Bundle parameters = new Bundle();

    parameters.putString("access_token", appAccessToken);
    parameters.putString("fields", "id");

    GraphRequest requestTestUsers = new GraphRequest(null, "app/accounts/test-users", parameters, null);

    GraphResponse response = requestTestUsers.executeAndWait();

    JSONArray data = response.getJSONObject().optJSONArray("data");
    return data.length();
}

From source file:org.ohmage.auth.Authenticator.java

@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) {
    // TODO: decide if we should allow more than one account, and if not, make it clear to the
    // user that they need to logout and login with a new account

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:com.hua.goddess.activites.RegisterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_register);
    pd = new ProgressDialog(RegisterActivity.this);
    // DeviceUuidFactory uuid = new DeviceUuidFactory(this);
    // uid = uuid.getDeviceUuid().toString();

    emailEditText = (EditText) findViewById(R.id.email);
    emailEditText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);// ??
    userNameEditText = (EditText) findViewById(R.id.username);
    passwordEditText = (EditText) findViewById(R.id.password);
    confirmPwdEditText = (EditText) findViewById(R.id.confirm_password);

    rg = (RadioGroup) findViewById(R.id.sex);
    b1 = (RadioButton) findViewById(R.id.male);
    b2 = (RadioButton) findViewById(R.id.female);
    wh = new WsRequestHelper(new WsRequestHelper.InterfaceCallBack() {
        @Override/*from www . ja va2 s  . c  o  m*/
        public void RequestCallBack(Object result) {
            // TODO Auto-generated method stub
            pd.dismiss();
            // Toast.makeText(RegisterActivity.this, result.toString(),
            // Toast.LENGTH_SHORT).show();
            if (result.toString().equals("?")) {
                Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("username", userNameEditText.getText().toString().trim());

                intent.putExtras(bundle);
                setResult(100, intent);
                finish();
            }

        }
    });

    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // TODO Auto-generated method stub
            if (checkedId == b1.getId()) {
                sex = "1";
                Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show();
            }
            if (checkedId == b2.getId()) {
                sex = "2";
                Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show();
            }

        }

    });
}

From source file:com.brodev.socialapp.view.VideoPlay.java

/** Called when the activity is first created. */
@Override/*from   w  ww. ja  v  a 2s  . c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_player);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    user = (User) getApplication().getApplicationContext();
    phraseManager = new PhraseManager(getApplicationContext());
    colorView = new ColorView(getApplicationContext());

    Bundle bundle = getIntent().getExtras();

    video = (Video) bundle.get("video");
    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "video.video"));
    if (video.getTime_stamp().equals("0")) {
        this.getVideoAdapter();
    }

    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "video");
    comment.putInt("itemId", video.getVideo_id());
    comment.putInt("totalComment", video.getTotal_comment());
    comment.putInt("total_like", video.getTotal_like());
    comment.putBoolean("is_liked", video.getIs_like());
    comment.putBoolean("can_post_comment", video.getCan_post_comment());
    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();

}

From source file:com.facebook.BatchRequestTests.java

@LargeTest
public void testExecuteBatchRequestsPathEncoding() throws IOException {
    // ensures that paths passed to batch requests are encoded properly before
    // we send it up to the server

    final AccessToken accessToken = getAccessTokenForSharedUser();

    Bundle parameters = new Bundle();
    parameters.putString("fields", "location");

    GraphRequest request1 = new GraphRequest(accessToken, "TourEiffel", parameters, null);
    request1.setBatchEntryName("eiffel");
    request1.setBatchEntryOmitResultOnSuccess(false);
    GraphRequest request2 = new GraphRequest(accessToken, "{result=eiffel:$.id}", parameters, null);

    List<GraphResponse> responses = GraphRequest.executeBatchAndWait(request1, request2);
    assertEquals(2, responses.size());/*  www.  j av a  2 s . c o m*/
    assertTrue(responses.get(0).getError() == null);
    assertTrue(responses.get(1).getError() == null);

    JSONObject eiffelTower1 = responses.get(0).getJSONObject();
    JSONObject eiffelTower2 = responses.get(1).getJSONObject();
    assertTrue(eiffelTower1 != null);
    assertTrue(eiffelTower2 != null);

    assertEquals("Paris", eiffelTower1.optJSONObject("location").optString("city"));
    assertEquals("Paris", eiffelTower2.optJSONObject("location").optString("city"));
}

From source file:com.gimranov.zandy.app.LookupActivity.java

/**
 * Implementation of the OnClickListener interface, to handle button events.
 * //from   ww  w .  jav  a2s . c  o m
 * Note: When adding a button, it needs to be added here, but the
 * ClickListener needs to be set in the main onCreate(..) as well.
 */
public void onClick(View v) {
    Log.d(TAG, "Click on: " + v.getId());
    if (v.getId() == R.id.lookupButton) {
        Log.d(TAG, "Trying to start search activity");
        TextView field = (TextView) findViewById(R.id.identifier);
        Editable fieldContents = (Editable) field.getText();
        Bundle b = new Bundle();
        b.putString("mode", "isbn");
        b.putString("identifier", fieldContents.toString());
        this.b = b;
        showDialog(DIALOG_PROGRESS);
    } else {
        Log.w(TAG, "Uncaught click on: " + v.getId());
    }
}