Google app making course

Google app making
Google app making

Google app making

Hi, now that you know exactly what Android is, let’s just create our first application in Android. To create that, you will be opening up your Android Studio and you will be presented with this window. And once you have downloaded all the SDKs, then you can go ahead and design your first application. Click on the <i>start a new Android Studio Project</i>. Here you need to give the application a name. Let me just call it <i>MyHelloFirstApp</i>. And this is your company domain name, it can be anything you’d like it to be. In my case, it’s <i>com.example.demouser</i>. Combining this Company name and Application name, your package name will be formed. Make sure this package name is unique because when you’re going to upload your APK at the end, that APK package will be checked out by your Google Play Store. If it is not unique, at that point in time, you might want to change that package name. If you try to put this<i>com.example.demouser</i>, is has already been taken by Google, for example, you can’t upload an application like this. Let’s say you put <i>com.planet.MyHelloFirstApp</i> and that domain is also taken by somebody else, then you cannot upload it. It has to be unique. Next, this is your project location,for our example purpose we are going to use this package name only. This is the project location, where our project is going to be saved. You can change it if you like. Click on <i>Next</i>. Then you have to select minimum and maximum SDK here. Maximum by default will be that latest one that is 25 API or if you’re using 24, 24 API. And then there will be a minimum you will have to select. I could have gone all the way down to nine and you can see I will be targeting approximately 100% of the devices, right now, in the market.

The problem here is the more I go down the more I’m sacrificing the features. Because the <i>Gingerbread</i> will not contain all the features which my Android API 25 contains. Of course, even if I am selecting 15, 15 will not contain all the features which my API 25 contains, right? But till 15, I can get the Android Support Library, that is the external leverage provided by the Android Framework and you can get those libraries to support those features up until a version. I cannot get support libraries below– all the way down to the 2.3. So that’s why you need to make a balance also, and you can see while I’m selecting <i>API 15</i>, I can still target 97.4% of the devices. That’s a good thing. Go to <i>Next</i>, then you will see all of these templates, you can select any of these templates to start your Android application development as we are starting our very first app and we are going to start from scratch. I will click on <i>Empty Activity</i>and press <i>Next</i>. Give the name of that activity,I’m going to call it <i>Main Activity</i> only. That’s it. You can give any name, whatever you like, this will ensure that you’re creating an activity name that is the Java file, plus the layout that is the XML file. It will create a layout file,if you don’t want that, unchecked this. But you definitely want the UI bar of your activity also, how, exactly activity will look like on the screen. You want that,. And then there is a <i>backward compatibility</i> checked.

Turning this on that means your activity will be extending <i>AppCompat</i> activity. If you uncheck this then your activity will be extending <i>extended activity class</i>. So <i>backward compatibility</i> is to make sure that even the previous versions are able to access the new features which are there in new versions with the help of support libraries. Press on <i>Finish</i>. Let the <i>Gradle</i> build.<i>Gradle</i> is a building tool here which is used by your Android system to build your application. Please, wait for <i>Gradle</i>to build your project first. If you try to keep on clicking here and there, your <i>Gradle</i> might crash. You need a pretty fast machine for <i>Gradle</i> not to crash. So let the <i>Gradle</i> build, once the <i>Gradle</i>– you’ll see down below “indexing is done”and <i>Gradle</i> is built, after that, you can see this is the Java file that is <i>MainActivity</i>, the Activity in Java file, and this is the Activity’s layout file. That is the XML file. This is how your first application will look like. Now before doing anything else,let me just run this application. To run this application, first of all, you need to create a virtual device. How can you create a virtual device? There’s this icon, AVD manager,known as “Android Virtual Device”.

Click on that. Ei<i>ther there will be a by default</i> virtual device created for you by Androidor you will be seeing this screen. You can even delete that <i>Virtual Device</i>and come to this screen. Click on this button, and select one of the resolution device which you want to work on. That’s a <i>Nexus 5</i>, screen resolution 1080×1920. If you want to work with this kind of resolution, go ahead. Or if you want to work with any other resolution you can select that too. Press <i>Next</i>. Then it asks you what should be your system image, which system image you want to runon your virtual device. Now, here it will only show you the system images that you downloaded, at the time of downloading from your SDK manager. In mine, you can see there is a 23 and a 25, so I will go with 25. I’m using <i>x86_64</i>that too with Google API. If you don’t want to use this Google API, then you can go with normal <i>x86</i> but then you must have downloaded that system image here. Other images. Any ARM or image if you want to work with that too. but I wouldn’t recommend the ARMas they are very slow. I’d recommend–I’m using the latest one, To Google API, press <i>Next</i>. You can give the name of your device or virtual device anything you want, let’s say <i>Black_Knight_01</i> and press <i>Finish</i>. Here you see my device is ready, all I have to do is press the <i>Play</i> button. Launch button and it will launch the emulator. Wait some seconds and you can see the emulator will be up and running in a bit. <i>x86</i> emulators are way faster as compared to your ARM. If this would have been an ARM machine, it would’ve taken a long time to run. This won’t take hardly a minute to turn on and I would recommend once your emulator is on, whenever you’re developing,do not close your emulator. Unless you are done for the day or done with the development for the day, why ?

