Android programming

536 views

Published on

Android Programming with PPT File

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
536
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Android programming

  1. 1. Android Programming• An Introduction ---• Android is an• Operating system• Developed by Google• For use in Notebooks• & Mobile Phones.
  2. 2. Introduction Android is a software bunch comprising not onlyoperating system but also middleware and keyapplications. Android Inc was founded in PaloAlto of California, U.S. by Andy Rubin, Richminer, Nick sears and Chris White in 2003. LaterAndroid Inc. was acquired by Google in 2005.After original release there have been number ofupdates in the original version of Android. It is Java based and supports theGoogle APIs
  3. 3. Main Features ofAndroid Application framework enabling reuse and replacement of components. Dalvik virtual machine optimized for mobile devices. Integrated browser based on the open source WebKit engine . Optimized graphics powered by a custom 2D graphics library; 3Dgraphics based on the OpenGL ES 1.0 specification (hardwareacceleration optional). SQLite for structured data storage. Media support for common audio, video, and still image formats(MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF). GSM Telephony (hardware dependent). Bluetooth, EDGE, 3G, and Wi-Fi (hardware dependent). Camera, GPS, compass, and accelerometer (hardware dependent). Rich development environment including a device emulator, tools fordebugging, memory and performance profiling, and a plug-in for theEclipse IDE.
  4. 4. Android Framework
  5. 5. Google APIs in Android Google APIs Add-On is an extension to the Android SDK development environment that lets youdevelop applications for devices that include Googles set of custom applications, libraries, andservices. A central feature of the add-on is the Maps external library, which lets you add powerfulmapping capabilities to your Android application. The add-on also provides a compatible Android system image that runs in the Android Emulator,which lets you debug, profile, and test your application before publishing it to users. The systemimage includes the the Maps library and other custom system components that your applicationsmay need, to access Google services (such as Android C2DM). The add-on does not include anycustom Google applications. When you are ready to publish your application, you can deploy it toany Android-powered device that runs a compatible version of the Android platform and that alsoincludes the custom Google components, libraries, and services. The Google APIs add-on includes: The Maps external library The USB Open Accessory Library (only with API Levels 10 and 12+) A fully-compliant Android system image (with the Maps library and other custom systemcomponents built in) A sample Android application called MapsDemo Full Maps library documentation
  6. 6. Google Cloud API Android Cloud to Device Messaging Framework Android Cloud to Device Messaging (C2DM) is aservice that helps developers send data fromservers to their applications on Android devices.The service provides a simple, lightweightmechanism that servers can use to tell mobileapplications to contact the server directly, tofetch updated application or user data. TheC2DM service handles all aspects of queueing ofmessages and delivery to the target applicationrunning on the target device.
  7. 7. Using Google Maps API• Build location-based apps• Build maps for mobile apps• Visualize Geospatial Data Create 3D imageswith the Earth API, heat maps in Fusion Tables• Customize your maps Create customized mapsthat highlight your data, imagery, and brand.
  8. 8. Google Earth API
  9. 9. Google Earth API Google Earth is available in Android Marketon most devices that have Android 2.1 orlater versions. So as devices such as Droid getupdated to Android 2.1, others will also beable to fly to the far reaches of the globe witha swipe of their finger.Google Earth for Nexus One is used in theAndroid Market.
  10. 10. Google Search API• Google search and Google image search areboth available for Android.• Free licensing is provided for1000 searches per day.
  11. 11. Animations in Android• Animations are supported in Androidboth programmatically and directively.
  12. 12. Android AnimationExample (1) HypatiaBasicAnimationActivity.java package hypatia.animation.basic;import android.app.Activity;import android.graphics.Color;import android.os.Bundle;public class HypatiaBasicAnimationActivity extends Activity { /** Called when the activity is first created. */ static HypatiaAnimationView v;static int[] colors={Color.WHITE,Color.YELLOW,Color.MAGENTA,Color.GREEN,Color.RED};static int colorno=0;@Overridepublic void onCreate(Bundle savedInstanceState) {//This is the first method to be executedsuper.onCreate(savedInstanceState);v=new HypatiaAnimationView(this);//Create the view and store it in a static variable for further usesetContentView(v);//Make this view the current view. This means that whenever the view is invalidated its onDraw method will be called}Android AnimationExample (1)
  13. 13. Android AnimationExample (2) public class HypatiaAnimationView extends View implements AnimationListener {String themessage="Reserve your right to think, for even to think wrongly is better than not to think at all.";public HypatiaAnimationView(Context context) {super(context);paint = new Paint();paint.setColor(HypatiaBasicAnimationActivity.colors[HypatiaBasicAnimationActivity.colorno]);HypatiaBasicAnimationActivity.colorno=(HypatiaBasicAnimationActivity.colorno + 1) %HypatiaBasicAnimationActivity.colors.length;// TODO Auto-generated constructor stub}Paint paint;//The paint object for the drawing@Overridepublic void onDraw(Canvas canvas){super.onDraw(canvas);if (hypatiaanimationset == null) {//If the animation set is null, create it//***********************Create the Animation Set****************************{hypatiaanimationset=new AnimationSet(true);animation = new AlphaAnimation(1F, 0F);animation.setRepeatMode(Animation.REVERSE);animation.setRepeatCount(Animation.INFINITE);animation.setDuration(5000);animation.setAnimationListener(this);
  14. 14. Data Access inAndroid• Android comes with a inbuilt SQLitedatabase.• SQLite is a software library that implements aself-contained, serverless, zero-configuration,transactional SQL database engine. SQLite isthe most widely deployed SQL databaseengine in the world. The source code forSQLite is in the public domain.
  15. 15. Main Feature of SQLite Main Feature of SQLite:- Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures. Zero-configuration - no setup or administration needed. Implements most of SQL92. (Features not supported) A complete database is stored in a single cross-platform disk file. Supports terabyte-sized databases and gigabyte-sized strings and blobs. (See limits.html.) Small code footprint: less than 350KiB fully configured or less than 200KiB with optional features omitted. Faster than popular client/server database engines for most common operations. Simple, easy to use API. Written in ANSI-C. TCL bindings included. Bindings for dozens of other languages available separately. Well-commented source code with 100% branch test coverage. Available as a single ANSI-C source-code file that you can easily drop into another project. Self-contained: no external dependencies. Cross-platform: Unix (Linux, Mac OS-X, Android, iOS) and Windows (Win32, WinCE, WinRT) are supported out ofthe box. Easy to port to other systems. Sources are in the public domain. Use for any purpose. Comes with a standalone command-line interface (CLI) client that can be used to administer SQLite databases.
  16. 16. A Simple Android SQL LiteProgram(1) android.database.sqlite.SQLiteOpenHelperThis class needs to be subclassed to provide for creation of the database.It has two methods@Overridepublic void onCreate(SQLiteDatabase database) {//Called when the database is created.}@Overridepublic void onUpgrade(SQLiteDatabase database, int oldversion, int newversion) {//Called when the database is upgraded.} android.database.sqlite.SQLiteDatabaseEncapsulates a connection to a SQLite database and provides methods for sending queries to theDatabase and recovering the result.android.database.Cursor This class provides methods for accessing the results of a select query.It can be compared to thejava.sql.ResultSet.
  17. 17. A Simple Android SQL LiteProgram(2) if(b.equals(bttncreate)){try{database.execSQL( "create table HypatiaBooks(bookname text primary key,price integer not null )");txtResult.setText("Table Created");}catch (Exception ex) {// TODO: handle exceptiontxtResult.setText(ex.getMessage());}}if(b.equals(bttninsert)){try{String bookname="" + txtBookName.getText();bookname=bookname.replaceAll("", "").trim();String price="" + txtPrice.getText();price=price.replaceAll("","").trim();database.execSQL("insert into HypatiaBooks values(" + bookname + "," + price + ")");txtResult.setText("Data Inserted");}catch (Exception ex) {// TODO: handle exceptiontxtResult.setText(ex.getMessage());}}}
  18. 18. A Simple Android SQL LiteProgram(3) if(b.equals(bttnselect)){try{String bookname="" + txtBookName.getText();bookname=bookname.replaceAll("", "").trim();String[] columns={"Price"};String selection="BookName="+ bookname + "";cursor= database.query("HypatiaBooks", columns, selection, null, null, null, null);if(cursor==null){txtResult.setText("No Data Found");return;}if(cursor.moveToFirst()){int price=cursor.getInt(0);txtPrice.setText("" + price);txtResult.setText("Data Selected");}elsetxtResult.setText("No Data Found");cursor.close();}catch (Exception ex) {// TODO: handle exceptiontxtResult.setText(ex.getMessage());}}
  19. 19. Web Services inAndroid• A Web Service is a XML based system forimplementing Remote Procedure Calls.• It uses SOAP , the Simple Object AccessProtocol for accessing the Remote Object.• The WSDL or Web Services descriptionLanguage is used to describe the methods inthe Web Service.
  20. 20. Web Services inAndroid @Override    public void onClick(View arg0) {        // TODO Auto-generated method stub        try        {        String namespace = "http://tempuri.org/";        String url ="http://hypatiasoftwaresolutions.com/HypatiaQuotesService.asmx?WSDL";            String soapaction = "http://tempuri.org/getBirthday";        String methodname = "getBirthday";        SoapObject request = new SoapObject(namespace, methodname);             request.addProperty("name","" + txtname.getText());        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);         envelope.dotNet=true;        envelope.setOutputSoapObject(request);        HttpTransportSE androidHttpTransport = new HttpTransportSE (url);                    androidHttpTransport.call(soapaction, envelope);            org.ksoap2.serialization.SoapObject resultsRequestSOAP =(org.ksoap2.serialization.SoapObject) envelope.bodyIn;            txtBirthday.setText("" + resultsRequestSOAP.getProperty(0));        }        catch(Exception ex)        {            tv.setText("" + ex);        }    }}
  21. 21. Conclusion Android is a truly open, free developement platform based on linuxand open source. Handset makers can use and customize theplatform without paying a royalty. A component-based architecture inspired by Internet mash-ups.parts of one application can be used in another in ways notoriginally envisioned by the developer. can use even replace built-in components with own improved version. This will unleash a new round of creativity in the mobile space. Android is open to all : industry, developers and users. Participating in many of the successful open source projects. Aims to be as easy to build for as the web. Google Android is stepping into the next level of mobile Internet.
  22. 22. THANK YOU……..

×