Android training in mumbai

C
CIBILBusiness Analyst at CIBIL
1/82
2/82
Android developmentAndroid development
Introduction Of Intent
3/82
ContentContent
INTRO1
USER INTERFACE
2
3
ANATOMY OF AN APPLICATION
4/82
Intro |Intro | quick startquick start
• Android SDK (Software Development Kit)
• JDK
• ADT (Android Development Tools, Eclipse IDE plug-in)
5/82
Intro | platform overviewIntro | platform overview
6/82
Intro | platform overviewIntro | platform overview
7/82
Intro | platform overviewIntro | platform overview
• Dalvik VM
o optimised to run on slow-cpu, low-ram, low-power devices
o runs .dex files (not .class/.jar)
o Multiple instances of DVM can run in parallel
8/82
Intro | dvm vs. jvmIntro | dvm vs. jvm
• register-based vs. stack-based
o register-based VMs allow for faster execution times, but
o programs are larger when compiled.
• execution environment - multiple vs. single instance
9/82
Intro |Intro | java vs. android apijava vs. android api
• Since it uses Java compiler, it implicitly supports a set of
Java commands
• Compatible with Java SE5 code
• A subset of Apache Harmony (open source, free Java
implementation)
• Multithreading as time-slicng.
• Dalvik implements the keyword synchronized and
java.util.concurrent.* package
• Supports reflexion and finalizers but these are not
recomended
• Does not support
o awt, swing, rmi, applet, ...
10/82
INTRO1
USER INTERFACE
2
3
6
ANATOMY OF AN APPLICATION
11/82
Apps | activityApps | activity
• Base class mostly for visual components
o extends Activity
o override onCreate
12/82
Apps | activityApps | activity
/* Example.java */
package uk.ac.ic.doc;
import android.app.Activity;
import android.os.Bundle;
public class Example extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.interface);
}
}
13/82
Apps | activityApps | activity
/* interface.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<LinearLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
android:orientation=“vertical”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”>
<TextView
android:id=“@+id/componentName”
android:layout_width=“fill_parent”
android:layout_height=“wrap_content”
android:text=“Text that will be displayed.”
/>
</LinearLayout>
14/82
Apps | activityApps | activity
/* Example.java */
package uk.ac.ic.doc;
import android.app.Activity;
import android.os.Bundle;
public class Example extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.interface);
TextView text_view = (TextView)findViewById(R.id.componentName);
}
}
15/82
Apps | activityApps | activity
/* strings.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<resources xmlns:android=“http://schemas.android.com/apk/res/android”>
<string name=“textRefName”>Text that will be displayed</strings>
</resources>
/* interface.xml */
[...]
<TextView
android:id=“@+id/componentName”
android:layout_width=“fill_parent”
android:layout_height=“wrap_content”
android:text=“@string/textRefName”
/>
16/82
Apps | activityApps | activity
17/82
Apps | activityApps | activity
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(“key”, value);
outState.putFloatArray(“key2”, value2);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
value = savedInstanceState.getString(“key”);
value2 = savedInstanceState.getFloatArray(“key2”);
}
18/82
Apps | intentApps | intent
• Allows communication between components
o Message passing
o Bundle
Intent intent = new Intent(CurrentActivity.this, OtherActivity.class);
startActivity(intent);
19/82
Apps | intentApps | intent
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Button listener
Button btnStart = (Button) findViewById(R.id.btn_start);
btnStart.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent =
new Intent(CurrentActivity.this, OtherActivity.class);
startActivity(intent);
}
});
}
20/82
Apps | threadApps | thread
Button btnPlay = (Button) findViewById(R.id.btnPlay);
btnPlay.setOnClickListener(new View.OnClickListener() {
public void onClick(View view){
// Main Thread blocks
Thread backgroundMusicThread = new Thread(
new Runnable() {
public void run() {
playMusic();
}
}
);
backgroundMusicThread.start();
}
});
21/82
Apps | hApps | handlerandler
• Communication between tasks running in parallel
22/82
Apps | hApps | handlerandler
private Handler mHandler = new Handler();
private Color mColor = Color.BLACK;
private Runnable mRefresh = new Runnable() {
public void run() {
mTextViewOnUI.setBackgroundColor(mColor)
}};
private Thread mCompute = new Thread(Runnable() {
public void run() {
while(1){
mColor = cpuIntensiveColorComputation(...);
mHandler.post(mRefresh);
}
}});
public void onCreate(Bundle savedInstanceState) {
mCompute.start();
}
23/82
Apps | serviceApps | service
• Base class for background tasks
o extends Service
o override onCreate
• It’s not
o a separate process
o a separate thread
• It is
o part of the main thread
o a way to update an application when it’s not active
24/82
Apps | sApps | serviceervice
25/82
Apps | bApps | broadcastroadcast rreceivereceiver
• extends BroadcastReceiver
• implements onReceive()
• Waits for a system broadcast to happen to trigger an event
• OS-generated
o Battery empty
o Camera button pressed
o New app installed
o Wifi connection established
• User-generated
o Start of some calculation
o End of an operation
26/82
Apps | bApps | broadcastroadcast rreceivereceiver
public class BRExample extends BroadcastReceiver {
@Override
public void onReceive(Context rcvCtx, Intent rcvIntent) {
if (rcvIntent.getAction().equals(Intent.ACTION_CAMERA_BUTTON)) {
rcvCtx.startService(new Intent(rcvCtx, SomeService.class));
}}}
public class SomeService extends Service {
@Override
public IBinder onBind(Intent arg0) { return null; }
@Override
public void onCreate() {
super.onCreate();
Toast.makeText(this,“Camera...”, Toast.LENGTH_LONG).show();}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, “Service done”, Toast.LENGTH_LONG).show();}
}
27/82
Apps | notificationsApps | notifications
• Toast
• AlertDialog
• Notification
Toast.makeText(this, “Notification text”, Toast.LENGTH_SHORT).show();
28/82
Apps | manifestApps | manifest
<?xml version=“1.0” encoding=“utf-8”?>
<manifest xmlns:android=“http://schemas.android.com/apk/res/android”
package=“uk.ac.ic.doc” android:versionCode=“1”
android:versionName=“1.0”>
<application android:icon=“@drawable/icon”
android:label=“@string/app_name”>
<activity android:name=“.SampleActivity”
android:label=“@string/activity_title_text_ref”>
<intent-filter>
/* ... */
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion=“3” />
</manifest>
29/82
Apps | resourcesApps | resources
• /res
o anim
o drawable
• hdpi
• mdpi
• ldpi
o layout
o values
• arrays.xml
• colors.xml
• strings.xml
o xml
o raw
30/82
Apps |Apps | RR.java.java
• Autogenerated, best if not manually edited
• gen/
31/82
4
INTRO1
USER INTERFACE
2
3
ANATOMY OF AN APPLICATION
32/82
Elements and layoutsElements and layouts
• dip vs. px
• Component dimesions
o wrap_content
o fill_parent
33/82
Elements and layoutsElements and layouts
• Linear Layout
o Shows nested View elements
/* linear.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<LinearLayout android:orientation=“horizontal”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:layout_weight=“1”>
<TextView android:text=“red” />
<TextView android:text=“green” />
</LinearLayout>
<LinearLayout android:orientation=“vertical”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:layout_weight=“1”>
<TextView android:text=“row one” />
</LinearLayout>
34/82
Elements and layoutsElements and layouts
• Relative Layout
35/82
Elements and layoutsElements and layouts
• Table Layout
o Like the HTML div tag
/* table.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<TableLayout android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:stretchColumns=“1”>
<TableRow>
<TextView android:layout_column=“1”
android:text=“Open...”
android:padding=“3dip” />
<TextView android:text=“Ctrl-O”
android:gravity=“right”
android:padding=“3dip” />
</TableRow>
</TableLayout>
36/82
Elements and layoutsElements and layouts
• Grid View
/* grid.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<GridView
android:id=“@+id/gridview”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:columnWidth=“90dp”
android:numColumns=“auto_fit”
android:verticalSpacing=“10dp”
android:horizontalSpacing=“10dp”
android:stretchMode=“columnWidth”
android:gravity=“center”
/>
37/82
Elements and layoutsElements and layouts
• Grid View
/* GridExample.java */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(new
AdapterForGridView(this));
gridview.setOnItemClickListener(
new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int pos, long id) {
Toast.makeText(
GridPrimer.this, "" + pos, Toast.LENGTH_SHORT).show();
}});
}
38/82
Elements and layoutsElements and layouts
• Grid View
/* AdapterForGridView.java */
public class AdapterForGridView extends BaseAdapter {
private Context mContext;
public AdapterForGridView(Context c) { mContext = c; }
public int getCount() { return mThumbIDs.length; }
public Object getItem(int position) { return null;}
public long getItemId(int position) { return 0; }
// bad getView implementation
public View getView(int pos, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIDs[pos]);
return imageView;
}
private Integer[] mThumbIDs =
{ R.drawable.img1, R.drawable.img2 /*...*/ };
}
39/82
Elements and layoutsElements and layouts
• Tab Layout
/* tab.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<TabHost android:id=“@android:id/tabhost”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”>
<LinearLayout android:orientation=“vertical”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”>
<TabWidget android:id=“@android:id/tabs”
android:layout_width=“fill_parent”
android:layout_height=“wrap_content”/>
<FrameLayout
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”/>
</LinearLayout>
</TabHost>
40/82
Elements and layoutsElements and layouts
• Tab Layout
/* selector1.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<selector xmlns:android=“http://schemas.android.com/apk/res/android”>
<!– Tab is selected -->
<item android:drawable=“@drawable/ic_tab_1_selected”
android:state_selected=“true” />
<!– Tab not selected -->
<item android:drawable=“@drawable/ic_tab_1_not_selected” />
</selector>
/* selector2.xml */
/* selector3.xml */
41/82
Elements and layoutsElements and layouts
• Tab Layout
/* Tab1.java */
public class Tab1 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText(“This is the Artists tab”);
setContentView(textview);
}
}
/* Tab2.java */
/* Tab3.java */
42/82
Elements and layoutsElements and layouts
• Tab Layout
/* TabExample.java */
public class TabExample extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
TabHost tabHost = getTabHost();
//--- tab 1 ---
Intent intent = new Intent().setClass(this, Tab1.class);
TabHost.TabSpec spec = tabHost.newTabSpec(“tab1”).setIndicator(
“Artists”, getResources().getDrawable(R.drawable.selector1))
.setContent(intent);
tabHost.addTab(spec);
//--- tab 1 ---
tabHost.setCurrentTab(2);}
43/82
Elements and layoutsElements and layouts
• List View
/* list_item.xml */
<?xml version=“1.0” encoding=“utf-8”?>
<TextView
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
android:padding=“10dp”
android:textSize=“16sp” />
44/82
Elements and layoutsElements and layouts
• List View
/* ListViewExample.java */
public class ListViewExample extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,
R.layout.list_item, COUNTRIES));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}});
}
45/82
Elements and layoutsElements and layouts
• Button
• ImageButton
• EditText
• CheckBox
• RadioButton
• ToggleButton
• RatingBar
46/82
Elements and layoutsElements and layouts
• DatePicker
• TimePicker
• Spinner
• AutoComplete
• Gallery
• MapView
• WebView
47/82
EventsEvents
• Event Handler
o Hardware buttons
• Event Listener
o Touch screen
48/82
EventsEvents
• KeyEvent is sent to callback methods
o onKeyUp(), onKeyDown(), onKeyLongpress()
o onTrackballEvent(), onTouchEvent()
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CAMERA) {
return true; // consumes the event
}
return super.onKeyDown(keyCode, event);
}
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { /* ... */ }
});
49/82
EventsEvents
public class TouchExample extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) { /*...*/ }
});
button.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
// ...
return true;
}
});}}
50/82
MenusMenus
• Options Menu: MENU button, tied to an Activity
• Context Menu: View LongPress
• Submenu
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_ADD, 0, “Add”)
.setIcon(R.drawable.icon);
menu.add(0, MENU_WALLPAPER, 0, “Wallpaper”);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case MENU_ADD: //... ; return true;
case MENU_WALLPAPER: //... ; return true;
default: return false;
}}
51/82
WidgetWidget
• XML Layout
• AppWidgetProvider gets notified
• Dimensions and refresh frequency
52/82
ThankThank You !!!You !!!
For More Information click below link:
Follow Us on:
http://vibranttechnologies.co.in/android-classes-in-mumbai.html
1 of 52

