Showing posts with label Android Application Development. Show all posts
Showing posts with label Android Application Development. Show all posts

Tuesday, June 28, 2016

Android Best Practices for Interaction and Engagement for Developers

Best Practices for Interaction and Engagement:

These classes teach you how to engage and retain your users by implementing the best interaction patterns for Android. For instance, to help users quickly discover content in your app, your app should match their expectations for user interaction on Android. And to keep your users coming back, you should take advantage of platform capabilities that reveal and open your content without requiring users to go through the app launcher.

2)Designing Effective Navigation:

One of the very first steps to designing and developing an Android application is to determine what users are able to see and do with the app. Once you know what kinds of data users are interacting with in the app, the next step is to design the interactions that allow users to navigate across, into, and back out from the different pieces of content within the app.

This class shows you how to plan out the high-level screen hierarchy for your application and then choose appropriate forms of navigation to allow users to effectively and intuitively traverse your content. Each lesson covers various stages in the interaction design process for navigation in Android applications, in roughly chronological order. After going through the lessons in this class, you should be able to apply the methodology and navigation paradigms outlined here to your own applications, providing a coherent navigation experience for your users.

2.a)Planning Screens and Their Relationships:

Most apps have an inherent information model that can be expressed as a tree or graph of object types. In more obvious terms, you can draw a diagram of different kinds of information that represents the types of things users interact with in your app. Software engineers and data architects often use entity-relationship diagrams (ERDs) to describe an application's information model.

b)Create a Screen List: 

Once you define the information model, you can begin to define the contexts necessary to enable users to effectively discover, view, and act upon the data in your application. In practice, one way to do this is to determine the exhaustive set of screens needed to allow users to navigate to and interact with the data. The set of screens we actually expose should generally vary depending on the target device; it's important to consider this early in the design process to ensure that the application can adapt to its environment.

In our example application, we want to enable users to view, save, and share categorized stories and photos. Below is an exhaustive list of screens that covers these use cases.

Home or "launchpad" screen for accessing stories and photos
List of categories
List of news stories for a given category
Story detail view (from which we can save and share)
List of photos, uncategorized
Photo detail view (from which we can save and share)
List of all saved items
List of saved photos
List of saved stories

c)Diagram Screen Relationships:

Now we can define the directed relationships between screens; an arrow from one screen A to another screen B implies that screen B should be directly reachable via some user interaction in screen A. Once we define both the set of screens and the relationships between them, we can express these in concert as a screen map, which shows all of your screens and their relationships.
If we later wanted to allow users to submit news stories or upload photos, we could add additional screens to this diagram.

d)Go Beyond a Simplistic Design:

At this point, it's possible to design a completely functional application from this exhaustive screen map. A simplistic user interface could consist of lists and buttons leading to child screens:

Buttons leading to different sections (e.g., stories, photos, saved items)
Vertical lists representing collections (e.g., story lists, photo lists, etc.)
Detail information (e.g., story view, full-screen photo view, etc.)
However, you can use screen grouping techniques and more sophisticated navigation elements to present content in a more intuitive and device-sensitive way. In the next lesson, we explore screen grouping techniques, such as providing multi-pane layouts for tablet devices. Later, we'll dive into the various navigation patterns common on Android.

3)Planning for Multiple Touchscreen Sizes:

The exhaustive screen map from the previous lesson isn't tied to a particular device form factor, although it can generally look and work okay on a handset or similar-size device. But Android applications need to adapt to a number of different types of devices, from 3" handsets to 10" tablets to 42" TVs. In this lesson we explore reasons and tactics for grouping together multiple screens from the exhaustive map.

Note: Designing applications for television sets also requires attention to other factors, including interaction methods (i.e., the lack of a touch screen), legibility of text at large reading distances, and more. Although this discussion is outside the scope of this class, you can find more information on designing for TVs in the Google TV documentation for design patterns.

4)Group Screens with Multi-pane Layouts:

Multi-pane Layout Design

For design guidelines, read Android Design's Multi-pane Layouts pattern guide.
3 to 4-inch screens are generally only suitable for showing a single vertical pane of content at a time, be it a list of items, or detail information about an item, etc. Thus on such devices, screens generally map one-to-one with levels in the information hierarchy (categories → object list → object detail).

Larger screens such as those found on tablets and TVs, on the other hand, generally have much more available screen space and are able to present multiple panes of content. In landscape, panes are usually ordered from left to right in increasing detail order. Users are especially accustomed to multiple panes on larger screens from years and years of desktop application and desktop web site use. Many desktop applications and websites offer a left-hand navigation pane or use a master/detail two-pane layout.