Because every time you close your emulator and run it again it will take the same time to launch the emulator again and again. So what you can do here is just run it once and then after that, keep on running your application from your Android Studio and they will directly go on your emulator. So your emulator doesn’t have to restart or get the resources again. How will you do that?As you can see, my emulator is running, What I would do to run my application is here, you can see a <i>Play</i> button launch button, or run button. Just click on that. My Android Studio automatically detected that there is a device connected to me, that’s called <i>Black_Knight</i>. Press on OK. And this application will run on my Android device. Just wait for it, <i>Gradle</i> will start building. If there is any error or something, that also will be detected at this point in time. There we go. So this is my very first app,which I have created from the Android App Studio. Even if you close your app now,you go to your apps, you can see your app here. You click on this, so it’s just behaving like any other app. Now before moving any further in Android, let’s just learn a little bit about your Android Studio ID, etc. The left bar is known as project panel, we will come to that. This middle area is known as code area, or you can create your layout also hereby dragging and dropping. The middle part is known as your console. This is where you will be seeing what is going on with your Android. I just ran an application here, in my Android Virtual Device. So it gave me what was going on,this was the run mode, what was going on with my application in run mode. But you can go to your Android monitor,also you will see a <i>logcat</i>.

<i>Logcat</i> will be your friend throughout your Android application development because it tells you what is going onion your Android Virtual Device. Okay, so now you can see here, this part here is known as project panel, in this, what you are seeings the Android Project Data Key. We’ll talk about other project data key but when we talk about Android Project Data Key, you will see your project is divided in two parts, one is your app folder, and the other one is your <i>Gradle script folder</i>. Let’s just talk about <i>Gradle’s script folder</i> first. When we open up our <i>Gradle</i> script,you will see that in <i>Gradle</i> there are mainly three types of <i>Gradle</i> file, one is called <i>ProjectMyHello.Gradle</i> which will contain nothing but the information about my <i>Gradle</i> version itselfas you can see which <i>Gradle</i> I’m using right now is <i>Gradle 2.2.2</i> and include all the repositoriesin this project. Second <i>Gradle file</i> which we will be seeing is module level <i>Gradle file</i>. As I only have the mobile module here so there is only one. If there would have been an Android <i>wear</i> then there would be a wear also. If there would be TV, then there would be a TV module file also. So there is only one, what exactly it contains it contains the information of all the module itself. What is the minimum version of SDK I’m going to use, what is the target version for this SDK, what is the application ID, the compilation SDK version,so all that information will be included in this module-level <i>Gradle</i>, Even the dependencies you want to add that is libraries and all– that will also be added in this. As you can see there are this many libraries as of right now.

I’m using the <i>Espresso libraries com</i>, and the <i>com support</i>, there is app compact support libraries also, I’m using <i>JUnit</i> library also. If you want to add any external leverage that also will be adding inside dependencies on it . So that’s what the use of the module <i>build Gradle file</i> it [inaudible] and gives you the information about that particular modules. Next <i>settings.gradle file</i>, it’s again one file per application. It tells the compiler which module has to part into the compilation at any particular time. For example, if you have a better application designed also for your mobile, TV, and wear, and your TV, and wear are still not complete for the production level. Then, when your mobile app for <i>wear</i> is complete then you can include the moduleof mobile here only. Like this, mobile. Then the name of the <i>Gradle file</i>, like, right now, it’s <i>app</i> here, it will be mobile. And if there is a <i>wear</i> also,then we will be putting <i>wear</i> too. Like this: <i>wear</i>. If there would be a <i>wear</i>that’s the condition, that there is a <i>wear</i> module too. Okay, so as of right now, there is no <i>wear</i>, so it’s only just one,that’s why this <i>setting-gradle</i> file contains only app because that’s the only <i>Gradle file</i> you’re going to compile whenever you’re going to run it. Okay great, so that was <i>Gradle scripts</i>. Now let’s talk about <i>app bar</i>, in the <i>app bar</i> you will see mainly three folders. First is your manifest project. Inside this you will find a file <i>android manifest.xml</i>, this is the file which comes in contact with your Android device for the very first time when you install your application. So when this application is getting installed in any emulator or device, this is the file that will come in contact with your Android device for the very first time. What exactly it contains,it contains the information about the application itself, like the package name, what’s is going to be my package name, the application’s information like how many screens or how many activities it’ll contain. If there are more screens, then you have to register them here, only, again if there is another activity, there will be another activity tag. Or if there is more services then there will be more services tags. And it will also include the permission,let’s say your application is going to contain any permission like internet permission, or access netbook permission or GPS permission.