Recommended

Android - Anatomy of android elements & layouts by
Android - Anatomy of android elements & layoutsAndroid - Anatomy of android elements & layouts
Android - Anatomy of android elements & layoutsVibrant Technologies & Computers
275 views52 slides
Building an app with Google's new suites by
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suitesToru Wonyoung Choi
70 views84 slides
Jetpack, with new features in 2021 GDG Georgetown IO Extended by
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
86 views77 slides
Android development with Scala and SBT by
Android development with Scala and SBTAndroid development with Scala and SBT
Android development with Scala and SBTAnton Yalyshev
184 views29 slides
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016) by
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)
Internal Android Library Management (DroidCon SF 2016, Droidcon Italy 2016)Kelly Shuster
14.3K views174 slides
Android For All The Things by
Android For All The ThingsAndroid For All The Things
Android For All The ThingsPaul Trebilcox-Ruiz
1.2K views45 slides

More Related Content

What's hot

Building maintainable app by
Building maintainable appBuilding maintainable app
Building maintainable appKristijan Jurković
1.9K views70 slides
[1D6]RE-view of Android L developer PRE-view by
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-viewNAVER D2
3.4K views115 slides
Synack at AppSec California 2015 - Geolocation Vulnerabilities by
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack
14.1K views56 slides
Multithreading in Android by
Multithreading in AndroidMultithreading in Android
Multithreading in Androidcoolmirza143
4.4K views19 slides
Building maintainable app #droidconzg by
Building maintainable app #droidconzgBuilding maintainable app #droidconzg
Building maintainable app #droidconzgKristijan Jurković
340 views72 slides
Using the Android Native Development Kit (NDK) by
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
5.6K views40 slides

