Convert intent To Fragment Arguments - Android android.content

Android examples for android.content:Intent

Description

Convert intent To Fragment Arguments

Demo Code

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class Main{

    private static final String URI_KEY = "_uri";
    /**/*from  www  .  j a  v  a  2s. co m*/
     * Inverse operation of {@link #fragmentArgumentsToIntent(Bundle)}.
     */
    public static Bundle intentToFragmentArguments(Intent intent) {
        Bundle arguments = new Bundle();
        if (intent == null) {
            return arguments;
        }

        final Uri data = intent.getData();
        if (data != null) {
            arguments.putParcelable(URI_KEY, data);
        }

        final Bundle extras = intent.getExtras();
        if (extras != null) {
            arguments.putAll(extras);
        }
        return arguments;
    }

}

Related Tutorials