best practice to send data using the intention of another activity?

advertisements

i created a listview with video thumbnail i already know how to use the media info and how to list it.

my question is what is the best programming practice for sending media info like String, Integer, or even a Bitmap?

Parcelable or Seralizeable or just ID of it from cursor?

i want to maximize my speed performance of my apps,

they say parce is good, some seializeable but others programers say its best to just only pass the ID or the position for cursor than using objects etc..

which is good from these 3?

  1. Parcelable

  2. Seralizeable

  3. just ID cursor etc, or position of the list?

example:

ACTIVITY A

@Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        // MOVE TO CLICK POSITION
        videoCursor.moveToPosition(position);

        // GET THE COLUMN INDEX OF THE FILEPATH, TITLE, ARTIST, DURATION
        videoPathColumnIndex = videoCursor
                .getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
        videoTitleColumnIndex = videoCursor
                .getColumnIndexOrThrow(MediaStore.Video.Media.TITLE);
        videoArtistColumnIndex = videoCursor
                .getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST);
        videoDurationColumnIndex = videoCursor
                .getColumnIndexOrThrow(MediaStore.Video.Media.DURATION);
        videoImageColumnIndex = videoCursor.getInt(videoCursor
                .getColumnIndexOrThrow(MediaStore.Video.Media._ID));

        // LIST THE DATA FROM STRING OF THE COLUMNINDEX OF THE VIDEOCURSOR POSITION
        videoPath = videoCursor.getString(videoPathColumnIndex);
        videoTitle = videoCursor.getString(videoTitleColumnIndex);
        videoArtist = videoCursor.getString(videoArtistColumnIndex);
        videoDuration = videoCursor.getString(videoDurationColumnIndex);

        // START THE NEW INTENT ACTIVITY AND PASS SOME MEDIA INFO
        videoIntent = new Intent(this, Play.class);
        videoIntent.putExtra(KEY_VIDEO_PATH, videoPath);
        videoIntent.putExtra(KEY_VIDEO_TITLE, videoTitle);
        videoIntent.putExtra(KEY_VIDEO_ARTIST, videoArtist);
        videoIntent.putExtra(KEY_VIDEO_DURATION, videoDuration);

        startActivity(videoIntent);
    }

this my code i can send the title, the path, the artist, i can also play the video through path, if i want to send the VideoThumbnail using the id only how to use putExtra and send the ID and get from ACTIVITY B and used the data?


Use the least you can, also because it makes it clearer what you are actually sending. If the data you want to send is covered by one of the Bundle methods, use that. For example, if you have a String use putString. If you have an enum or an ID you can use in your new Activity or Fragment, use putInt (with ordinal() on the enum).

Only if you have e.g. a custom object there's really a need for a Parcelable object. Some Android specific classes already implement the Parcelable interface. I would avoid Serializable since it's slower and you usually have no real control over the serialization.