Showing posts with label Android OS. Show all posts
Showing posts with label Android OS. Show all posts

Tuesday, 13 October 2015

Create Android Emulator using Command line


This video tutorial content following:

  • How to make Android emulator for test your Android apps
  • Use of command line in android sdk
  • How to change hardware setting for emulator
  • How to open avd manager using command line



Full Setup Android Environment for developing Android Application


This tutorial video content following:

  • Download android studio
  • Download android SDK
  • Install Android studio
  • Set environment variable 


Tuesday, 15 September 2015

What is new in Moto G Android 5.1 update in India


Indian Moto G (1st Gen) handset receiving new update Android 5.1 from last 2-3 days. Update contains some more security future at system level and removing, fixed security vulnerability, bug fix and other stability improvements.


New in Android 5.1 : Notification bar display your GSM network provide name steady. 


New in Android 5.1 : Notification bar display Wi-Fi and Blutooth dropdown icon.



Motorola start feeding Android 5.1 for Moto G first Generation in India

It is very good news for Moto lover of Moto G first generation handset receiving  Android 5.1 update. 



Motorola start feeding update from last 2-3 days in India and update have 208.7 MB size.







Saturday, 27 June 2015

Drawing route between coordinates in Google map at Android os

use this simple code...may be work in your application

    public class GPSLine extends MapActivity {
   
    private List<Overlay> mapOverlays;
    private Projection projection;
    MapView mapView;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
   
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    mapView.setClickable(true);
   
    mapOverlays = mapView.getOverlays();
    projection = mapView.getProjection();
    mapOverlays.add(new MyOverlay(null));
   
    }
   
    @Override
    protected boolean isRouteDisplayed() {
       return false;
    }
   
   
    class MyOverlay extends ItemizedOverlay {
   
    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    public MyOverlay(Drawable defaultMarker) {
    super(defaultMarker);
    // TODO Auto-generated constructor stub
    }
    @Override
    public void draw(Canvas canvas, MapView mapv, boolean shadow){
           super.draw(canvas, mapv, shadow);
   
           Paint mPaint = new Paint();
           mPaint.setDither(true);
           mPaint.setColor(Color.RED);
           mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
           mPaint.setStrokeJoin(Paint.Join.ROUND);
           mPaint.setStrokeCap(Paint.Cap.ROUND);
           mPaint.setStrokeWidth(2);
   
           GeoPoint gP1 = new GeoPoint(19240000,-99120000);
           GeoPoint gP2 = new GeoPoint(37423157, -122085008);
   
           Point p1 = new Point();
           Point p2 = new Point();
   
       Path path = new Path();
   
        projection.toPixels(gP1, p1);
           projection.toPixels(gP2, p2);
   
           path.moveTo(p2.x, p2.y);
           path.lineTo(p1.x,p1.y);
   
           canvas.drawPath(path, mPaint);
       }
    @Override
    protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub
    return mOverlays.get(i);
    }
    @Override
    public int size() {
    // TODO Auto-generated method stub
    return 0;
    }
    }
    }

Divide Image into parts in Android