In addition to addressing these user expectations, it's usually necessary to provide multiple panes of information on tablets to avoid leaving too much whitespace or unwittingly introducing awkward interactions, for example 10 x 0.5-inch buttons.

The following figures demonstrate some of the problems that can arise when moving a UI (user interface) design into a larger layout and how to address these issues with multi-pane layouts:

Implementation Note: After deciding on the screen size at which to draw the line between single-pane and multi-pane layouts, you can provide different layouts containing one or multiple panes for devices in varying screen size buckets (such as large/xlarge) or varying minimum screen widths (such as sw600dp).

Implementation Note: While a single screen is implemented as an Activity subclass, individual content panes can be implemented as Fragment subclasses. This maximizes code re-use across different form factors and across screens that share content.

5)Design for Multiple Tablet Orientations:

Although we haven't begun arranging user interface elements on our screens yet, this is a good time to consider how your multi-pane screens will adapt to different device orientations. Multi-pane layouts in landscape work quite well because of the large amount of available horizontal space. However, in the portrait orientation, your horizontal space is more limited, so you may need to design a separate layout for this orientation.

Below are a few common strategies for creating portrait tablet layouts.

Stretch  Stretch strategy:

The most straightforward strategy is to simply stretch each pane's width to best present the content in each pane in the portrait orientation. Panes could have fixed widths or take a certain percentage of the available screen width.

Expand/collapse  Expand/collapse strategy:

A variation on the stretch strategy is to collapse the contents of the left pane when in portrait. This works quite well with master/detail panes where the left (master) pane contains easily collapsible list items. An example would be for a realtime chat application. In landscape, the left list could contain chat contact photos, names, and online statuses. In portrait, horizontal space could be collapsed by hiding contact names and only showing photos and online status indicator icons. Optionally also provide an expand control that allows the user to expand the left pane content to its larger width and vice versa.

Show/Hide  Show/Hide strategy:

In this scenario, the left pane is completely hidden in portrait mode. However, to ensure the functional parity of your screen in portrait and landscape, the left pane should be made available via an onscreen affordance (such as a button). It's usually appropriate to use the Up button in the Action Bar (pattern docs at Android Design) to show the left pane, as is discussed in a later lesson.

Stack  Stack strategy:

The last strategy is to vertically stack your normally horizontally-arranged panes in portrait. This strategy works well when your panes aren't simple text-based lists, or when there are multiple blocks of content running along the primary content pane. Be careful to avoid the awkward whitespace problem discussed above when using this strategy.

6)Group Screens in the Screen Map:

Now that we are able to group individual screens together by providing multi-pane layouts on larger-screen devices, let's apply this technique to our exhaustive screen map from the previous lesson to get a better sense of our application's hierarchy on such devices:

Friday, May 27, 2016

Android with RecyclerView Example

RecyclerView is more advanced and flexible and efficient version of ListView. RecyclerView ViewGroup is an container for larger data set of views that can be recycled and scrolled very efficiently. RecyclerView can be used for larger datasets to be rendered on the UI like a list. RecyclerView provides maximum flexibility to design different kind of views.

Android RecyclerView is more advanced version of ListView with improved performance and other benefits. Using RecyclerView and CardView together, both lists and grids can be created very easily.

You have to include the dependencies in gradle file like this.


build.gradle
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
}

1) Activity

import android.content.res.Resources;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;

public class CommonForumActivity extends AppCompatActivity {

    public ListView list;
    public CustomAdapter adapter;
    public  CommonForumActivity CustomListView = null;
    public ArrayList<ForumModel> CustomListViewValuesArr = new ArrayList<ForumModel>();


    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_forum);

        CustomListView = this;

        /******** Take some data in Arraylist ( CustomListViewValuesArr ) ***********/        setListData();

        Resources res =getResources();
        list= ( ListView )findViewById( R.id.listView );  // List defined in XML ( See Below )
        /**************** Create Custom Adapter *********/        adapter=new CustomAdapter( CustomListView, CustomListViewValuesArr,res );
        list.setAdapter( adapter );
    }

    /****** Function to set data in ArrayList *************/    public void setListData()
    {

        for (int i = 0; i < 11; i++) {

            final ForumModel sched = new ForumModel();

            /******* Firstly take data in model object ******/            sched.setQuestion("Company " + i);
            sched.setImageUrl("image" + i);
            /******** Take Model Object in ArrayList **********/            CustomListViewValuesArr.add( sched );
        }

    }

    public void OnItemClickListener(int mPosition)
    {
        ForumModel tempValues = ( ForumModel ) CustomListViewValuesArr.get(mPosition);

    }
}

