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:br.ufsc.das.gtscted.shibbauth.SPSelectionActivity.java

/** Called when the activity is first created. */
@Override/*ww w .j a v a 2s.co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sp_selection);

    nextButton = (Button) findViewById(R.id.nextButton);
    exitButton = (Button) findViewById(R.id.exitButton);
    spEditText = (EditText) findViewById(R.id.spUrlEditText);

    //SP para testes   
    spEditText.setText("https://sp.ufrgs.br/chimarrao/");

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String serviceUrl = spEditText.getText().toString();

            try {
                Connection connection = new Connection();
                String[] getResponseAndEndpoint = connection.httpGetWithEndpoint(serviceUrl);
                String wayfLocation = getResponseAndEndpoint[0];
                String responseBody = getResponseAndEndpoint[1];

                Bundle bundle = new Bundle();
                bundle.putString("html_source", responseBody);
                bundle.putString("wayf_location", wayfLocation);
                bundle.putSerializable("cookie", connection.getSerializableCookie(0));

                Intent newIntent = new Intent(SPSelectionActivity.this, ShibAuthenticationActivity.class);
                newIntent.putExtras(bundle);
                startActivity(newIntent);

            } catch (KeyManagementException e) {
                String message = "KeyManagementException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (NoSuchAlgorithmException e) {
                String message = "NoSuchAlgorithmException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (KeyStoreException e) {
                String message = "KeyStoreException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (UnrecoverableKeyException e) {
                String message = "UnrecoverableKeyException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (ClientProtocolException e) {
                String message = "ClientProtocolException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (IOException e) {
                String message = "IOException";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            } catch (Exception e) {
                String message = "Exception";
                Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
                toast.show();
            }
        }
    });

    exitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);
    setTitle(getText(R.string.app_name) + " - " + getText(R.string.screenshot));

    mImageView = new ImageView(this);
    setContentView(mImageView);/*from  w ww.j a  va 2  s  .co m*/
    mImageView.setBackgroundColor(Color.BLACK);

    Bundle extras = getIntent().getExtras();

    if (extras == null) {
        extras = new Bundle();
    }

    mType = extras.getInt(KEY_TYPE, TYPE_ALL);
    mFormat = extras.getInt(KEY_FORMAT, FORMAT_PNG);
    mSize = extras.getInt(KEY_SIZE, 720);
    mFilename = extras.getString(KEY_FILENAME);

    reload();
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();

    setContentView(R.layout.upload_photo_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mViewPhotoButton = (Button) findViewById(R.id.view_photo_button);
    mTagPhotoButton = (Button) findViewById(R.id.tag_photo_button);
    mUploadedPhoto = (ImageView) findViewById(R.id.uploadedPhoto);

    JSONObject json;/*w  w  w.  java2 s .  c  om*/
    try {
        json = Util.parseJson(response);
        final String photo_id = json.getString("id");
        this.photo_id = photo_id;

        mOutput.setText(json.toString(2));
        mUsefulTip.setText(activity.getString(R.string.photo_tip));
        Linkify.addLinks(mUsefulTip, Linkify.WEB_URLS);

        mViewPhotoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (hidePhoto) {
                    mViewPhotoButton.setText(R.string.view_photo);
                    hidePhoto = false;
                    mUploadedPhoto.setImageBitmap(null);
                } else {
                    hidePhoto = true;
                    mViewPhotoButton.setText(R.string.hide_photo);
                    /*
                     * Source tag: view_photo_tag
                     */
                    Bundle params = new Bundle();
                    params.putString("fields", "picture");
                    dialog = ProgressDialog.show(activity, "", activity.getString(R.string.please_wait), true,
                            true);
                    dialog.show();
                    Utility.mAsyncRunner.request(photo_id, params, new ViewPhotoRequestListener());
                }
            }
        });
        mTagPhotoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*
                 * Source tag: tag_photo_tag
                 */
                setTag();
            }
        });
    } catch (JSONException e) {
        setText(activity.getString(R.string.exception) + e.getMessage());
    } catch (FacebookError e) {
        setText(activity.getString(R.string.facebook_error) + e.getMessage());
    }
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * @param buddyId   the buddyId to whom the image should be sent
 * @param name      the name of the chat
 * @param imageUris the imageUris representing the images that are added
 * @return A new instance of fragment SendImageFragment.
 *///from www  . ja va2s  .  c om
public static SendImageFragment newInstance(String buddyId, String name, Parcelable... imageUris) {
    SendImageFragment fragment = new SendImageFragment();
    Bundle args = new Bundle();
    args.putParcelableArray(Constants.IMAGE_URI, imageUris);
    args.putString(Constants.BUDDY_ID, buddyId);
    args.putString(Constants.CHAT_NAME, name);
    fragment.setArguments(args);
    return fragment;
}