public class CropImageManipulator
    {
        public CropImageManipulator()
        {
        }
   
        private string _fileNameWithoutExtension;
        private string _fileExtension;
        private string _fileDirectory;
   
        public void Cropping(string inputImgPath, int cropWidth, int cropHeight)
        {
            this._fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(inputImgPath);
            this._fileExtension = System.IO.Path.GetExtension(inputImgPath);
            this._fileDirectory = System.IO.Path.GetDirectoryName(inputImgPath);
   
            //Load the image divided
             Image inputImg = Image.FromFile(inputImgPath);
            int imgWidth = inputImg.Width;
            int imgHeight = inputImg.Height;
   
            //Divide how many small blocks
            int widthCount = (int)Math.Ceiling((imgWidth * 1.00) / (cropWidth * 1.00));
            int heightCount = (int)Math.Ceiling((imgHeight * 1.00) / (cropHeight * 1.00));
            ArrayList areaList = new ArrayList();
   
            int i = 0;
            for (int iHeight = 0; iHeight < heightCount ; iHeight ++)
            {
                for (int iWidth = 0; iWidth < widthCount ; iWidth ++)
                {
                    int pointX = iWidth * cropWidth;
                    int pointY = iHeight * cropHeight;
                    int areaWidth = ((pointX + cropWidth) > imgWidth) ? (imgWidth - pointX) : cropWidth;
                    int areaHeight = ((pointY + cropHeight) > imgHeight) ? (imgHeight - pointY) : cropHeight;
                    string s = string.Format("{0};{1};{2};{3}",pointX,pointY,areaWidth,areaHeight);
   
                    Rectangle rect = new Rectangle(pointX,pointY,areaWidth,areaHeight);
                    areaList.Add(rect);
                    i ++;
                }
            }
   
            for (int iLoop = 0 ; iLoop < areaList.Count ; iLoop ++)
            {
                Rectangle rect = (Rectangle)areaList[iLoop];
                string fileName = this._fileDirectory + "\\" + this._fileNameWithoutExtension + "_" + iLoop.ToString() + this._fileExtension;
                Bitmap newBmp = new Bitmap(rect.Width,rect.Height,PixelFormat.Format24bppRgb);
                Graphics newBmpGraphics = Graphics.FromImage(newBmp);
                newBmpGraphics.DrawImage(inputImg,new Rectangle(0,0,rect.Width,rect.Height),rect,GraphicsUnit.Pixel);
                newBmpGraphics.Save();
                switch (this._fileExtension.ToLower())
                {
                    case ".jpg":
                    case ".jpeg":
                        newBmp.Save(fileName,ImageFormat.Jpeg);
                        break;
                    case "gif":
                        newBmp.Save(fileName,ImageFormat.Gif);
                        break;
                }
            }
            inputImg.Dispose();
        }
    }

Friday, 12 August 2011

android: removing listview selector

first this problem solution achieve we can create custom listview...

suppose your listview xml file like...

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
         
        <ListView
        android:layout_height="wrap_content"
        android:id="@android:id/list"
        android:layout_width="match_parent"></ListView>
    </LinearLayout>

and custom view xml file...


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/black"
        >
            <TextView
            android:text="TextView"
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:textSize="30dip">
            </TextView>
   
    </LinearLayout>


activity class...

public class ListHeaderActivity extends ListActivity {

    ListView lstVw;
    MyArrayAdapter myArrayAdapter = null;
    ArrayList<String> arrList = new ArrayList<String>();

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

        arrList.add("android");
        arrList.add("iphone");
        arrList.add("rim");
        lstVw = getListView();
        myArrayAdapter = new MyArrayAdapter(ListHeaderActivity.this,
                R.layout.header, arrList);
        lstVw.setAdapter(myArrayAdapter);

    }

}

adapter class....

public class MyArrayAdapter extends ArrayAdapter<String> {

    ViewHolder holder;
    private int rawLayout;

    public MyArrayAdapter(Context context, int resourceId,
            ArrayList<String> objects) {
        super(context, resourceId, objects);
        rawLayout = resourceId;
    }

    @Override
    public int getCount() {
        return super.getCount();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(getContext());
            convertView = inflater.inflate(rawLayout, parent, false);
            holder = new ViewHolder();
            holder.title1 = (TextView) convertView.findViewById(R.id.textView1);

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.title1.setText("your text item");

        return convertView;
    }

    private class ViewHolder {
        TextView title1;
    }
}


Saturday, 6 August 2011

Android expandable list view

Activity class..

public class ExpList extends ExpandableListActivity
{
    static final String colors[] = {
      "grey",
      "blue",
      "yellow",
      "red"
    };

    static final String shades[][] = {
// Shades of grey
      {
        "lightgrey","#D3D3D3",
        "dimgray","#696969",
        "sgi gray 92","#EAEAEA"
      },
// Shades of blue
      {
        "dodgerblue 2","#1C86EE",
        "steelblue 2","#5CACEE",
        "powderblue","#B0E0E6"
      },
// Shades of yellow
      {
        "yellow 1","#FFFF00",
        "gold 1","#FFD700",
        "darkgoldenrod 1","    #FFB90F"
      },
// Shades of red
      {
        "indianred 1","#FF6A6A",
        "firebrick 1","#FF3030",
        "maroon","#800000"
      }
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        SimpleExpandableListAdapter expListAdapter =
            new SimpleExpandableListAdapter(
                this,
                createGroupList(),    // groupData describes the first-level entries
                R.layout.group_row,    // Layout for the first-level entries
                new String[] { "colorName" },    // Key in the groupData maps to display
                new int[] { R.id.groupname },        // Data under "colorName" key goes into this TextView
                createChildList(),    // childData describes second-level entries
                R.layout.child_row,    // Layout for second-level entries
                new String[] { "shadeName", "rgb" },    // Keys in childData maps to display
                new int[] { R.id.childname, R.id.rgb }    // Data under the keys above go into these TextViews
            );
        setListAdapter( expListAdapter );
    }

