Skip navigation

Monthly Archives: July 2014

For typical Android App with holoEverywhere and Facebook login. When you receive:

. Android is limited to 65535 methods per classes.dex
 You can either remove some methodor use a secondary framework .”

So you can use proguard this is the configuration that finally worked for me:

-dontobfuscate
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

#modify for Facebook
-keepattributes Signature
-keep class com.facebook.model.** { *; }

-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
#Important ActionBar uses reflection methods
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
    <init>(android.app.Activity, int);
}

-dontwarn android.support.**
-dontwarn com.mixpanel.android.**
-dontwarn org.joda.**

-keep class com.actionbarsherlock.**
-keep class org.holoeverywhere.**
-keep class android.support.**
-keep class org.apache.**
-keep class com.commonsware.**

The Elements of Amazon Maps

The Amazon Maps API consists of a core set of classes that combine to provide mapping capabilities in Android applications on the Kindle Fire. The key classes are:

MapActivity – A subclass of the Android Activity class, this provides the base class for activities that need to provide map support. Any activity that needs to work with maps must be derived from this class.
MapView – Provides the canvas onto which the map is drawn.
MapController – Provides an interface for managing an existing map. This class includes capabilities such as setting both the center coordinates of the map and the current zoom level.
ItemizedOverlay – A class specifically designed to overlay information onto a map. For example, an overlay might be used to mark all the locations of the public libraries in a town. A single overlay can contain multiple items, each represented by an OverlayItem instance. An onTap() callback method may be implemented to pop up additional information about a location when tapped by the user.
OverlayItem – Used to represent each item in an ItemizedOverlay. Each item has associated with it a location on the map and an optional image to mark the location.
MyLocationOverlay – A special-purpose overlay designed specifically to display the current location of the device on the map view.
Overlay – A general-purpose overlay class provided primarily to allow transparent effects or content to be placed on top of the map.

You can use the Original documentation from gMaps V1: https://developers.google.com/maps/documentation/android/v1/hello-mapview

IMPORTANT LINKS/NOTEs:

  • You need to create you MD5 certificate into your free (thx) Amazon developer account to enable the maps on your app.
  • You will need A REGISTERED KINDLE FIRE TO SEE THE MAP it does not work in other case (also enable the location on settings)
  • getLatitudeSpan() Returns the difference in microdegrees(decimal degrees multiplied by one million). between the latitude of the top edge of the MapView and the latitude of the bottom edge. * 1E6 or / 1E6
  • Useful to replace the typical markers: https://developer.amazon.com/public/binaries/content/assets/javadoc/fire-phone/reference/com/amazon/geo/maps/overlayitem.html
  • http://www.techotopia.com/index.php/Marking_Android_Map_Locations_using_Amazon_Map_Overlays

Example of extension of Maps to calculate user interactions and refresh for instance the Overlay

package your_package

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.amazon.geo.maps.GeoPoint;
import com.amazon.geo.maps.MapView;

/**
 * Created by victoriza on 18/07/14.
 */

public class ExplorerAmazonMapView extends MapView {

	private static final String TAG = ExplorerAmazonMapView.class.getSimpleName();

	private static final int DURATION_DEFAULT = 700;

	private OnRegionChangedListener onRegionChangedListener;
	private GeoPoint previousMapCenter;
	private int previousZoomLevel;

	// This is the duration between when the user stops moving the map around and when the onRegionEndChange event fires.
	private int changeDuration;

	private boolean isTouched = false;
	private boolean regionChanging = false;

	private Runnable onRegionEndChangeTask = new Runnable() {
		public void run() {
			regionChanging = false;
			previousMapCenter = getMapCenter();
			previousZoomLevel = getZoomLevel();
			if (onRegionChangedListener != null) {
				onRegionChangedListener.onRegionEndChange(ExplorerAmazonMapView.this, previousMapCenter, previousZoomLevel);
			}
		}
	};

	public ExplorerAmazonMapView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public ExplorerAmazonMapView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public ExplorerAmazonMapView(Context context, String apiKey) {
		super(context, apiKey);
		init();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		isTouched = event.getAction() != MotionEvent.ACTION_UP;
		return super.onTouchEvent(event);
	}

	@Override
	public void computeScroll() {
		super.computeScroll();

		// If the map region is still changing (user is still scrolling or zooming), reset timer for onRegionEndChange.
		if ((!isTouched && !getMapCenter().equals(previousMapCenter)) || (previousZoomLevel != getZoomLevel())) {

			// If the region has just begun changing, fire off onRegionBeginChange event.
			if (!regionChanging) {
				regionChanging = true;
				if (onRegionChangedListener != null) {
					onRegionChangedListener.onRegionBeginChange(this, previousMapCenter, previousZoomLevel);
				}
			}

			// Reset timer for onRegionEndChange.
			removeCallbacks(onRegionEndChangeTask);
			postDelayed(onRegionEndChangeTask, changeDuration);
		}
	}

	private void init() {
		changeDuration = DURATION_DEFAULT;
		previousMapCenter = getMapCenter();
		previousZoomLevel = getZoomLevel();
	}

	public void setOnRegionChangedListener(OnRegionChangedListener listener) {
		onRegionChangedListener = listener;
	}

	public void setChangeDuration(int duration) {
		changeDuration = duration;
	}

	public interface OnRegionChangedListener {
		public abstract void onRegionBeginChange(ExplorerAmazonMapView explorerMapView, GeoPoint geoPoint, int zoomLevel);

		public abstract void onRegionEndChange(ExplorerAmazonMapView explorerMapView, GeoPoint geoPoint, int zoomLevel);
	}
}