From source file:de.teunito.android.cyclelife.RennradNewsShare.java

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

    Bundle data = new Bundle();
    data = getIntent().getExtras();
    trackId = data.getLong("trackId");

    mTrackDb = TrackDb.getInstance(getApplicationContext());

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    APIKey = prefs.getString(Preferences.RENNRADNEWS_API_KEY, "");
    bikeId = prefs.getString(Preferences.RENNRADNEWS_BIKE_ID, "");
    weight = prefs.getString(Preferences.WEIGHT, "");

    tv = (TextView) findViewById(R.id.rnsShareTitle);
    tv.setText("Share your track " + trackId + " to rennrad-news.de community!");
    bt = (Button) findViewById(R.id.rnsShareBtn);
    etTemp = (EditText) findViewById(R.id.rnsShareTemp);
    spSports = (Spinner) findViewById(R.id.rnsShareSports);
    spZone = (Spinner) findViewById(R.id.rnsShareZone);
    spWeather = (Spinner) findViewById(R.id.rnsShareWeather);
    spMood = (Spinner) findViewById(R.id.rnsShareMood);

    sportsAdapter = ArrayAdapter.createFromResource(this, R.array.sports, android.R.layout.simple_spinner_item);
    zoneAdapter = ArrayAdapter.createFromResource(this, R.array.zone, android.R.layout.simple_spinner_item);
    weatherAdapter = ArrayAdapter.createFromResource(this, R.array.weather,
            android.R.layout.simple_spinner_item);
    moodAdapter = ArrayAdapter.createFromResource(this, R.array.mood, android.R.layout.simple_spinner_item);

    sportsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    zoneAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    weatherAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    moodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spSports.setAdapter(sportsAdapter);
    spZone.setAdapter(zoneAdapter);
    spWeather.setAdapter(weatherAdapter);
    spMood.setAdapter(moodAdapter);

    bt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog = ProgressDialog.show(RennradNewsShare.this, "", "Uploading. Please wait...", true);

            sportsID = String.valueOf(spSports.getSelectedItemPosition() + 1);
            zoneId = String.valueOf(spZone.getSelectedItemPosition() + 1);
            weatherId = String.valueOf(spWeather.getSelectedItemPosition() + 1);
            moodId = String.valueOf(spMood.getSelectedItemPosition() + 1);
            temperature = etTemp.getText().toString();

            // execute is a blocking call, it's best to call this code in a thread separate from the ui's
            uploadThread.start();
        }
    });

    handler = new Handler() {
        public void handleMessage(Message msg) {
            String result = msg.getData().getString("result");
            if (result.contains("success")) {
                Toast.makeText(getApplicationContext(), "Uploaded: " + result, Toast.LENGTH_LONG).show();
                finish();
            } else
                Toast.makeText(getApplicationContext(), "Error: " + result, Toast.LENGTH_LONG).show();
        }
    };

    if (APIKey.length() < 20) {
        AlertDialog.Builder builder = new AlertDialog.Builder(RennradNewsShare.this);
        builder.setMessage("Please enter first the rennrad-news.de API-key in the Settings!")
                .setCancelable(false).setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        RennradNewsShare.this.finish();
                        startActivity(new Intent(RennradNewsShare.this, Preferences.class));
                    }
                });
        builder.create().show();
    }
}

From source file:com.easy.facebook.android.apicall.RestApi.java

private String setStatusCall(String message, String urlPicture) throws EasyFacebookError {

    Bundle params = new Bundle();
    params.putString("format", "json");
    params.putString("method", "status.set");
    params.putString("access_token", facebook.getAccessToken());

    params.putString("status", message);

    if (urlPicture != null)
        params.putString("picture", urlPicture);

    String jsonResponse = "";

    try {/*from   w ww.  j  a  va2  s  .  c o  m*/

        jsonResponse = Util.openUrl("https://api.facebook.com/restserver.php", "POST", params);

    } catch (MalformedURLException e) {

        throw new EasyFacebookError(e.toString(), "MalformedURLException");
    } catch (IOException e) {

        throw new EasyFacebookError(e.toString(), "IOException");
    }

    return jsonResponse;

}

From source file:edu.stanford.mobisocial.dungbeetle.facebook.FacebookInterfaceActivity.java

/** Called when the activity is first created. */
@Override//from w  w w. j  a v  a 2  s  . co 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 FacebookInterfaceActivity.java");
    }

    setContentView(R.layout.facebook);
    mLoginButton = (LoginButton) findViewById(R.id.login);
    mText = (TextView) FacebookInterfaceActivity.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(FacebookInterfaceActivity.this, "feed", new SampleDialogListener());
        }
    });
    mPostButton.setVisibility(mFacebook.isSessionValid() ? View.VISIBLE : View.INVISIBLE);
}

From source file:com.mercandalli.android.apps.files.file.cloud.FileCloudFragment.java

public static FileCloudFragment newInstance(final int positionInViewPager) {
    final FileCloudFragment fileCloudFragment = new FileCloudFragment();
    final Bundle args = new Bundle();
    args.putInt(ARG_POSITION_IN_VIEW_PAGER, positionInViewPager);
    fileCloudFragment.setArguments(args);
    return fileCloudFragment;
}

From source file:com.granita.contacticloudsync.syncadapter.AccountSettings.java

public static Bundle createBundle(ServerInfo serverInfo) {
    Bundle bundle = new Bundle();
    bundle.putString(KEY_SETTINGS_VERSION, String.valueOf(CURRENT_VERSION));
    bundle.putString(KEY_USERNAME, serverInfo.getUserName());
    bundle.putString(KEY_AUTH_PREEMPTIVE, Boolean.toString(serverInfo.isAuthPreemptive()));
    return bundle;
}

From source file:com.emacs.xpets.utils.Utils.java

public static Bundle extractPropertiesIntoBundle(List<Pet> pets) {
    Bundle bundle = new Bundle();
    int i = 0;/*from   www . j  ava  2 s. c  o m*/
    String[] titles = new String[pets.size()];
    String[] images = new String[pets.size()];
    String[] keys = new String[pets.size()];
    for (Pet p : pets) {
        titles[i] = p.getTitle();
        images[i] = p.getPhoto();
        keys[i] = p.getKey();
        i++;
    }
    bundle.putStringArray("keys", keys);
    bundle.putStringArray("titles", titles);
    bundle.putStringArray("images", images);
    return bundle;
}