What's hot(6)

[1D6]RE-view of Android L developer PRE-view by NAVER D2
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view
NAVER D23.4K views
Synack at AppSec California 2015 - Geolocation Vulnerabilities by Synack
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation Vulnerabilities
Synack14.1K views
Multithreading in Android by coolmirza143
Multithreading in AndroidMultithreading in Android
Multithreading in Android
coolmirza1434.4K views
Using the Android Native Development Kit (NDK) by DroidConTLV
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
DroidConTLV5.6K views

Viewers also liked

oday booklet_v25 by
oday booklet_v25oday booklet_v25
oday booklet_v25SIU MAN LAM
1.1K views36 slides
Weekend Kitchen Renovations by
Weekend Kitchen RenovationsWeekend Kitchen Renovations
Weekend Kitchen RenovationsMichael Leafer
61 views6 slides
CADZINE n° 1, gennaio 2015, ANNO II by
CADZINE n° 1, gennaio 2015, ANNO IICADZINE n° 1, gennaio 2015, ANNO II
CADZINE n° 1, gennaio 2015, ANNO IICADZINE
592 views64 slides
L3_Power_SIMnews_42 by
L3_Power_SIMnews_42L3_Power_SIMnews_42
L3_Power_SIMnews_42Sean Bradley
144 views22 slides
El Manierismo by
El ManierismoEl Manierismo
El ManierismoCarlos Muñoz
70 views6 slides
Ciencia y-tecnologia-ivelis by
Ciencia y-tecnologia-ivelisCiencia y-tecnologia-ivelis
Ciencia y-tecnologia-ivelisive15129718
75 views8 slides

