intercept Float Param from Bundle - Android android.os

Android examples for android.os:Bundle

Description

intercept Float Param from Bundle

Demo Code

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;

public class Main{

    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  . ja va  2  s.  c om*/
            if (intent != null) {
                Bundle incomming = intent.getExtras();
                if (incomming != null) {
                    ret = incomming.getFloat(paramName, 0);
                }
            }
        }

        return ret;
    }

}

Related Tutorials