Example usage for android.content Intent getByteExtra

List of usage examples for android.content Intent getByteExtra

Introduction

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

Prototype

public byte getByteExtra(String name, byte defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

/**
 * Gets the player.//  w ww  .j a v  a2  s  .  com
 * 
 * @param intent
 *            the intent
 * 
 * @return the player
 */
public static byte getPlayer(Intent intent) {
    return intent.getByteExtra(PLAYER_KEY, (byte) 0);
}

From source file:Main.java

public static byte getByteExtra(Intent intent, String name, byte defaultValue) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return defaultValue;
    return intent.getByteExtra(name, defaultValue);
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindIntentExtra(Object receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);/*from w  w w. ja v  a2  s.c o m*/
        IntentExtra intentExtra = field.getAnnotation(IntentExtra.class);
        if (intentExtra != null) {
            try {
                Intent intent = null;
                if (receiver instanceof Activity) {
                    intent = ((Activity) receiver).getIntent();
                } else if (receiver instanceof Fragment) {
                    intent = ((Fragment) receiver).getActivity().getIntent();
                }
                if (intent != null) {
                    Class<?> type = field.getType();
                    if (type == Boolean.class || type == boolean.class) {
                        field.set(receiver, intent.getBooleanExtra(intentExtra.value(), false));
                    } else if (type == Byte.class || type == byte.class) {
                        field.set(receiver, intent.getByteExtra(intentExtra.value(), (byte) 0));
                    } else if (type == Character.class || type == char.class) {
                        field.set(receiver, intent.getCharExtra(intentExtra.value(), '\u0000'));
                    } else if (type == Double.class || type == double.class) {
                        field.set(receiver, intent.getDoubleExtra(intentExtra.value(), 0.0d));
                    } else if (type == Float.class || type == float.class) {
                        field.set(receiver, intent.getFloatExtra(intentExtra.value(), 0.0f));
                    } else if (type == Integer.class || type == int.class) {
                        field.set(receiver, intent.getIntExtra(intentExtra.value(), 0));
                    } else if (type == Long.class || type == long.class) {
                        field.set(receiver, intent.getLongExtra(intentExtra.value(), 0L));
                    } else if (type == Short.class || type == short.class) {
                        field.set(receiver, intent.getShortExtra(intentExtra.value(), (short) 0));
                    } else if (type == String.class) {
                        field.set(receiver, intent.getStringExtra(intentExtra.value()));
                    } else if (type == Boolean[].class || type == boolean[].class) {
                        field.set(receiver, intent.getBooleanArrayExtra(intentExtra.value()));
                    } else if (type == Byte[].class || type == byte[].class) {
                        field.set(receiver, intent.getByteArrayExtra(intentExtra.value()));
                    } else if (type == Character[].class || type == char[].class) {
                        field.set(receiver, intent.getCharArrayExtra(intentExtra.value()));
                    } else if (type == Double[].class || type == double[].class) {
                        field.set(receiver, intent.getDoubleArrayExtra(intentExtra.value()));
                    } else if (type == Float[].class || type == float[].class) {
                        field.set(receiver, intent.getFloatArrayExtra(intentExtra.value()));
                    } else if (type == Integer[].class || type == int[].class) {
                        field.set(receiver, intent.getIntArrayExtra(intentExtra.value()));
                    } else if (type == Long[].class || type == long[].class) {
                        field.set(receiver, intent.getLongArrayExtra(intentExtra.value()));
                    } else if (type == Short[].class || type == short[].class) {
                        field.set(receiver, intent.getShortArrayExtra(intentExtra.value()));
                    } else if (type == String[].class) {
                        field.set(receiver, intent.getStringArrayExtra(intentExtra.value()));
                    } else if (Serializable.class.isAssignableFrom(type)) {
                        field.set(receiver, intent.getSerializableExtra(intentExtra.value()));
                    } else if (type == Bundle.class) {
                        field.set(receiver, intent.getBundleExtra(intentExtra.value()));
                    }
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:it.geosolutions.android.map.MapsActivity.java

/**
 * center the map on the markers//from   w  w  w  .  ja  va 2 s .  c  om
 */
public void centerMapFile() {
    MarkerOverlay mo = mapView.getMarkerOverlay();
    MapPosition mp = mapView.getMapViewPosition().getMapPosition();

    Intent intent = getIntent();
    if (intent.hasExtra(PARAMETERS.LAT) && intent.hasExtra(PARAMETERS.LON)
            && intent.hasExtra(PARAMETERS.ZOOM_LEVEL)) {
        double lat = intent.getDoubleExtra(PARAMETERS.LAT, 43.68411);
        double lon = intent.getDoubleExtra(PARAMETERS.LON, 10.84899);
        byte zoom_level = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL, (byte) 13);
        /*ArrayList<MarkerDTO> list_marker = intent.getParcelableArrayListExtra(PARAMETERS.MARKERS);
        MarkerDTO mark = list_marker.get(0);*/
        new MapPosition(new GeoPoint(lat, lon), zoom_level);
        mapView.getMapViewPosition().setMapPosition(mp);
    } else {
        if (mo != null) {
            //support only one marker
            MapPosition newMp = MarkerUtils.getMarkerCenterZoom(mo.getMarkers(), mp);
            if (newMp != null)
                mapView.getMapViewPosition().setMapPosition(newMp);
        }
    }
}

From source file:it.geosolutions.geocollect.android.map.GeoCollectMapActivity.java

/**
 * center the map on the markers/*from ww  w  .  j av  a2 s . c  om*/
 */
public void centerMapFile() {
    MarkerOverlay mo = mapView.getMarkerOverlay();
    MapPosition mp = mapView.getMapViewPosition().getMapPosition();

    Intent intent = getIntent();
    if (intent.hasExtra(PARAMETERS.LAT) && intent.hasExtra(PARAMETERS.LON)
            && intent.hasExtra(PARAMETERS.ZOOM_LEVEL)) {
        double lat = intent.getDoubleExtra(PARAMETERS.LAT, 43.68411);
        double lon = intent.getDoubleExtra(PARAMETERS.LON, 10.84899);
        byte zoom_level = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL, (byte) 13);
        byte zoom_level_min = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MIN, (byte) 0);
        byte zoom_level_max = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MAX, (byte) 30);
        /*
         * ArrayList<MarkerDTO> list_marker = intent.getParcelableArrayListExtra(PARAMETERS.MARKERS); MarkerDTO mark = list_marker.get(0);
         */
        mp = new MapPosition(new GeoPoint(lat, lon), zoom_level);
        mapView.getMapViewPosition().setMapPosition(mp);
        mapView.getMapZoomControls().setZoomLevelMin(zoom_level_min);
        mapView.getMapZoomControls().setZoomLevelMax(zoom_level_max);
    } else {
        if (mo != null) {
            // support only one marker
            MapPosition newMp = MarkerUtils.getMarkerCenterZoom(mo.getMarkers(), mp);
            if (newMp != null) {
                mapView.getMapViewPosition().setMapPosition(newMp);
            }
        }
    }
}