SlideShare uma empresa Scribd logo
1 de 79
Android predavanje
Nikola Kapraljević, Infinum

Java tečaj 22.06.2012, FER
Nikola Kapraljević
twitter@nixa
nikola@infinum.hr
Android
Ruby on Rails
iPhone
Android OS
Android OS
koristi se za tablet i smartphone uređaje
trenutno postoji preko 300 različitih telefona
900 000 novih uređaja se aktivira dnevno
330 000 000 uređaja je trenutno aktivno
Samsung Galaxy SIII
Izgled sučelja
HTC Sense
Motorola MotoWiz
Samsung TouchWiz
Sony Ericsson UX
Honeycomb 3.x
tablet računala
Android
4.0
Open source...
Android Arhitecture
Android OS
Linux based OS
no NIJE Linux
nema glibc
nema X11
nema konfiguracijske datoteke koje očekujemo
nema ni sve alate koji dolaze s Linuxom
Application Framework
Activity Manager    Resource Manager
Window Manager      Location Manager
Content Providers   Notification Manager
View System
Package Manager
Telephony Manager
Dalvik VM
virtual machine koji izvršava Dalvik byte-code
slično JVM, no nije JVM
Java se kompajlira u .dex datoteke
svaka aplikacija se izvršava u vlastitom
sandboxu i na vlastitoj instanci VM-a
Java SE 5
Applications
uz OS dolazi i određeni set aplikacija
  SMS
  Calendar
  Browser (Webkit)
  Contacts
  ....
Raspodjela Android
http://developer.android.com/resources/
dashboard/platform-versions.html
Različite rezolucije/orijentacije
res/layout/main_activity.xml      # For handsets
res/layout-land/main_activity.xml       # For landscape handsets
res/layout-sw600dp/main_activity.xml # For tablets
Dashboard
most of the apps
Side
navigation
Android Development
UI
layout.xml
definiranje sučelja koristeći XML
android:id="@+id/my_button”
moguće učitavanje on runtime pomocu
LayoutInflater servicea
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main_layout);
Button
<Button android:id="@+id/my_button"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/my_button_text"/>
View system
Android Layouts
FrameLayout
LinearLayout
RelativeLayout
TableLayout
Gallery
Android Widget Toolbox
TextView    RadioButton
EditText    http://
            developer.android.co
ListView
            m/guide/tutorials/
Spinner     views/index.html

Button
CheckBox
http://developer.android.com/design/
index.html
Actionbar Sherlock
http://actionbarsherlock.com/
Custom Components
Extend an existing View class or subclass with your own class.
Override some of the methods from the superclass. The superclass
methods to override start with 'on', for example, onDraw(),
onMeasure(), and onKeyDown(). This is similar to the on... events in
Activity or ListActivity that you override for lifecycle and other
functionality hooks.
Use your new extension class. Once completed, your new extension
class can be used in place of the view upon which it was based.
example: extend ImageView and add some rounded border
http://developer.android.com/guide/topics/ui/custom-
components.html
New project example
Project
src/
assets/
res/
AndroidManifest.xml
AndroidManifest.xml
permissions, activity, name, icon
strings.xml
Overriding resources
res/values-en/strings.xml
res/layout-land/main.xml
res/drawable-ldpi/slika.png
res/drawable-hdpi/slika.png


http://developer.android.com/guide/topics/
resources/providing-resources.html
R.java
pointers from java to resources
R.java
R.layout
R.string
R.drawable
R.anim
R.color
HomeActivity.java
Android Emulator
napraviti ćemo novi AVD, koristite x86 ako
mozete
telnet localhost port
~/.android/avd
DDMS perspective
pozivi, sms, network speed
Pokretanje aplikacije
compiling, signing, deploying, running
ANT
building from command line
android update project -p .
ant help :)
Android Debug Bridge
SDK/tools/adb
Command line install
adb install bin/Workshop.apk
adb uninstall com.infinum.workshop
Application components
Activities
Services
ContentProviders
Broadcast receivers
Activity lifecycle
http://developer.android.com/reference/
android/app/Activity.html
Android Intents
Intents are used as a message-passing
mechanism that works both within your
application, and between applications.
 Declare your intention that an Activity or
 Service be started to perform an action,
 usually with (or on) a particular piece of data
 Broadcast that an event (or action) has
 occurred
Explicit intents
startActivity
  Intent intent = new Intent(this, MyActivity.class);
  startActivity(intent);
startActivityForResults
  Intent intent = new Intent(this, MyActivity.class);
  startActivity(intent);
