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:de.damdi.fitness.activity.settings.sync.OpenTrainingSyncService.java

protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "onHandleIntent()");

    version = intent.getIntExtra(EXTRA_VERSION_CODE, -1);
    host = intent.getStringExtra(EXTRA_HOST);

    mReceiver = intent.getParcelableExtra("receiver");
    String command = intent.getStringExtra("command");
    Bundle b = new Bundle();
    if (command.equals("query")) {
        try {//from www. j av  a2  s . c  om

            // set up REST-Client
            mClient = new RestClient(host, port, "https", version);

            // download and parse the exercises
            ArrayList<ExerciseType> allExercises = downloadAndParseExercises();

            // add data to bundle
            b.putSerializable("all_exercises", allExercises);

            mReceiver.send(STATUS_FINISHED, b);
        } catch (Exception e) {
            Log.e(TAG, "Error, could not get exercises from server: " + e.toString(), e);
            b.putString(Intent.EXTRA_TEXT, e.toString());
            mReceiver.send(STATUS_ERROR, b);
        }
    }
    this.stopSelf();
}

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

/** Called when the activity is first created. */
@Override//from   w  ww  . ja v a2s  . c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.music_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();
    colorView = new ColorView(getApplicationContext());

    Bundle bundle = getIntent().getExtras();

    music = (Music) bundle.get("song");

    if (music.getTitle().equals("")) {
        this.getMusicAdapter();
    }
    initView();
    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "music_song");
    comment.putInt("itemId", Integer.parseInt(music.getSong_id()));
    comment.putInt("totalComment", Integer.parseInt(music.getTotal_comment()));
    comment.putInt("total_like", Integer.parseInt(music.getTotal_like()));
    comment.putBoolean("no_share", music.isShare());
    comment.putBoolean("is_liked", music.isLiked());
    comment.putBoolean("can_post_comment", music.isCanPostComment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();

}

From source file:com.normalexception.app.rx8club.task.UpdateTask.java

@Override
protected void onPostExecute(Void result) {
    try {//from w  ww  . ja  va 2s.  co m
        mProgressDialog.dismiss();
        mProgressDialog = null;
    } catch (Exception e) {
        Log.w(TAG, e.getMessage());
    }

    String url = HtmlFormUtils.getResponseUrl();

    Bundle args = new Bundle();
    args.putString("link", url);
    args.putString("title", pageTitle);
    args.putString("page", "1");

    // Create new fragment and transaction
    Fragment newFragment = null;
    if (deleteThread) {
        newFragment = new CategoryFragment();
    } else {
        newFragment = ThreadFragment.newInstance();
    }

    FragmentUtils.fragmentTransaction(sourceFragment.getActivity(), newFragment, true, true, args);
}

From source file:com.ymt.demo1.plates.hub.MyHubFragment.java

public static MyHubFragment getInstance(String myHubItemType, HubReplyPostCountGetter countGetter) {
    MyHubFragment.countGetter = countGetter;

    MyHubFragment fragment = new MyHubFragment();
    Bundle bundle = new Bundle();
    bundle.putString("type", myHubItemType);
    fragment.setArguments(bundle);/*  w  w w . j  a v a2  s .  c o  m*/
    return fragment;
}

From source file:dtu.ds.warnme.app.activity.MainActivity.java

@Override
public void onApproachingEvent(Event event) {
    if (warningDialog != null && event.equals(warningDialog.getEvent())) {
        return;//from  w  ww.  ja  va2 s.c om
    }

    if (alreadyWarned.contains(event)) {
        return;
    }
    alreadyWarned.add(event);

    if (warningDialog != null) {
        warningDialog.dismiss();
    }

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag(LoginDialog.class.getName());
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    Bundle args = new Bundle();
    args.putSerializable(KEY_EVENT, event);

    warningDialog = new WarningDialog();
    warningDialog.setEvent(event);
    warningDialog.setArguments(args);
    warningDialog.show(ft, WarningDialog.class.getName());
}

From source file:com.amaze.carbonfilemanager.services.ExtractService.java