    private List createGroupList() {
      ArrayList result = new ArrayList();
      for( int i = 0 ; i < colors.length ; ++i ) {
        HashMap m = new HashMap();
        m.put( "colorName",colors[i] );
        result.add( m );
      }
      return (List)result;
    }

  private List createChildList() {
    ArrayList result = new ArrayList();
    for( int i = 0 ; i < shades.length ; ++i ) {
// Second-level lists
      ArrayList secList = new ArrayList();
      for( int n = 0 ; n < shades[i].length ; n += 2 ) {
        HashMap child = new HashMap();
        child.put( "shadeName", shades[i][n] );
        child.put( "rgb", shades[i][n+1] );
        secList.add( child );
      }
      result.add( secList );
    }
    return result;
  }

}

xml files

main.xml

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">

     <ExpandableListView android:id="@+id/android:list"
               android:layout_width="wrap_content" android:layout_height="wrap_content"
               />

     <TextView android:id="@+id/android:empty"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:text="@string/main_no_items"/>
</LinearLayout>

group_row.xml

<TextView android:id="@+id/groupname"
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:textSize="16px"
         android:textStyle="bold"
         android:paddingLeft="50px"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:background="@drawable/red_button"/>



child_row.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView android:id="@+id/childname"
         android:paddingLeft="50px"
         android:textSize="14px"
         android:textStyle="italic"
         android:layout_width="150px"
         android:layout_height="wrap_content"/>

    <TextView android:id="@+id/rgb"
         android:textSize="14px"
         android:textStyle="italic"
         android:layout_width="100px"
         android:layout_height="wrap_content"/>
</LinearLayout>

In drawable folder...create one red_button.xml file

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <!--  <color android:color="#800517" />-->
        <shape>
            <gradient android:startColor="#FFFF00" android:endColor="#AF7817"
                android:angle="270" />
            <stroke android:width="5dp" android:color="#747170" />
            <corners android:radius="5dp" />
            <padding android:left="10dp" android:top="10dp"
                android:right="10dp" android:bottom="10dp" />

        </shape>
    </item>
    <item android:state_focused="true">
        <!--  <color android:color="#00FFFF" />-->
        <shape>
            <gradient android:endColor="#F433FF" android:startColor="#F6358A"
                android:angle="270" />
            <stroke android:width="5dp" android:color="#747170" />
            <corners android:radius="5dp" />
            <padding android:left="10dp" android:top="10dp"
                android:right="10dp" android:bottom="10dp" />
        </shape>

    </item>
    <item>
                <shape>
            <gradient android:endColor="#A0CFEC" android:startColor="#736AFF"
                android:angle="270" />
            <stroke android:width="5dp" android:color="#747170" />
            <corners android:radius="5dp" />
            <padding android:left="10dp" android:top="10dp"
                android:right="10dp" android:bottom="10dp" />
        </shape>

    </item>
</selector>


output screenshot...

Friday, 8 April 2011

how to use web service with xml parsing in android application?



An XML parser converts an XML document into an XML DOM(Document Object Model) object - which can then be manipulated with a Java Code.
Type of XML Parser :
  XML SAX Parser(Simple API for XML): It gives an event based approach to XML parsing. It means that instead of going from node to node, it goes from event to event.
  XML Pull Parser: It is optimal for applications that require fast and a small XML parser. It should be used when all the process has to be performed quickly and efficiently to input elements.

and many other...! 

Monday, 21 March 2011

what is android?

A software platform and operating system for mobile devices.Based on the Linux kernel.Developed by Google and later the Open Handset Alliance (OHA).Allows writing managed code in the Java language.