 Good morning again, I am Pradhna and as I mentioned during the overview of workshop basically the goal of this workshop is to make every one of you able to develop some small applications for Akash tablet. So at the end of this workshop we expect you to come up with some nice educational applications for tablet and definitely I mean Phataksar has already given you incentive that you know there will be a cash prize and lot of other things. So definitely please help us to build a Akash community which will contribute towards the educational applications. So let's start this great course with a great introduction. Yeah so the under introduction see basically the introduction to Android would be like FYI session for you. It will I mean tell you what all happens behind this great you know cool technology. So in students language it will be a like theory lecture I am like but I will promise you that you know I won't torture you that much. I will minimize my torture from my end so please bear with it. So let's start with it so the contents which we will cover is the introduction what is Android etc. The Android version and API level very important point as a developer to know what your device supports which version and API level a very important part otherwise your application won't run on device. A big picture is nothing but a how Android stack looks like then the comparison of Dalvik virtual machine and Java virtual machine this Dalvik virtual machine is a very interesting part what Android people came up with and this is why Android is so fast. Then next is Android features some out of box feature what Android provides then application fundamentals we have .apk file which we install on Android device. So what is this .apk we will look into that then Android application components these are basic programming building block so as a developer you will always deal with these. So this is important for you to know so let's go next. So what is an Android it's a well-known Linux Vix OS primarily for touch screen mobile devices like smartphones tablets it was initially developed by Android INC and then purchased by Google in 2005. So in Google so Google started working on DVM in 2005 and then after 3 years they came up with first Android device in 2008 and rest all is history all of us know how popular Android is today. Next Android is open source and Google releases its code under Apache 2 license. Now this is the important feature why Android is so popular in the market because it's a open source so and it is released under Apache 2 license. So Apache 2 license says is you know you derive your code from the original work you can use it for any purpose you can modify it you can redistribute it. So whatever these hardware manufacturers are like HTC, Micromax and lot of others what they do is they just customize the Android for their own purpose and they just redistribute it. So the cost for this is 0 no licensing no paying of royalty nothing so that's why Android is so popular in the market because of the cost saving and last is a Google Play Store a very useful place for you people if you want Angry Bird app for your Akash tablet this is a place you should visit. Basically you will have all kind of Android applications at one place which is a Google Play Store you just think of anything and you will have app for that. So open Android what it means to be open and why would you care. So basically I have given this link I am not sure whether it is visible for you or not this is the Apache 2 license link so those who are interested to do that you can go and you know check out what are the terms and conditions to do it. So what do you mean by it's a open Android as I had already told you it's a open source Google is releasing its code under Apache 2 license you can use this code for free of cost nothing need to be paid. So you know that's why it is so popular the brief history of Android this is basically for just for reference when different Android version came into the market like if you just glance through this in 2009 it was from Cupcake to Eclair then 2010 from Froyo to Gingerbread and if you just observe these are like alphabetical names of deserts I don't know what it what made to them to make this desert names if you see that this is a picture representation of these versions this is still what we had till 2010 now then in 2011 it was Honeycomb then ICS and our Akash tablet has have ICS version I will show you how to check the version of the device and 2012 the latest update is Jelly Bean we just go and show you. So again a representation all desert names they have provided so yeah so this is about the versions and next is a API level so what is this API level basically API level is a unique integer identifier for API framework again now what is API this is application program and interface so in normal language API is nothing but you will have lots of classes lots of attributes to use which you can use in actual code so these what is why do they need I mean and revision of API so definitely with each API level there will be some plus minus and then they have come up with a revision of each API level so whenever new API comes into the market it's always a additive change the old won't be removed it will be deprecated which means there is something new better available in the market which you can use so if you try in the eclipse editor and something comes as a strike through if you try a class name and something come as a strike through like a new I guess notification manager class so that's a deprecated one and if you get that that's a which means that there is something better available in the market which you can use so in new API the better has been made available for you so what I want to emphasis on is the API is a additive change old won't be removed but yes it may be deprecated so for each version there is a corresponding API level so for our approach tablet we say we come at this level that is 4.0.3 and API level is 15 and version name is ice cream sandwich and the rest all is for your reference I have mentioned the all versions and corresponding API level you can go through it later on depending on device on which you want to code you want to support your applications you can go ahead with it this is nothing but API level grouping basic basic based on the need why it developed the first API was specially for smartphones then the 3.0 to 3.2 came for tablets and from android 4 onwards android is everywhere let it be smartphones tablets just think about it and it is there so let's move ahead the choosing API level why I mentioned it is important because it depends on device support basically you are you need to know your device device is on which version and corresponding API level I mean so the application in corresponding API level will only work on the device and there is a something called as application forward compatibility and backward compatibility this is pretty logical so for example if I have a device which has a version 4.1 Jelly Bean and I compile my application using 4.0 that is ICS so it will work on my on my device but vice versa may not be true which means I have a device which is 4.0 and I compile my application in 4.1 and if I try to run on device it may not work for obvious reason that each API has additive change something new if you have used that new functionality of API and trying to run on the old API level it won't work simple reason so pretty logical but important to understand the next is a version in Akash tablet I'll just quickly show you how to check it let's go to the settings I'm just going to settings then in settings there is about tablet so can you see this Android version 4.0.4 this is what I'm talking about you should check your device version and then only start programming and also one more thing there is a kernel version 3.0.8 this is important if you want to have you know Android custom image for your device but let's not go into that right now let's come back to the slides the big picture this is actually really big it's not coming in the one screen so I mean you can get this diagram on developer.android.com but let me just show you that there are three different colors and three different stacks so what we'll do is we'll go to bottom up the bottom most stack is a Linux kernel then there is a libraries and then application framework where your application actually sits we'll go through the one layer one by one layer because it's not anyway visible in this diagram so let's look at the red layer the Linux kernel so as I have already told you and most of us already know that it runs on the Linux basically it gives its hardware abstraction layer so why Linux several reasons again Linux is a open source lot of things have been already explored about the Linux so it gives a advantage second Linux has a such a strong kernel such a strong driver model which makes even Android a portable OS because I mean as all of us know Linux runs on any platform you just name it and it runs so the objective of Android was also to run on the many many different devices and this both both objective came together that's why the they have chose the Linux as a user you will never see the Linux subsystem you will always see the top layer that is applications the Linux is doing its work at the bottom why what is its doing why it is important we'll just see the later part of this session then there is an Akash tablet I have already shown you Linux kernel version is 3.0.8 and there is a command using which you can open up at the Linux shell this is a ADB command it's Android debug bridge basically a very versatile useful command tool which connects to your emulator or your connected device I mean we will have dedicated session on this on day 3 and a very useful tool which gives you access to the Linux shell and to do lot of things the session would be conducted by Shrikan on third day and it would be a really useful session for you to under to you to attend then next is a green layer so on the red layer the there is a green layer which sits the libraries so these are basically bits and pieces which Android people just you know borrowed from different open source projects and made available in Android so if you check out OpenGL this web SQLite webkit you must have already heard it with context of different programming languages for example OpenGL is widely used in C++ whatever games you see those are mostly developed using C++ in OpenGL so these are just libraries which Android people borrowed and made available on Android on the right hand side what you see is a pretty interesting part that's a Dalvik virtual machine a very well talked about basically Dalvik virtual machine is a substitution of JVM what we have in had in Java you must have seen in earlier session there was a diagram where you know JVM was running the Java bytecode so Dalvik virtual machine runs its Dalvik bytecode why it is required we already had JVM etc we'll just see this after this slides and as I mentioned these are open source library used for different different purposes webkit for fast HTML rendering OpenGL for graphics media codex to support the media framework maximum most popular media framework is supported in Android then SQLite data but this is a permanent data storage how you can store a data on Android we will have a session on this also let's complete our architecture diagram first in the blue layer our application framework and application so as a developer you will deal with these two maximum time you will avail the services services provided by the application framework in your applications like activity manager so I mean in simple terms activities something on a screen with which user can interact you know anything I mean which needs a user interaction so whatever applications you see for example an angry bird application so you know it needs that user to pull that and release it so that's again an activity so what does why this I'm a lot of emphasizing on activity because this is what you will develop in a next session a basic Android application program will have an activity will have some user interaction I mean that's why because we are dealing with a touch screen environment so everything has to be with related to user with you know comfort of user so activity is important part these are this is just two diagrams to understand what happens at the background I mean consider an email activity so you open a email application you get a inbox right you go to the compose email so so the inbox activity calls the compose email activity so which means what happens at the background suppose my main activity is my inbox activity which is calling the compose activity so this so the main activity gets stored on the back stack and the activity to is pushed in so this follows last in first out a normal stack operation and what happens activity to that is my compose email is visible on my screen and my main activity my inbox activity is in the background so what happens when user clicks on the back button when user clicks on the back button the main activity but becomes a visible that means my inbox will be visible sorry my inbox will be visible and my compose compose email activity would be popped out from the back stack so I just wanted to know make a note of it that you know this is everything is getting handled by the activity manager by your application framework services I mean you don't need to think about that okay I need to store my data I need to show this activity then I need to store you know which activity I had shown last no activity manager is doing everything for you is just that avail its use its services and just do it in your application it is that simple there are several other managers available like content providers content provider basically gives you the data which is shared across the applications if multiple applications wants to share some common data then this is the place which you would like to go then there are other things like notification manager if you have a smartphone you must have already noticed you get a lot of notifications that you know you have a miss call the battery is low so there is everything gets handled by the notification manager and on top of this are those are our applications what you actually see you must have seen in tablet also there is a default browser there is contacts there are a lot of other things so that's it about the architecture let's go next that this is actually to show the how process differs in Java and the at Android in Dalvik virtual machine so basically at Java what we have is you have already seen let's just see the left hand side diagram let's concentrate on it the Java source code that the compiler byte code Java byte code runs on the JVM straightforward what happens at the Android site at Android site we have a Java source code we have a Java compiler we get Java byte code then there is a DX compiler a special compiler which converts it to the Dalvik byte code and this Dalvik executable runs on the DVM now this is what marked in red is a something new steps which Android people introduced why it is required basically a Java compiler rather Java byte code itself is a very verbose code a very heavy code if you try to decompile Java byte code you will get everything back as it is right from your code your resources your things everything so I mean this is not possible to run on the smartphone on it or a tablet where you know we have a power issue a power optimization is required you cannot run applications which are very you know consuming heavy powers you have to consider that so that's why they come up with this DX compiler and this optimized code this opt this code basically optimizes Java basically Dalvik byte code optimizes the Java byte code at several layers and if you try to decompile basically to decompile Dalvik byte code is pretty difficult and if you succeed in that you won't get your Java source code back there will be lot of you know assembly code which you have to do lot of other things to get your code back so basically it does a lot of optimization to give you a small and optimized code let's go next very talk you know well known sorry a very well known difference between the DVM and JVM so why I'm emphasizing so much on DVM JVM see because it's it's important to understand that's yes Android is based on Java yes it follows Java syntax yes but there are some difference differences than the Java and this is a major important difference because if we start using JVM on tablets and smartphones your application will start crash definitely so this is important then so DVM follows a register base architecture so being I guess engineering student you must be able to understand what is a register base and JVM follows a stack base I just have a small example to show you what is register base and stack base so basically this is a stack base so here is my program I'm just adding simple two numbers I have my stack pointer stack pointer is here right and just to add simple two programs I need these four lines of instructions that is pop 20 pop 7 at 20 and 7 and store the result and push the result back so 27 is pushed back so just to do to just to add two numbers I have to you know follow four lines whereas in register base what happens is a single line of instruction will do your work add R3 R1 R2 R3 is my destination R1 R2 is my source so you know add R1 R2 and store it in R3 this is a diagrammatic representation so it is adding 5 and 30 and storing it in 35 so what happens in register base is you need to give directly the address of register we need to give the register name over there so the length of instruction definitely increases but the number of instruction decreases that's why DVM follows the register base architecture because it has the less number of instructions so here is a difference clear number of operations in DVM would be fewer as it follows register base in JVM it would be more because it follows stack base and the file format I have already talked about CJVM it is known dot class basically this dot DX is a Dalvik bytecode so your source code in Android gets compiled to the dot DX instead of class because of the Dalvik compiler I have already shown you because there is one more step this is Dalvik bytecode and this Dalvik bytecode nothing but dot DX file so we have covered this this let's go ahead so as I mentioned to you yes Android is based on Java it follows Java syntax it follows lot of things in Java but there is difference so Android Java consists of Java standard implementation minus AWT swing plus Android API so AWT swing if you have worked on it in Java it's not supported in Android it's completely removed they have come up with their own UI which is part of Android API and why this Android API was added because of touchscreen I mean we need a extensive touchscreen support when we are dealing with Android because we are talking about the smartphones and tablets so this was this was required so they just removed this AWT swing and added an Android API so this is how the the standard Java and Android Java differs so you will see lot of Java APIs in Java is not supported in Android this is the reason so let's go next these are some out-of-box feature what Android gives out-of-box feature what Android gives us like application framework enabling reuse and replacement of components now this is pretty interesting feature to understand as a developer so what what it mean by it is there are so many applications already available out-of-box for you so whenever you want to use any application you don't need to code for it for example in my application I want to use a camera my application requires that camera should be open it should click a picture it should give me back I don't need to write a code to access the camera store the image nothing it will be handled by the camera application altogether there would be a intent or rather you can say there would be activity which will do it for you you just need to call it in your program so this is a reusability it uses I mean extensible reuse reusability framework in it and it is you will see that you know there are so many complex applications but they are so pretty to so easy to code so this is about the application framework reusability then we have already seen the Dalvi DVM then there is optimized graphic support it has to be there it the UI has to look very cool and attractive so I optimized graphic support like 2D 3D open GL support there is a SQLite for the permanent data storage we will have dedicated session on SQLite how to access how to store data a very useful one then the I already told you there are almost popular media formats are supported in Android then there is a these three feature the last three feature depends on your hardware manufacture so if they have given it then only you will have it in device that is a GSM telephony bluetooth 3G Wi-Fi direct hotspot camera so I mean you can just go see at the glance that you know how much is there in Android I mean whatever you think of it it is there I mean everything is supported is just up to you to how to use it so these are Android features and this is our Akash tablet features are Akash tablet feature ICS then optimized graphic support we have Wi-Fi which you must have already you know connected during the clicker quiz we have camera accelerometer SQLite media support and lots of them application fundamentals now see when we install our application on the Android device it is in the format format of dot APK which is nothing but application package file what you see you know I mean I don't want to relate I mean technically it would be incorrect but what you see on dot exe on windows what dot exe does it install something so similarly on Android happens with dot APK but technically it's incorrect to relate because dot APK is more like a dot jar file in Java it is a compressed format that's it so it's a like a zip package format which is based on the jar so basically your dot APK will hold all these things how your dot APK gets created you have a Java source code it gets converted to dot dex and after dot dex it gets converted to the dot APK so dot APK will have along with a code lot of other things there are resources what is the resources anything other than your code would be resource you know you want to play some video you want to show some images you want to play some file anything it would be in the resources similar with assets then there's some certificates if your device needs to sign then the manifest file manifest is a pretty important file in application because it's like a controller file you can say it defines lot of system properties it gives you know permissions to your application a lot of other things for example as I mentioned earlier I have an application where camera needs to be accessed so I have to give my permission in manifest then only this Linux kernel will understand that okay this application needs a camera so this is what dot APK holds and what happens once dot APK is installed on the device as I mentioned that you know all though as a user Linux kernel doesn't come into the picture at any layer but this is what it does once it is installed on a device every application will have its own user ID it will it will set in its own security sandbox it will have its own virtual machine it will have its own Linux process so if you see if you understand this every application will run in isolation compared to the other application so two application won't interfere with each other so it's a great security mechanism I know we are running out of time let me just cover up quickly rest all things Android application components now as I mentioned earlier these are basically programming building blocks in Android so you compare with the Java what will you think a programming blocks in Java a classes for desktop application JSP servlet for web applications now here we are talking about the completely different environment Android was developed for this touch screen devices which are smartphones and tablets so what do you need on this so you need something you know where user will interact user will touch something will happen you will need something where you know the notifications are coming that you know okay your battery is getting low you have a miss call you need something which is you know running in the background for example I am upgrading my sub software so this has been developed with that aspect it's not I mean with the Java aspect it's a different one so what is activity act so these are basically four blocks and let's just see quickly one by one because today in the evening you will have dedicated session on this where you will actually code this run it and see it on your device so basically activity is nothing but something which needs a user interaction it's a component which provides a screen with a user can interact in order to do something and it is implemented as a subclass of activity so your first program will start which will extends activity alright so next is the services services as I mentioned something is happening in background for a long time I'm upgrading my software so that's what the service is again implemented by a subclass of service then the content provider now content providers are interesting part I mean it manages shared set of application data I mean consider application which is a to do list I have marked a to do list and I have you know marked that okay I have to call someone at this time I have to do this I have to do this and if other applications needs to access that corresponding status that whether I have called that person or not I have I had my lunch or not then yes this is the this is the thing which you will need a content provider so you know my to list can share its status with rest all applications whenever required so this is a content provider implemented by subclass of content provider then there is a broadcast receiver it is a component that responds to the system wide broadcast announcement consider example if I have downloaded some file and all application needs to understand okay now for example any player I mean some VLC player is available for you so if I have downloaded that VLC player and all application needs to understand for example my custom application needs to understand okay VLC player is there I can play my video this is the thing I mean in your application you need to implement your broadcast receiver which will receive this notification that okay it has been downloaded it is ready to use and this is just a last slide for you okay this is the activity life cycle diagram a pretty huge one okay so whatever you see in the gray box it these are nothing but methods which you can actually implement for example it starts from top to and goes bottom as activity starts so first would be on the names are self-explanatory you can understand by reading it it's on create then on start so activity will be available for user interaction after on resume once you do the on resume then activity would be available for user to interact so it can go for on pause if you know some application with a higher priority needs a memory or it can go for a on stop on then on destroy so I mean you can see these are so important methods for you I mean we are talking all the time about the performance optimization the power optimization and etc so for example on on pause I'm using a file resource so I should release it I mean the first and foremost thing when you will deal with Android application is never preserve your resources whichever you are using always release it when it's not in use so you know on pause you can just release your resources you can release your file object so that will reduce the burden on the application and the power consumption so this is it I won't go into the detail now as we are running out of time so let's go to the summary this is all we have learned lot of things rather I hope it was a useful session for you and these are some references so basically you just need to go to developer.android.com this is a Bible for Android developer you don't need to go anywhere else this is the first and foremost kick start for you and yeah thank you so much for listening