@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
    Bundle b = new Bundle();
    String file = intent.getStringExtra(KEY_PATH_ZIP);
    String extractPath = intent.getStringExtra(KEY_PATH_EXTRACT);

    if (extractPath != null) {
        // a custom dynamic path to extract files to
        epath = extractPath;/*ww w .j a  va 2s.co m*/
    } else {

        epath = PreferenceManager.getDefaultSharedPreferences(this).getString(KEY_PATH_EXTRACT, file);
    }
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    entries = intent.getStringArrayListExtra(KEY_ENTRIES_ZIP);

    b.putString(KEY_PATH_ZIP, file);

    totalSize = getTotalSize(file);
    progressHandler = new ProgressHandler(1, totalSize);

    progressHandler.setProgressListener(new ProgressHandler.ProgressListener() {
        @Override
        public void onProgressed(String fileName, int sourceFiles, int sourceProgress, long totalSize,
                long writtenSize, int speed) {
            publishResults(startId, fileName, sourceFiles, sourceProgress, totalSize, writtenSize, speed,
                    false);
        }
    });

    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(cd);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.extracting))
            .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_zip_box_grey600_36dp);
    startForeground(Integer.parseInt("123" + startId), mBuilder.build());

    new DoWork().execute(b);
    return START_STICKY;
}

From source file:com.battlelancer.seriesguide.api.Action.java

/**
 * Serializes this {@link Action} object to a {@link android.os.Bundle} representation.
 *///from  w w w.j  a v  a2s  . c o  m
public Bundle toBundle() {
    Bundle bundle = new Bundle();
    bundle.putString(KEY_TITLE, mTitle);
    bundle.putString(KEY_VIEW_INTENT,
            (mViewIntent != null) ? mViewIntent.toUri(Intent.URI_INTENT_SCHEME) : null);
    bundle.putInt(KEY_ENTITY_IDENTIFIER, mEntityIdentifier);
    return bundle;
}

From source file:com.mikecorrigan.bohrium.pubsub.PubSubClient.java

@Override
public boolean register(final Bundle bundle) {
    Log.v(TAG, "register: bundle=" + Utils.bundleToString(bundle));

    // Create JSON request body.
    JSONObject j = new JSONObject();
    try {//  w w w  .  j  a va 2  s  .  c o m
        j.put("name", bundle.getString(RegistrationClient.APP_NAME));
        j.put("resource", bundle.getString(RegistrationClient.RESOURCE));
        j.put("type", GCM_DEVICE_TYPE);
        j.put("reg_id", bundle.getString(RegistrationClient.REG_ID));
        j.put("dev_id", mDevId);
    } catch (JSONException e) {
        Log.w(TAG, "Registration failure: URI failed=" + e);
        return false;
    }

    ITransaction transaction = mTransactionService.createTransaction("PUT", "device/" + mDevId + "/", j);
    transaction.run();
    if (transaction.getStatusCode() == 200) {
        // Save user ID.
        try {
            JSONObject responseBody = (JSONObject) transaction.getResponseBody();
            mDevice = JSONCodec.fromJson(responseBody);

            mUser = new Bundle();
            mUser.putString("user_id", responseBody.getString("user_id"));

        } catch (JSONException e) {
            Log.e(TAG, "Exception " + e);
            Log.e(TAG, Log.getStackTraceString(e));
        }
    }

    Log.e(TAG, "onRegisterComplete: statusCode=" + transaction.getStatusCode());
    return transaction.getStatusCode() == 200;
}

From source file:com.facebook.AccessTokenTest.java

@Test
public void testCreateFromRefreshFailure() {
    AccessToken accessToken = new AccessToken("a token", "1234", "1000", Utility.arrayList("stream_publish"),
            null, AccessTokenSource.WEB_VIEW, null, null);

    String token = "AnImaginaryTokenValue";

    Bundle bundle = new Bundle();
    bundle.putString("access_token", "AnImaginaryTokenValue");
    bundle.putString("expires_in", "60");

    try {//from w  w w .  java  2s  . c  om
        AccessToken.createFromRefresh(accessToken, bundle);
        fail("Expected exception");
    } catch (FacebookException ex) {
        assertEquals("Invalid token source: " + AccessTokenSource.WEB_VIEW, ex.getMessage());
    }
}