Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: android-studio

Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: android-studio
Showing posts with label android-studio. Show all posts
Showing posts with label android-studio. Show all posts

Android Development Basic

Android Development Basic

Android Project Structure


Android Project Structure -

Before we Start to make our first Android app, we first see the basic parts of an Android application project, in order to recognize them and be able to understand them better.


AndroidManifest.xml

Androidmanifest.xml

 

AndroidManifest is A xml file Which information of our app. it contains : -

1. App Permission.
2. Our Running Activites which we have to Register in AndroidManifest.xml
3. Our Broadcaster
4. Our Receiver
5. Our Services.
 

Activities

android activity

 

The Activities are the main Java classes with a layout design file  , that contain the Android code with which we are going to develop, what do we want the application to do.

Res Directory

android res

 


Res Directory also called Resource directory where all our resource file be stored like design,layout,images,menu etc.

  

Layouts 

android layout

 

The Layouts are the xml files, that contain the Android xml code with which we are going to develop, how will our application UI look like.

Values

android values

 

The Values are Also XML file Which Contain The Values of Strings,Style, Colors in To Use them in Your App.

Following are Thing Comes in Values : -

– Animation Resources
– Color State List Resource

android color




– Drawable Resources

android drawable


– Layout Resource

android layout




– Menu Resource

android menu






– String Resources

android string



– Style Resource 

android style



Drawables 

 A drawable resource is a directory in res which contain our images,layout drawable,shapes , vector graphics.
Following are The Things Comes is Drawable : -

Bitmap File
-  A bitmap graphic file (.png, .jpg, or .gif). Creates a Bitmap Drawable.
Nine-Patch File
-  A PNG file with stretchable regions to allow image resizing based on content (.9.png). Creates a Nine Patch Drawable.
Layer List
-  A Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index is be drawn on top. Creates a LayerDrawable.
State List
-  An XML file that references different bitmap graphics for different states (for example, to use a different image when a button is pressed). Creates a StateListDrawable.
Level List
-  An XML file that defines a drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Creates a Level List Drawable.
Transition Drawable
-  An XML file that defines a drawable that can cross-fade between two drawable resources. Creates a Transition Drawable.
Inset Drawable
- An XML file that defines a drawable that insets another drawable by a specified distance. This is useful when a View needs a background drawble that is smaller than the View’s actual bounds.
Clip Drawable
- An XML file that defines a drawable that clips another Drawable based on this Drawable’s current level value. Creates a Clip Drawable.
Scale Drawable
-  An XML file that defines a drawable that changes the size of another Drawable based on its current level value. Creates a Scale Drawable
Shape Drawable
- An XML file that defines a geometric shape, including colors and gradients. Creates a Shape Drawable.


build.gradle

build.gradle is a file which contain information of our project library,modules,
application id,version name,version code etc.


build.gradle

 

Android Hello World Example

Start Android Studio and Create a new Project.

android hello world

 Select Minimum Api Level  (Api Level Means Which Lowest Android Which You Want to Run That App).

android  api

Android Activity (Selecting Here Simple Empty Activity)

android empty activity

Android Launcher Activity Name 

mainactivity

Android Project is Ready Now Click on Green Play Button To Run Your Android Project.

Make Sure You Created Your Emulator. 
Or Connected Your Device With USB Debugging is Permission is  (For Enable USB Debugging .
Just Go To Phone-> Setting -> About -> Click on Build Number 7 times .
 then back then you see a developer option just enable the usb debugging)

android project ready

Android Hello World Example. 

android devices
 

android hello world

Install Android Studio

Today For Some User It's Difficult To Setup Android Studio.

In This I Will Show How To Install Android Studio.

 
On Windows 
and On Ubuntu.

Let's Start
For Ubuntu : -
Install JDK 6 or Later. (Better To Use Latest Version)

command : -

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

Now Let's Download Android SDK from Here For Ubuntu.

https://developer.android.com/sdk/index.html

After Installing Java and Downloading Android Studio.

Now Extract The file to home directory.

For This.

Use : tar zxvf android.tar.gz /home/Your_user_directory/


Let set The Path For android Studio and Java.

Now Open Your Bashrc file by Running This Code (Not in Root User).

sudo gedit ~/.bashrc

Paste This Line To Bottom of The File.

//please check your sdk location in file manager first

export ANDROID_HOME=/home/Your_Username/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

now save and close this file.

after that reload the file for system.
so run this command.

source ~/.bashrc

Now Open Your android studio.

By Running the command.

android-studio/bin/studio.sh.

Then Follow This Screens.

android studio setup
 

android studio setup

android studio setup



android studio setup

please check you android-studio location first in my case it in home user directory.

now this was fresh install so you have to select do not import setting.
after that update some libraries.

Now its Ready To Use.

For Windows :

Installing android on Windows Does not required lots of thing.
Just download
jdk: -

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

and
android studio 

Then simply Run the executable file
.
https://developer.android.com/sdk/index.html

All will Done by window automatic.