Implicit intents
trazimo od OS-a da izabere pomocu cega ce
izvrsiti Intent
  Intent intent = new
  Intent(Intent.ACTION_CALL, Uri.parse(‘tel:
  0959115614’);
  startActivity(intent);
DetailsActivity example
prenosenje i vracanje parametara s
activitya na activity
Broadcasts
Broadcasting intents
  napravite intent i pozoveze nad njim
     sendBroadcast(intent);
Receiving intents
  extend BroadcastReceiver
  register in android manifest
     <receiver android:name=".MyBroadcastReciver">
     <intent-filter>
     <action android:name="hr.infinum.fer.LECTURE_DONE"/>
     </intent-filter>
     </receiver>
Phone call
example
String url = "tel:0959115614";
Intent intent = new Intent(Intent.ACTION_CALL,
Uri.parse(url));
Permissions
<uses-permission
android:name="android.permission.CALL_PHONE"
></uses-permission>
Možemo li znati kad je
poziv gotov?
public void onCreate(Bundle savedInstanceState) {
	   	    super.onCreate(savedInstanceState);
	   	    setContentView(R.layout.main);

	   	   Button btnCall = (Button) findViewById(R.id.btnCall);
	   	   btnCall.setOnClickListener(new OnClickListener() {

	   	   	     @Override
	   	   	     public void onClick(View v) {
	   	   	     	    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:0917700"));
	   	   	     	    startActivity(intent);
	   	   	     }
	   	   });

	   	   TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
	   	   tm.listen(new EndCallListener(), PhoneStateListener.LISTEN_CALL_STATE);
	   }

	   private class EndCallListener extends PhoneStateListener {

	   	   @Override
	   	   public void onCallStateChanged(int state, String incomingNumber) {
	   	   	    Log.d("NIXA", "Phone state is " + state + " " + incomingNumber);
	   	   }
	   }
Permissions
<uses-permission
android:name="android.permission.READ_PHONE
_STATE"></uses-permission>
ListView
List adapters
ArrayAdapter
CursorAdapter
SimpleCursorAdapter
ListView example
Storage
Shared Preferences
Internal Storage
External Storage
SQLite Databases
Network Connection
Media and Camera
take photo
record video
pick photo/video from gallery
MediaStore.ACTION_IMAGE_CAPTURE
MediaStore.ACTION_VIDEO_CAPTURE
Camera example
Paziti na
Low processing power
Limited RAM
Limited permanent storage capacity
Small screens with low resolution
High costs associated with data transfer
Slow data transfer rates with high latency
Unreliable data connections
Limited battery life
ANR
application not
responding
services 10s
activities 5s
Support Library
Fragment
FragmentManager
FragmentTransaction
ListFragment
DialogFragment
LoaderManager
Loader
AsyncTaskLoader
CursorLoader
coloredlogcat
https://bitbucket.org/GBouerat/colored-
logcat-pid
Flurry
ako vas zanima tko i kako koristi aplikaciju
AdMob
ako hocete nesto zaraditi, ali vjerovatno
necete
Android Market
Android Market
Developer Console
pratite komentare
exceptioni
Active Install Rate
Android Market
25$ account
kad krenete razvijati applikaciju nije loše
uploadat ju odmah na početku developmenta
kako bi si rezervirali namespace
(hr.infinum.nixa...)
“od sljedećeg tjedna izgleda da ćemo moći
kupovati/prodavati aplikacije i iz Hrvatske”
DORS/CLUC 2011 - ovo jos uvijek ne radi :-)
Lamborgini Aventador
700hp V12, 2.9s do 100km/h
Pitanja ...
Hvala!

twitter@nixa
skype@nkapralj
nikola.kapraljevic@gmail.com

Mais conteúdo relacionado

Destaque (6)

Donna Dickson on Employee Engagement
Donna Dickson on Employee EngagementDonna Dickson on Employee Engagement
Donna Dickson on Employee Engagement
 
Hands on Android
Hands on AndroidHands on Android
Hands on Android
 
Project Management 8 Human Resources
Project Management 8 Human ResourcesProject Management 8 Human Resources
Project Management 8 Human Resources
 
Corporate Culture General 1.3.Blank
Corporate Culture General 1.3.BlankCorporate Culture General 1.3.Blank
Corporate Culture General 1.3.Blank
 
Giáo án lịch sử 11 bài 17-19-20-21-22
Giáo án lịch sử 11 bài 17-19-20-21-22Giáo án lịch sử 11 bài 17-19-20-21-22
Giáo án lịch sử 11 bài 17-19-20-21-22
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Semelhante a Android workshop

android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
slesulvy
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
openbala
 
Mobile Software Engineering Crash Course - C04 Android Cont.
Mobile Software Engineering Crash Course - C04 Android Cont.Mobile Software Engineering Crash Course - C04 Android Cont.
Mobile Software Engineering Crash Course - C04 Android Cont.
Mohammad Shaker
 

Semelhante a Android workshop (20)

Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
 
Getting your app ready for android n
Getting your app ready for android nGetting your app ready for android n
Getting your app ready for android n
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android Developers
 
Java RMI
Java RMIJava RMI
Java RMI
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 Agent
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
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 Extended
 
Android101
Android101Android101
Android101
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
Android App development and test environment, Understaing android app structure
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
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
Mobile Software Engineering Crash Course - C04 Android Cont.
Mobile Software Engineering Crash Course - C04 Android Cont.Mobile Software Engineering Crash Course - C04 Android Cont.
Mobile Software Engineering Crash Course - C04 Android Cont.
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
SRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile ServicesSRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile Services
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Android workshop

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. - neke stvari se mogu emulirati no ne sve\n- recimo emuliranje kamere, telefonskih poziva i slicno radi\n- ne moze se emulirati sensore, slobodno pokusajte tresti laptop, ali ne moj!\n- network bandwidth se moze mijenjati\n
  42. \n
  43. pokazati ini file\ngdje se nalazi SD kartica i slicno\nmksdcard za napraviti karticu rucno\nprilikom stvaranja AVD-a mozemo izabrati ili velicinu ili datoteku\n
  44. \n
  45. \n
  46. \n
  47. \n
  48. radi deployment na emulator ili na uredjan no brine se za transfer i instalaciju na ciljanom uredaju\n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n