You need to declare those permissions here inside this manifest file only. Let’s say, I want to include the internet permission I will use this permission, internet,and there you go. So this is how your permission gets added also. So that was Android manifest. In the manifest file you can see there are many attributes, like <i>AllowBackup</i> will make sure that your application is compatible for backing up. And icon attribute here is getting the icon from <i>@mipmap/ic_launcher</i>. I will talk about this <i>@mipmap</i> in a bit, but know that this here is getting the icon… Or this label attribute also is getting the text from your resource folder. We’ll talk about how it’s getting there. <i>SupportRTL</i> is again right to left, there are language which go from right to left so this applicationwill support RTL language too. And <i>theme</i>, I’m getting this style from resource folder we’ll talk about that also, but knowthese attributes are setting… This one is setting the icon to my application this one is setting the name or label to my application and this one is setting the style to my application. Now let’s just go to our Java folder. When you open up your Java folderyou will find three package, First package is know as development package. Second package is known as Android test package or instrumented test package. Third package is known as unit testing package. The first development package you will put all the code for your application development. This is the package which you’ll be dealing a lot when you’re doing the Android application development.

All your activities, services, broadcasts, content providers, database classes, all those classes will be kept insidethis development package only. As you can see there is only one activity right now, that’s <i>MainActivity</i>, if you open up, this is how your <i>MainActivity</i> looks like. Inside your <i>MainActivity</i>, you can see that– activity is nothing but a class which is extending <i>AppCompatActivity</i> and this <i>AppCompatActivity</i>is being inherited from or is taken from your Android support library. As you can see, App Compat Library is important for your <i>android.support.v7. app</i>. Now if I would have done activity also, then, also syntactically, there would be no problem because ultimately, this is activity only, right ? I’m designing for the latest version then the features like material design all the new features, will not be supported by the previous version if they are not included there. So that’s the reason I want to dothe <i>AppCompatActivity</i>. Inside your activity, you can see there’s a method I’m using, an overrides method called <i>OnCreate</i>, so that <i>OnCreate</i> method is already defined inside <i>AppCompatActivity</i>and I’m just overriding it. And inside this, there’s the very first statement I’m doing which is <i>super.OnCreate</i>. <i>Super.OnCreate</i> will make sure that before I do anything, before I do any customization in this particular method I want to use all the functionalities which was there in my parent activity. I don’t want to temper with the functionality which was provided to me by my Activity class, the <i>OnCreate</i> functionality which was provided to me by Activity class.

I want that. Plus if I want any of my own functionality that I would be includingafter including this statement. Once I include this, then I’m including my own statement that is <i>SetContentView</i>. I’m providing a particular view to my activity and that I’m also doing with <i>R.layout.activity_main</i>. Just for now, understand that I’m attaching my layout file here. I’m attaching this layout fileas you can see, <i>Activity_Main</i>, <i>Activity_Main</i>. I will discuss into more detail in a bit on how exactly it’s getting attached but you can see <i>activity_main</i> is the file which is getting attached to this particular <i>Main Activity</i> here now. So that was the development package and that was the <i>MainActivity</i> file. In other packages like Android test, you will see the files which are used for UI testing here all the UI testing class will be put inside this– All the <i>JUnit</i> classes testing, all the classes for <i>JUnit</i> will be put. So that was the Java folder. So the Java folder will specifically contain all your coding bar. Now let’s just come to <i>res folder</i>. Now, <i>res folder</i> is a very important folder in your