2) Forum Model:

/** * Created by Abhinaw.Tripathi on 24-05-2016. */public class ForumModel {

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    private String question="";
    private String imageUrl ="";
}

3)CustomeAdapter

import java.util.ArrayList;

/** * Created by Abhinaw.Tripathi on 24-05-2016. */public class CustomAdapter extends BaseAdapter implements View.OnClickListener
{
    private Activity activity;
    private ArrayList data;
    private static LayoutInflater inflater=null;
    public Resources res;
    ForumModel tempValues=null;
    int i=0;

    /*************  CustomAdapter Constructor *****************/    public CustomAdapter(Activity a, ArrayList d,Resources resLocal)
    {
        /********** Take passed values **********/        activity = a;
        data=d;
        res = resLocal;
        /***********  Layout inflator to call external xml layout () ***********/        inflater = ( LayoutInflater )activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }


    @Override    public int getCount()
    {
        if(data.size()<=0)
            return 1;
        return data.size();
    }

    @Override    public Object getItem(int position) {
        return position;
    }

    @Override    public long getItemId(int position) {
        return position;
    }

    /********* Create a holder Class to contain inflated xml file elements *********/    public static class ViewHolder
    {
        public TextView text;
        public ImageView image;
        public TextView answer;
    }

    @Override    public View getView(int position, View convertView, ViewGroup parent)
    {
        View vi = convertView;
        ViewHolder holder;

        if(convertView==null) {

            /****** Inflate tabitem.xml file for each row ( Defined below ) *******/            vi = inflater.inflate(R.layout.item_row_layout, null);

            /****** View Holder Object to contain tabitem.xml file elements ******/
            holder = new ViewHolder();
            holder.text = (TextView) vi.findViewById(R.id.txt_row_ask_quest);
            holder.image = (ImageView) vi.findViewById(R.id.imgView_titleHardCodeQyuest);
            holder.answer = (TextView) vi.findViewById(R.id.txt_titleHardCodeAns);

            /************  Set holder with LayoutInflater ************/            vi.setTag(holder);
        }
        else            holder=(ViewHolder)vi.getTag();
        if(data.size()<=0)
        {
            holder.text.setText("No Data");

        }
        else        {
            /***** Get each Model object from Arraylist ********/            tempValues=null;
            tempValues = ( ForumModel ) data.get( position );

            /************  Set Model values in Holder elements ***********/
            holder.text.setText( tempValues.getQuestion());
            holder.image.setImageResource(
                    res.getIdentifier(
                            "com.myandroid.docpat:drawable/" + tempValues.getImageUrl()
                            , null, null));
            /******** Set Item Click Listner for LayoutInflater for each row *******/
            vi.setOnClickListener((View.OnClickListener) new OnItemClickListener( position ));

        }
        return vi;
    }

    @Override    public void onClick(View v) {

    }

    /********* Called when Item click in ListView ************/    private class OnItemClickListener  implements View.OnClickListener {
        private int mPosition;

        OnItemClickListener(int position){
            mPosition = position;
        }

        @Override        public void onClick(View arg0) {

            CommonForumActivity sct = (CommonForumActivity)activity;

            sct.OnItemClickListener(mPosition);

        }
    }
}

4)item_row_layout

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="wrap_content"    >
    <LinearLayout        android:orientation="horizontal"        android:layout_width="match_parent"        android:weightSum="2.0"        android:layout_height="wrap_content">

    <ImageView        android:layout_width="100dp"        android:layout_height="80dp"        android:layout_weight="0.5"        android:id="@+id/imgView_titleHardCodeQyuest"        android:textColor="@android:color/black"        android:onClick="onClick"        android:background="@drawable/questions"        />
        <TextView            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_weight="1.5"            android:text="what is your question?"            android:textStyle="bold"            android:textSize="20dp"            android:gravity="center_horizontal|center_vertical|center"
            android:id="@+id/txt_row_ask_quest"            android:textColor="@android:color/black"            android:onClick="onClick"            />


    </LinearLayout>

    <TextView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="Answer:"        android:textStyle="bold"        android:padding="20dp"        android:textSize="20dp"        android:id="@+id/txt_titleHardCodeAns"        android:textColor="@android:color/black"        android:onClick="onClick"        />