Viewers also liked(10)

oday booklet_v25 by SIU MAN LAM
oday booklet_v25oday booklet_v25
oday booklet_v25
SIU MAN LAM1.1K views
CADZINE n° 1, gennaio 2015, ANNO II by CADZINE
CADZINE n° 1, gennaio 2015, ANNO IICADZINE n° 1, gennaio 2015, ANNO II
CADZINE n° 1, gennaio 2015, ANNO II
CADZINE592 views
Ciencia y-tecnologia-ivelis by ive15129718
Ciencia y-tecnologia-ivelisCiencia y-tecnologia-ivelis
Ciencia y-tecnologia-ivelis
ive1512971875 views
MagXLondon Magazine Edition December 2015 by Rafael Bertrán
MagXLondon Magazine Edition December 2015MagXLondon Magazine Edition December 2015
MagXLondon Magazine Edition December 2015
Rafael Bertrán706 views
Real Property Gains Tax (RPGT) by UiTM
Real Property Gains Tax (RPGT)Real Property Gains Tax (RPGT)
Real Property Gains Tax (RPGT)
UiTM 25.2K views

Similar to Android training in mumbai

Android tutorial (2) by
Android tutorial (2)Android tutorial (2)
Android tutorial (2)Kumar
632 views82 slides
Android classes in mumbai by
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbaiVibrant Technologies & Computers
344 views82 slides
Android - Api & Debugging in Android by
Android - Api & Debugging in AndroidAndroid - Api & Debugging in Android
Android - Api & Debugging in AndroidVibrant Technologies & Computers
154 views36 slides
Ruby conf2012 by
Ruby conf2012Ruby conf2012
Ruby conf2012Chandan Jog
524 views50 slides
Android Best Practices by
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
7K views58 slides
Suportando Aplicações Multi-tenancy com Java EE by
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EERodrigo Cândido da Silva
2.2K views37 slides

