Convert a fragment arguments bundle into an intent. - Android android.os

Android examples for android.os:Bundle

Description

Convert a fragment arguments bundle into an intent.

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.  c  om
     * Convert a fragment arguments bundle into an intent.
     */
    public static Intent fragmentArgumentsToIntent(Bundle arguments) {
        Intent intent = new Intent();
        if (arguments == null) {
            return intent;
        }

        final Uri data = arguments.getParcelable(URI_KEY);
        if (data != null) {
            intent.setData(data);
        }

        intent.putExtras(arguments);
        intent.removeExtra(URI_KEY);
        return intent;
    }

}

Related Tutorials