</LinearLayout>

5)mainlayout:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingTop="@dimen/activity_vertical_margin"    android:paddingBottom="@dimen/activity_vertical_margin"    android:layout_margin="5dp"    tools:context="com.myandroid.docpat.CommonForumActivity"    android:background="@drawable/border"    >

    <TextView        android:id="@+id/txt_titleForum"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text=" Please ask questions or doubts!!!"        android:textStyle="bold"        android:padding="20dp"        android:background="@android:color/darker_gray"        android:textSize="20dp"        android:textColor="@android:color/black"        android:singleLine="false"        android:layout_centerHorizontal="true"        />

    <ListView        android:id="@+id/listView"        android:layout_below="@+id/txt_titleForum"        android:layout_above="@+id/bottomLayout"        android:layout_width="match_parent"        android:layout_height="wrap_content">

    </ListView>


<LinearLayout    android:id="@+id/bottomLayout"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="horizontal"    android:weightSum="3.0"    android:layout_alignParentBottom="true"    android:background="@android:color/darker_gray"    >

    <Button        android:id="@+id/btnAskQuest"        android:text="Ask Question"        android:layout_margin="5dp"        android:layout_width="wrap_content"        android:layout_weight="1.0"        android:layout_height="wrap_content" />

    <Button        android:id="@+id/btnGiveAns"        android:text="Give Answer"        android:layout_margin="5dp"        android:layout_width="wrap_content"        android:layout_weight="1.0"        android:layout_height="wrap_content" />
    <Button        android:id="@+id/btnDo_Nothing"        android:text="Do Nothing"        android:layout_margin="5dp"        android:layout_width="wrap_content"        android:layout_weight="1.0"        android:layout_height="wrap_content" />

</LinearLayout>

</RelativeLayout>

Thursday, May 26, 2016

Arc GIS Mapping Example with Source code


1)ArcGisActivity.java

package arc.gis;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.Toast;
import com.esri.android.map.GraphicsLayer;
import com.esri.android.map.MapOnTouchListener;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISFeatureLayer;
import com.esri.android.map.ags.ArcGISFeatureLayer.MODE;
import com.esri.android.map.ags.ArcGISFeatureLayer.Options;
import com.esri.android.map.ags.ArcGISFeatureLayer.SELECTION_METHOD;
import com.esri.android.map.event.OnSingleTapListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.map.CallbackListener;
import com.esri.core.map.FeatureSet;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.SimpleFillSymbol;
import com.esri.core.symbol.SimpleLineSymbol;
import com.esri.core.tasks.SpatialRelationship;
import com.esri.core.tasks.ags.query.Query;