Android application development is not just about Java, it includes your resources and they can be images. Resources can be layout files, XML files, any <i>values resources</i> that you are providing [hard-coded]. So let’s talk about them in more detail. There will be a <i>res folder</i>and inside that <i>res folder</i> there will be some dedicated folders like <i>drawable</i>. <i>Drawable</i> is a folder which will be used to include the images. Generally the draw able– Each and every folder you’re gonna design inside your <i>res folder</i> will have a specific purpose. So the draw-able here is used for your images or if you have any animations, selectors. For those kind of things you will be using the <i>drawable</i>. You will be seeing more of it in your folder’s sessions what exactly this <i>drawable</i> foldercan be used more for. For now, understand that all the images and animation parts you’ll put here. Next is your <i>layout folder</i>. <i>Layout folder</i> is a folder where you will provide all the layout for your activity. All the UI part, any layout you want to show to your screen this is the folder where you want to design. So that file which you just saw,this is where it resides. <i>Activity_Main.xml</i>, any XML file you’re seeing, any layout file you’re seeing, they are in your <i>layout folder</i>. You can see that this layout hereis the drag and drop screen. That is called layout, there you can drag any button right now, and place it where you want. This is the Drag &amp; Drop bar,when you click on the text tab here you will be able to see the coding part, and the XML part also.

We will discuss about the coding part and how exactly you can deal with these XML parts for the session. But for now know that : in layout folder, all the layout file exists and you can edit the layout of these XML file with the app <i>Layout Editor</i>. Next is your <i>mipmap</i>. <i>Mipmap</i> is a folder which is, again, used for your images only but here you can put the different screen resolution images together. As you can see, the image here is known as <i>ic_launcher.png</i>. Each and every image is named the same here, like <i>ic_launcher.png…</i> but you can see the difference is the resolution. There will be images which will be– This image here is high pixel image, then there is extra high pixel image, then there is extra, extra high pixel image,so the resolution changes. If you have an image of a different resolution, you will put it in the <i>mipmap</i> by putting the same name. If my image name is logo and I have five different resolutions of logo I will put logo only but the resolution will be different. Like one maybe 42×42, other maybe 72×72 and other one, maybe,extra high 128×128. So automatically, it will create a folder which will define my high densitypixel image differently, and medium density pixel differently, and extra high density pixel image differently. So what are the use of it? If you run your application on any device which uses extra high density pixel, you don’t have to specify or put in the code that use this image. It will automatically adjust that, “okay this is my extra high density pixel device”. It will automatically pick this image only. That was <i>mipmap</i>. Now let’s talk about values,now values is a folder where you generally put all your other resource which you want to put or show to the users, like colors. <i>Values</i> is the folder where you want to define your different resources, to make the localization. So you don’t have to define those resources again, and again. It may be any string value,or any title, or any color also. As you can see, I defined a color <i>file.xml</i> separately and then defined the color tag. Remember that any resource you want to define, you have to use the resource tag first. So now this will be a resource,this color will be a resource and the name of the color by which I’m going to access it anywhere, is now <i>ColorPrimary</i>.

The use of this will define the resources, let’s say, this is the color right now. As you can see, the color is 3F51B5. I don’t have to remember this color code or hashcode again and again. And I can directly use this <i>ColorPrimary</i>wherever I want to use it. In a bit we are going to see how exactly we can use it. In the second uses, let’s say tomorrow your boss says “I want to change this color”. Instead of <i>ColorPrimary</i>, you define one more color here, and that color is <i>Title_Color</i>,let’s call it color. You define a color called 99ccc– So, 99cc00. Okay so this is my <i>title color</i>. Let’s say tomorrow your boss say, “we’re going to change our title color”. So you don’t have to goto each and every place where you had used this hashcode. If you would have done hard-coded here, you’d have to change the hashcode in each and every place. Here you are just going to change the color here and wherever you’ve used this name there, all those places will be receiving the changes. So that’s the beauty of defining the resources here. So in this way I have to find resource colors only here you can see <i>ColorPrimary</i> <i>ColorDark</i>, <i>ColorAccent</i>and <i>ColorTitle</i>, right ? One more thing I want to point out here,anything you put in your resource even a image, even a layout file, even all these color which I’m putting here right now,anything you put in your <i>res folder</i>, they get a registry inside a filenamed as <i>Android Java file</i>. <i>Android Java file</i> is a system generated file which is being provided to youby your Android system itself, or the Android application itself,so you don’t have to create it but whatever you do inside the <i>res folder</i> that will get entry inside the hard-coded Java file. As of right now, the color which I have just defined, the whole entry plus the <i>ActivityMain.xml</i>should also have entry and all these <i>mipmap</i>should also have a entry. Let’s just check that out. You won’t be seeing <i>R.java file</i>inside your Android data key.

For more information you can see above photo or just click on below given link to get real knowledge

https://developers.google.com/training
All information of App Making is in the word best online platform google please learn.

Leave a Reply

Your email address will not be published. Required fields are marked *