Similar to Android training in mumbai(20)

Android tutorial (2) by Kumar
Android tutorial (2)Android tutorial (2)
Android tutorial (2)
Kumar 632 views
"JavaME + Android in action" CCT-CEJUG Dezembro 2008 by Vando Batista
"JavaME + Android in action" CCT-CEJUG Dezembro 2008"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
Vando Batista1.3K views
android level 3 by DevMix
android level 3android level 3
android level 3
DevMix1.6K views
Android Workshop by Junda Ong
Android WorkshopAndroid Workshop
Android Workshop
Junda Ong1.5K views
Android app development basics by Anton Narusberg
Android app development basicsAndroid app development basics
Android app development basics
Anton Narusberg1.6K views
Asynchronous Module Definition (AMD) by xMartin12
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
xMartin1215.5K views
Android App development and test environment, Understaing android app structure by Vijay Rastogi
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
Vijay Rastogi5.8K views
Titanium appcelerator best practices by Alessio Ricco
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practices
Alessio Ricco14.9K views
How to make a high-quality Node.js app, Nikita Galkin by Sigma Software
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software269 views
Introduction to Apache Cordova (Phonegap) by ejlp12
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
ejlp1232.4K views
Androidaop 170105090257 by newegg
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
newegg256 views

Recently uploaded

DevsRank by
DevsRankDevsRank
DevsRankdevsrank786
11 views1 slide
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...Marc Müller
38 views62 slides
360 graden fabriek by
360 graden fabriek360 graden fabriek
360 graden fabriekinfo33492
37 views25 slides
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the... by
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...Deltares
6 views22 slides
Navigating container technology for enhanced security by Niklas Saari by
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas SaariMetosin Oy
13 views34 slides
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Marc Müller
37 views83 slides

Recently uploaded(20)

.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller38 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info3349237 views
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the... by Deltares
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
Deltares6 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy13 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller37 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski10 views
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme... by Deltares
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...
DSD-INT 2023 Salt intrusion Modelling of the Lauwersmeer, towards a measureme...
Deltares5 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
Deltares17 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares14 views
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols by Deltares
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - DolsDSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols
Deltares7 views
Generic or specific? Making sensible software design decisions by Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
MariaDB stored procedures and why they should be improved by Federico Razzoli
MariaDB stored procedures and why they should be improvedMariaDB stored procedures and why they should be improved
MariaDB stored procedures and why they should be improved
Software evolution understanding: Automatic extraction of software identifier... by Ra'Fat Al-Msie'deen
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...