public class ArcGisActivity extends Activity {

MapView mMapView ;
ArcGISFeatureLayer fLayer = null;
GraphicsLayer gLayer = null;
SimpleFillSymbol sfs;
CallbackListener<FeatureSet> callback = new CallbackListener<FeatureSet>() {
public void onCallback(FeatureSet fSet) {
System.out.println("onCallback"+fSet);
}

public void onError(Throwable arg0) {
gLayer.removeAll();
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mMapView = (MapView)findViewById(R.id.map);
ESRIShapeLayer graphicsLayer = new ESRIShapeLayer("/mnt/sdcard/sample.shp",mMapView.getExtent());
Options o = new Options();
o.mode = MODE.ONDEMAND;
o.outFields = new String[] { "FIELD_KID", "APPROXACRE", "FIELD_NAME",
"STATUS", "PROD_GAS", "PROD_OIL", "ACTIVEPROD", "CUMM_OIL",
"MAXOILWELL", "LASTOILPRO", "LASTOILWEL", "LASTODATE",
"CUMM_GAS", "MAXGASWELL", "LASTGASPRO", "LASTGASWEL",
"LASTGDATE", "AVGDEPTH", "AVGDEPTHSL", "FIELD_TYPE",
        "FIELD_KIDN"
};
gLayer=graphicsLayer.getLayer();
mMapView.addLayer(gLayer);

mMapView.setOnSingleTapListener(new OnSingleTapListener() {

private static final long serialVersionUID = 1L;
public void onSingleTap(float x, float y) {
Toast.makeText(getApplicationContext(), "You have touched at X-Y points::"+x+" "+y, Toast.LENGTH_LONG).show();

}
});


/* mMapView.setExtent(new Envelope(-10868502.895856911, 4470034.144641369,
-10837928.084542884, 4492965.25312689), 0);
ArcGISTiledMapServiceLayer tms = new ArcGISTiledMapServiceLayer(
"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
mMapView.addLayer(tms);*/

fLayer = new ArcGISFeatureLayer(
"http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/1",
o);
SimpleFillSymbol fiedldsSelectionSymbol = new SimpleFillSymbol(Color.MAGENTA);
fiedldsSelectionSymbol.setOutline(new SimpleLineSymbol(Color.YELLOW, 2));
fLayer.setSelectionSymbol(fiedldsSelectionSymbol);

mMapView.addLayer(fLayer);

// selection box
gLayer = new GraphicsLayer();
sfs = new SimpleFillSymbol(Color.BLACK);
sfs.setOutline(new SimpleLineSymbol(Color.RED, 2));
sfs.setAlpha(100);

mMapView.addLayer(gLayer);
//setContentView(map);

MyTouchListener touchListener = new MyTouchListener(this, mMapView);
mMapView.setOnTouchListener(touchListener);

Toast.makeText(this, "Press down to start let go the stop",Toast.LENGTH_SHORT).show();
}

class MyTouchListener extends MapOnTouchListener {

Graphic g;
// first point clicked on the map
Point p0 = null;
int uid = -1;

public MyTouchListener(Context arg0, MapView arg1) {
super(arg0, arg1);
}

public boolean onDragPointerMove(MotionEvent from, MotionEvent to) {
if (uid == -1) { // first time
g = new Graphic(null, sfs);
p0 = mMapView.toMapPoint(from.getX(), from.getY());
uid = gLayer.addGraphic(g);

} else {

Point p2 = mMapView.toMapPoint(new Point(to.getX(), to.getY()));
Envelope envelope = new Envelope();
envelope.merge(p0);
envelope.merge(p2);
gLayer.updateGraphic(uid, envelope);

}

return true;

}
public boolean onDragPointerUp(MotionEvent from, MotionEvent to) {

if (uid != -1) {
g = gLayer.getGraphic(uid);
if (g!= null && g.getGeometry() != null) {
fLayer.clearSelection();
Query q = new Query();
// optional
q.setWhere("PROD_GAS='Yes'");
q.setReturnGeometry(true);
q.setInSpatialReference(mMapView.getSpatialReference());
q.setGeometry(g.getGeometry());
q.setSpatialRelationship(SpatialRelationship.INTERSECTS);

fLayer.selectFeatures(q, SELECTION_METHOD.NEW, callback);
}
gLayer.removeAll();

}

p0 = null;
// Resets it
uid = -1;
return true;

}

}

@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
mMapView.pause();
}
@Override
protected void onResume() {
super.onResume();
mMapView.unpause();
}

@Override
public Object onRetainNonConfigurationInstance() {
return mMapView.retainState();
}
}

2) ESRIShapeLayer.java

package arc.gis;

import java.io.File;
import java.io.IOException;

import android.graphics.Color;

import com.bbn.openmap.layer.shape.ESRIPointRecord;
import com.bbn.openmap.layer.shape.ESRIPoly;
import com.bbn.openmap.layer.shape.ESRIPolygonRecord;
import com.bbn.openmap.layer.shape.ShapeFile;
import com.esri.android.map.GraphicsLayer;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.Polygon;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.SimpleFillSymbol;
import com.esri.core.symbol.SimpleMarkerSymbol;
import com.esri.core.symbol.SimpleMarkerSymbol.STYLE;

