Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

In this page you can find the example usage for android.content Intent getExtras.

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:Main.java

public static float interceptFloatParam(Bundle savedInstanceState, Intent intent, String paramName) {
    float ret = 0;

    if (savedInstanceState != null) {
        ret = savedInstanceState.getFloat(paramName, 0);
    } else {/*from  w w w .java2 s  .  c o  m*/
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getFloat(paramName, 0);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static String interceptStringParam(Bundle savedInstanceState, Intent intent, String paramName) {
    String ret = null;/*  ww w  .  ja  va2  s .  co  m*/

    if (savedInstanceState != null) {
        ret = savedInstanceState.getString(paramName);
    } else {
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getString(paramName);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static double interceptDoubleParam(Bundle savedInstanceState, Intent intent, String paramName) {
    double ret = 0;

    if (savedInstanceState != null) {
        ret = savedInstanceState.getDouble(paramName, 0);
    } else {/* w  w w. j av a  2 s  .  co m*/
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getDouble(paramName, 0);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static byte interceptByteParam(Bundle savedInstanceState, Intent intent, String paramName) {
    byte ret = 0;

    if (savedInstanceState != null) {
        ret = savedInstanceState.getByte(paramName, (byte) 0);
    } else {//from w w  w  .  ja v a2 s.  c  o  m
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getByte(paramName, (byte) 0);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static char interceptCharParam(Bundle savedInstanceState, Intent intent, String paramName) {
    char ret = 0;

    if (savedInstanceState != null) {
        ret = savedInstanceState.getChar(paramName, (char) 0);
    } else {/*from w  w w .j ava 2 s .co  m*/
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getChar(paramName, (char) 0);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static Parcelable interceptParcelableParam(Bundle savedInstanceState, Intent intent, String paramName) {
    Parcelable ret = null;//from w w w  .  j a  va  2  s .co  m

    if (savedInstanceState != null) {
        ret = savedInstanceState.getParcelable(paramName);
    } else {
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getParcelable(paramName);
            }
        }
    }

    return ret;
}

From source file:Main.java

public static boolean interceptBooleanParam(Bundle savedInstanceState, Intent intent, String paramName) {
    boolean ret = false;

    if (savedInstanceState != null) {
        ret = savedInstanceState.getBoolean(paramName, false);
    } else {//from  w  w w.j  av a 2 s . co  m
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getBoolean(paramName, false);
            }
        }
    }

    return ret;
}

From source file:com.parse.ParseAnalytics.java

static String getPushHashFromIntent(Intent intent) {
    String pushData = null;/*from   w ww. jav a2  s  .c  om*/
    if (intent != null && intent.getExtras() != null) {
        pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA);
    }
    if (pushData == null) {
        return null;
    }
    String pushHash = null;
    try {
        JSONObject payload = new JSONObject(pushData);
        pushHash = payload.optString("push_hash");
    } catch (JSONException e) {
        PLog.e(TAG, "Failed to parse push data: " + e.getMessage());
    }
    return pushHash;
}

From source file:Main.java

/**
 * Converts an intent into a {@link Bundle} suitable for use as fragment
 * arguments./*w  w  w .  j ava2  s.co m*/
 */
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", data);
    }

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

    return arguments;
}

From source file:Main.java

/**
 * Inverse operation of {@link #fragmentArgumentsToIntent(Bundle)}.
 *//*  ww w  . ja  v  a 2  s .  co  m*/
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;
}