Android training in mumbai

  • 4. 4/82 Intro |Intro | quick startquick start • Android SDK (Software Development Kit) • JDK • ADT (Android Development Tools, Eclipse IDE plug-in)
  • 5. 5/82 Intro | platform overviewIntro | platform overview
  • 6. 6/82 Intro | platform overviewIntro | platform overview
  • 7. 7/82 Intro | platform overviewIntro | platform overview • Dalvik VM o optimised to run on slow-cpu, low-ram, low-power devices o runs .dex files (not .class/.jar) o Multiple instances of DVM can run in parallel
  • 8. 8/82 Intro | dvm vs. jvmIntro | dvm vs. jvm • register-based vs. stack-based o register-based VMs allow for faster execution times, but o programs are larger when compiled. • execution environment - multiple vs. single instance
  • 9. 9/82 Intro |Intro | java vs. android apijava vs. android api • Since it uses Java compiler, it implicitly supports a set of Java commands • Compatible with Java SE5 code • A subset of Apache Harmony (open source, free Java implementation) • Multithreading as time-slicng. • Dalvik implements the keyword synchronized and java.util.concurrent.* package • Supports reflexion and finalizers but these are not recomended • Does not support o awt, swing, rmi, applet, ...
  • 11. 11/82 Apps | activityApps | activity • Base class mostly for visual components o extends Activity o override onCreate
  • 12. 12/82 Apps | activityApps | activity /* Example.java */ package uk.ac.ic.doc; import android.app.Activity; import android.os.Bundle; public class Example extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.interface); } }
  • 13. 13/82 Apps | activityApps | activity /* interface.xml */ <?xml version=“1.0” encoding=“utf-8”?> <LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android” android:orientation=“vertical” android:layout_width=“fill_parent” android:layout_height=“fill_parent”> <TextView android:id=“@+id/componentName” android:layout_width=“fill_parent” android:layout_height=“wrap_content” android:text=“Text that will be displayed.” /> </LinearLayout>
  • 14. 14/82 Apps | activityApps | activity /* Example.java */ package uk.ac.ic.doc; import android.app.Activity; import android.os.Bundle; public class Example extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.interface); TextView text_view = (TextView)findViewById(R.id.componentName); } }
  • 15. 15/82 Apps | activityApps | activity /* strings.xml */ <?xml version=“1.0” encoding=“utf-8”?> <resources xmlns:android=“http://schemas.android.com/apk/res/android”> <string name=“textRefName”>Text that will be displayed</strings> </resources> /* interface.xml */ [...] <TextView android:id=“@+id/componentName” android:layout_width=“fill_parent” android:layout_height=“wrap_content” android:text=“@string/textRefName” />
  • 17. 17/82 Apps | activityApps | activity @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(“key”, value); outState.putFloatArray(“key2”, value2); } @Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); value = savedInstanceState.getString(“key”); value2 = savedInstanceState.getFloatArray(“key2”); }
  • 18. 18/82 Apps | intentApps | intent • Allows communication between components o Message passing o Bundle Intent intent = new Intent(CurrentActivity.this, OtherActivity.class); startActivity(intent);
  • 19. 19/82 Apps | intentApps | intent @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Button listener Button btnStart = (Button) findViewById(R.id.btn_start); btnStart.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(CurrentActivity.this, OtherActivity.class); startActivity(intent); } }); }
  • 20. 20/82 Apps | threadApps | thread Button btnPlay = (Button) findViewById(R.id.btnPlay); btnPlay.setOnClickListener(new View.OnClickListener() { public void onClick(View view){ // Main Thread blocks Thread backgroundMusicThread = new Thread( new Runnable() { public void run() { playMusic(); } } ); backgroundMusicThread.start(); } });
  • 21. 21/82 Apps | hApps | handlerandler • Communication between tasks running in parallel
  • 22. 22/82 Apps | hApps | handlerandler private Handler mHandler = new Handler(); private Color mColor = Color.BLACK; private Runnable mRefresh = new Runnable() { public void run() { mTextViewOnUI.setBackgroundColor(mColor) }}; private Thread mCompute = new Thread(Runnable() { public void run() { while(1){ mColor = cpuIntensiveColorComputation(...); mHandler.post(mRefresh); } }}); public void onCreate(Bundle savedInstanceState) { mCompute.start(); }
  • 23. 23/82 Apps | serviceApps | service • Base class for background tasks o extends Service o override onCreate • It’s not o a separate process o a separate thread • It is o part of the main thread o a way to update an application when it’s not active
  • 24. 24/82 Apps | sApps | serviceervice
  • 25. 25/82 Apps | bApps | broadcastroadcast rreceivereceiver • extends BroadcastReceiver • implements onReceive() • Waits for a system broadcast to happen to trigger an event • OS-generated o Battery empty o Camera button pressed o New app installed o Wifi connection established • User-generated o Start of some calculation o End of an operation
  • 26. 26/82 Apps | bApps | broadcastroadcast rreceivereceiver public class BRExample extends BroadcastReceiver { @Override public void onReceive(Context rcvCtx, Intent rcvIntent) { if (rcvIntent.getAction().equals(Intent.ACTION_CAMERA_BUTTON)) { rcvCtx.startService(new Intent(rcvCtx, SomeService.class)); }}} public class SomeService extends Service { @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); Toast.makeText(this,“Camera...”, Toast.LENGTH_LONG).show();} @Override public void onDestroy() { super.onDestroy(); Toast.makeText(this, “Service done”, Toast.LENGTH_LONG).show();} }
  • 27. 27/82 Apps | notificationsApps | notifications • Toast • AlertDialog • Notification Toast.makeText(this, “Notification text”, Toast.LENGTH_SHORT).show();
  • 28. 28/82 Apps | manifestApps | manifest <?xml version=“1.0” encoding=“utf-8”?> <manifest xmlns:android=“http://schemas.android.com/apk/res/android” package=“uk.ac.ic.doc” android:versionCode=“1” android:versionName=“1.0”> <application android:icon=“@drawable/icon” android:label=“@string/app_name”> <activity android:name=“.SampleActivity” android:label=“@string/activity_title_text_ref”> <intent-filter> /* ... */ </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion=“3” /> </manifest>
  • 29. 29/82 Apps | resourcesApps | resources • /res o anim o drawable • hdpi • mdpi • ldpi o layout o values • arrays.xml • colors.xml • strings.xml o xml o raw
  • 30. 30/82 Apps |Apps | RR.java.java • Autogenerated, best if not manually edited • gen/
  • 32. 32/82 Elements and layoutsElements and layouts • dip vs. px • Component dimesions o wrap_content o fill_parent
  • 33. 33/82 Elements and layoutsElements and layouts • Linear Layout o Shows nested View elements /* linear.xml */ <?xml version=“1.0” encoding=“utf-8”?> <LinearLayout android:orientation=“horizontal” android:layout_width=“fill_parent” android:layout_height=“fill_parent” android:layout_weight=“1”> <TextView android:text=“red” /> <TextView android:text=“green” /> </LinearLayout> <LinearLayout android:orientation=“vertical” android:layout_width=“fill_parent” android:layout_height=“fill_parent” android:layout_weight=“1”> <TextView android:text=“row one” /> </LinearLayout>
  • 34. 34/82 Elements and layoutsElements and layouts • Relative Layout
  • 35. 35/82 Elements and layoutsElements and layouts • Table Layout o Like the HTML div tag /* table.xml */ <?xml version=“1.0” encoding=“utf-8”?> <TableLayout android:layout_width=“fill_parent” android:layout_height=“fill_parent” android:stretchColumns=“1”> <TableRow> <TextView android:layout_column=“1” android:text=“Open...” android:padding=“3dip” /> <TextView android:text=“Ctrl-O” android:gravity=“right” android:padding=“3dip” /> </TableRow> </TableLayout>
  • 36. 36/82 Elements and layoutsElements and layouts • Grid View /* grid.xml */ <?xml version=“1.0” encoding=“utf-8”?> <GridView android:id=“@+id/gridview” android:layout_width=“fill_parent” android:layout_height=“fill_parent” android:columnWidth=“90dp” android:numColumns=“auto_fit” android:verticalSpacing=“10dp” android:horizontalSpacing=“10dp” android:stretchMode=“columnWidth” android:gravity=“center” />
  • 37. 37/82 Elements and layoutsElements and layouts • Grid View /* GridExample.java */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(new AdapterForGridView(this)); gridview.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int pos, long id) { Toast.makeText( GridPrimer.this, "" + pos, Toast.LENGTH_SHORT).show(); }}); }
  • 38. 38/82 Elements and layoutsElements and layouts • Grid View /* AdapterForGridView.java */ public class AdapterForGridView extends BaseAdapter { private Context mContext; public AdapterForGridView(Context c) { mContext = c; } public int getCount() { return mThumbIDs.length; } public Object getItem(int position) { return null;} public long getItemId(int position) { return 0; } // bad getView implementation public View getView(int pos, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mThumbIDs[pos]); return imageView; } private Integer[] mThumbIDs = { R.drawable.img1, R.drawable.img2 /*...*/ }; }
  • 39. 39/82 Elements and layoutsElements and layouts • Tab Layout /* tab.xml */ <?xml version=“1.0” encoding=“utf-8”?> <TabHost android:id=“@android:id/tabhost” android:layout_width=“fill_parent” android:layout_height=“fill_parent”> <LinearLayout android:orientation=“vertical” android:layout_width=“fill_parent” android:layout_height=“fill_parent”> <TabWidget android:id=“@android:id/tabs” android:layout_width=“fill_parent” android:layout_height=“wrap_content”/> <FrameLayout android:layout_width=“fill_parent” android:layout_height=“fill_parent”/> </LinearLayout> </TabHost>
  • 40. 40/82 Elements and layoutsElements and layouts • Tab Layout /* selector1.xml */ <?xml version=“1.0” encoding=“utf-8”?> <selector xmlns:android=“http://schemas.android.com/apk/res/android”> <!– Tab is selected --> <item android:drawable=“@drawable/ic_tab_1_selected” android:state_selected=“true” /> <!– Tab not selected --> <item android:drawable=“@drawable/ic_tab_1_not_selected” /> </selector> /* selector2.xml */ /* selector3.xml */
  • 41. 41/82 Elements and layoutsElements and layouts • Tab Layout /* Tab1.java */ public class Tab1 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textview = new TextView(this); textview.setText(“This is the Artists tab”); setContentView(textview); } } /* Tab2.java */ /* Tab3.java */
  • 42. 42/82 Elements and layoutsElements and layouts • Tab Layout /* TabExample.java */ public class TabExample extends TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); TabHost tabHost = getTabHost(); //--- tab 1 --- Intent intent = new Intent().setClass(this, Tab1.class); TabHost.TabSpec spec = tabHost.newTabSpec(“tab1”).setIndicator( “Artists”, getResources().getDrawable(R.drawable.selector1)) .setContent(intent); tabHost.addTab(spec); //--- tab 1 --- tabHost.setCurrentTab(2);}
  • 43. 43/82 Elements and layoutsElements and layouts • List View /* list_item.xml */ <?xml version=“1.0” encoding=“utf-8”?> <TextView android:layout_width=“fill_parent” android:layout_height=“fill_parent” android:padding=“10dp” android:textSize=“16sp” />
  • 44. 44/82 Elements and layoutsElements and layouts • List View /* ListViewExample.java */ public class ListViewExample extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); }}); }
  • 45. 45/82 Elements and layoutsElements and layouts • Button • ImageButton • EditText • CheckBox • RadioButton • ToggleButton • RatingBar
  • 46. 46/82 Elements and layoutsElements and layouts • DatePicker • TimePicker • Spinner • AutoComplete • Gallery • MapView • WebView
  • 47. 47/82 EventsEvents • Event Handler o Hardware buttons • Event Listener o Touch screen
  • 48. 48/82 EventsEvents • KeyEvent is sent to callback methods o onKeyUp(), onKeyDown(), onKeyLongpress() o onTrackballEvent(), onTouchEvent() public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_CAMERA) { return true; // consumes the event } return super.onKeyDown(keyCode, event); } Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { /* ... */ } });
  • 49. 49/82 EventsEvents public class TouchExample extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { /*...*/ } }); button.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { // ... return true; } });}}
  • 50. 50/82 MenusMenus • Options Menu: MENU button, tied to an Activity • Context Menu: View LongPress • Submenu public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, MENU_ADD, 0, “Add”) .setIcon(R.drawable.icon); menu.add(0, MENU_WALLPAPER, 0, “Wallpaper”); return super.onCreateOptionsMenu(menu); } public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { case MENU_ADD: //... ; return true; case MENU_WALLPAPER: //... ; return true; default: return false; }}
  • 51. 51/82 WidgetWidget • XML Layout • AppWidgetProvider gets notified • Dimensions and refresh frequency
  • 52. 52/82 ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/android-classes-in-mumbai.html