public class ESRIShapeLayer {

private GraphicsLayer graphicsLayer = null;// = new GraphicsLayer();
private String shapeFileName = null;
private Polygon polygon = null;// = new Polygon();
private Point polygonVertex = null;// = new Point();
@SuppressWarnings("unused")
private int polygonCount = 0;


/**
* Save applications's state
*/
//ApplicationState applicationState = null; //, ApplicationState applicationState

public ESRIShapeLayer(String shapeFileName, Polygon pol) {
this.shapeFileName = shapeFileName;
SpatialReference lSR = SpatialReference.create(2093);  //26192   2093
Envelope lEnvolope = getSHPEnvelope(shapeFileName);

graphicsLayer = new GraphicsLayer(lSR,lEnvolope);
polygon = new Polygon();
polygonVertex = new Point();
//this.applicationState = applicationState;
readShapeFile();

}

public GraphicsLayer getLayer() {
return graphicsLayer;
}

public GraphicsLayer readShapeFile() {
try {
File file = new File(shapeFileName);
ShapeFile esriShapeFile = new ShapeFile(file);
ESRIPoly[] polygons;

System.out.println("Shape Type: " + esriShapeFile.getShapeType());

if (esriShapeFile.getShapeType() == ShapeFile.SHAPE_TYPE_POINT) {
ESRIPointRecord esriPointRecord = (ESRIPointRecord) esriShapeFile.getNextRecord();
SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(Color.BLUE, 10, STYLE.CIRCLE);

while (esriPointRecord != null) {
graphicsLayer.addGraphic(new Graphic(
new Point(esriPointRecord.getX(), esriPointRecord.getY()), simpleMarkerSymbol));
esriPointRecord = (ESRIPointRecord) esriShapeFile.getNextRecord();
}
//esriShapeFile.close();
}
if (esriShapeFile.getShapeType() == ShapeFile.SHAPE_TYPE_POLYLINE) {
/**
* Have not figured this out yet.
*/
}
if (esriShapeFile.getShapeType() == ShapeFile.SHAPE_TYPE_POLYGON) {

ESRIPolygonRecord esriPolygonRecord = (ESRIPolygonRecord) esriShapeFile.getNextRecord();
SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(Color.BLUE);

while (esriPolygonRecord != null) {
polygons = esriPolygonRecord.polygons;

System.out.println("Number of Polygons Per Record[" + polygons.length + "]: "+ esriPolygonRecord.getRecordNumber());

for (int i = 0; i < polygons.length; i++) {
polygonCount++;

ESRIPoly.ESRIFloatPoly poly = (ESRIPoly.ESRIFloatPoly) polygons[i];

//System.out.println("Polygon Point Count[: " + esriPolygonRecord.getRecordNumber() + "]: " + poly.nPoints);

polygonVertex = new Point(poly.getX(0), poly.getY(0));
polygon = new Polygon();

polygon.startPath(polygonVertex);

for (int j = 1; j < poly.nPoints; j++) {
// System.out.println("poly.getX(j):"+poly.getX(j)+" poly.getY(j):"+poly.getY(j));
polygonVertex = new Point(poly.getX(j), poly.getY(j));
polygon.lineTo(polygonVertex);
}
}

/**
* Move inside loop above otherwise it is only displaying one of the polygons per record.
*/

//polygon.calculateArea2D();
graphicsLayer.addGraphic(new Graphic(polygon, simpleFillSymbol));
esriPolygonRecord = (ESRIPolygonRecord) esriShapeFile.getNextRecord();
}
//esriShapeFile.close();
// System.out.println("Polygon Count: " + polygonCount);
}

esriShapeFile.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return graphicsLayer;
}

private Envelope getSHPEnvelope(String shapName) {

double xMin = 120.0;        // 220.0
double xMax = 150.0;         //250.0
double yMin = 150.0;         //250.0
double yMax = -150.0;        //-250.0

/*double xMin = -130.0;
double xMax = -114.0;
double yMin = 31.0;
double yMax = 41.5;*/
/*try {
File file = new File(shapName);
ShapeFile esriShapeFile = new ShapeFile(file);
ShapefileWorkspaceFactory shapefileWorkspaceFactory = new ShapefileWorkspaceFactory();

}catch (Exception e) {
e.printStackTrace();
}*/

Envelope envelop = new Envelope();
envelop.setCoords(xMin, xMax, yMin, yMax);

/*Envelope env = new Envelope();
Envelope NewEnv = new Envelope();
for (int i:graphicsLayerLines.getGraphicIDs()){
Polyline p = (Polyline)graphicsLayerLines.getGraphic(i).getGeometry();
   p.queryEnvelope(env);
   NewEnv.merge(env);
}
for (int i:graphicsLayerPoints.getGraphicIDs()){
 Point p = (Point)graphicsLayerPoints.getGraphic(i).getGeometry();
 p.queryEnvelope(env);
 NewEnv.merge(env);
}*/

return envelop;
}
}

3) main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    tools:context=".ArcGisActivity" >

    <com.esri.android.map.MapView
       
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        initExtent = "-1.3296373526814876E7 3930962.41823043 -1.2807176545789773E7 4201243.7502468005">
    </com.esri.android.map.MapView>

</LinearLayout>

4)<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="arc.gis"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" android:maxSdkVersion="17"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

   

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".ArcGisActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


Download the library from the website arcggismappming.........