SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Mobile
          Software
        Engineering
L04 – Android Cont.

                     Mohammad Shaker
              FIT of Damascus - AI dept.
         MohammadShakerGtr@gmail.com
                Mobile SE – August 2012
Activities
Starting Another Activity
Intent
an object that provides runtime binding between separate
           components (such as two activities)
Intent
carry a collection of various data types as key-value pairs
           called extras through putExtra()
It’s a good practice..
to define keys for intent extras using your app's package name as a prefix.
 This ensures they are unique, in case your app interacts with other apps.
Starting Another Activity
http://developer.android.com/training/basics/firstapp/starting-activity.html#BuildIntent
                              Project Attached
Starting Another Activity
public final static String EXTRA_MESSAGE =
"com.example.intetsample.MESSAGE";

public void sendMessage(View view) {
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.editText1);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
  }
AndroidManifest.xml
AndroidManifest.xml
<application
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:theme="@style/AppTheme" >
       <activity
           android:name=".MainActivity"
           android:label="@string/title_activity_main" >
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />

               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       <activity
           android:name=".DisplayMessageActivity"
           android:label="@string/title_activity_display_message" >
           <meta-data
               android:name="android.support.PARENT_ACTIVITY"
               android:value="com.example.intetsample.MainActivity" />
       </activity>
   </application>
Managing the Activity
    Life Cycle
Destroy the activity
   onDestroy()
Destroy the activity
onPasue()
 @Override
 public void onPause() {
    // Always call the superclass method first
     super.onPause();

     //   Release the Camera because
     //   we don't need it when paused
     //   and other activities might need to use it.
     if   (mCamera != null) {
           mCamera.release()
           mCamera = null;
     }
 }
onResume()
 @Override
 public void onResume() {
    // Always call the superclass method first
    super.onResume();

            // Get the Camera instance as the activity
     // achieves full user focus
      if (mCamera == null) {
        // Local method to handle camera init
          initializeCamera(); }
 }
Recreating activity
  onSaveInstanceState
Storage – Database
     Sqlite3
Draggable stick
 project sample attached
OpenGL ES
How can we animate?
'Must Override a Superclass
   Method' Errors after importing a
    project into Eclipse Problem
http://stackoverflow.com/questions/1678122/must-override-a-superclass-
           method-errors-after-importing-a-project-into-eclips
@Override
public boolean onTouchEvent(MotionEvent e) {
    float x = e.getX();        float y = e.getY();
    switch (e.getAction()) {
        case MotionEvent.ACTION_MOVE:

           float dx = x - mPreviousX;      float dy = y - mPreviousY;

           //   reverse direction of rotation   above the mid-line
           if   (y > getHeight() / 2) {         dx = dx * -1 ; }
           //   reverse direction of rotation   to left of the mid-line
           if   (x < getWidth() / 2) {          dy = dy * -1 ; }

           mRenderer.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR;
           // = 180.0f / 320
           requestRender();
    }
    mPreviousX = x;         mPreviousY = y;
    return true;
}
Let’s get our hands dirty
        with code!
Advanced Training
•   Making Your App Location Aware
•   Performing Network Operations
•   Transferring Data Without Draining the Battery
•   Syncing to the Cloud
•   Designing for Multiple Screens
•   Improving Layout Performance
•   Managing Audio Playback
•   Optimizing Battery Life
•   Creating Custom Views
•   Adding Search Functionality
•   Remembering Users
•   Sharing Content
•   Capturing Photos
•   Maintaining Multiple APKs
•   Creating Backward-Compatible UIs
•   Developing for Enterprise
•   Monetizing Your App
•   Designing Effective Navigation
•   Implementing Effective Navigation
•   Designing for TV
•   Displaying Bitmaps Efficiently
•   Implementing Accessibility
•   Displaying Graphics with OpenGL ES
See you nxt time!

Más contenido relacionado

La actualidad más candente

The Life and Times of UIViewController
The Life and Times of UIViewControllerThe Life and Times of UIViewController
The Life and Times of UIViewController
whilethis
 

La actualidad más candente (20)

Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
Training Session 2
Training Session 2 Training Session 2
Training Session 2
 
The A1 by Christian John Felix
The A1 by Christian John FelixThe A1 by Christian John Felix
The A1 by Christian John Felix
 
iOS_Presentation
iOS_PresentationiOS_Presentation
iOS_Presentation
 
Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Deep dive into AngularJs for Beginners
Deep dive into AngularJs for BeginnersDeep dive into AngularJs for Beginners
Deep dive into AngularJs for Beginners
 
iOS: View Controllers
iOS: View ControllersiOS: View Controllers
iOS: View Controllers
 
Practical Dynamic Actions - Intro
Practical Dynamic Actions - IntroPractical Dynamic Actions - Intro
Practical Dynamic Actions - Intro
 
The Life and Times of UIViewController
The Life and Times of UIViewControllerThe Life and Times of UIViewController
The Life and Times of UIViewController
 
AngularJS - introduction & how it works?
AngularJS - introduction & how it works?AngularJS - introduction & how it works?
AngularJS - introduction & how it works?
 
Angular js
Angular jsAngular js
Angular js
 
December 2014 University iOS Meetup Talk
December 2014 University iOS Meetup TalkDecember 2014 University iOS Meetup Talk
December 2014 University iOS Meetup Talk
 
Angular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHEREAngular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHERE
 
Dive into Angular, part 2: Architecture
Dive into Angular, part 2: ArchitectureDive into Angular, part 2: Architecture
Dive into Angular, part 2: Architecture
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 

Similar a Mobile Software Engineering Crash Course - C04 Android Cont.

Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
Droidcon Berlin
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
openbala
 

Similar a Mobile Software Engineering Crash Course - C04 Android Cont. (20)

04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android Developers
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 
Clean Architecture @ Taxibeat
Clean Architecture @ TaxibeatClean Architecture @ Taxibeat
Clean Architecture @ Taxibeat
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Android
AndroidAndroid
Android
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Exercises
ExercisesExercises
Exercises
 
Android 3
Android 3Android 3
Android 3
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
 

Más de Mohammad Shaker

Más de Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Último (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Mobile Software Engineering Crash Course - C04 Android Cont.

  • 1. Mobile Software Engineering L04 – Android Cont. Mohammad Shaker FIT of Damascus - AI dept. MohammadShakerGtr@gmail.com Mobile SE – August 2012
  • 3. Intent an object that provides runtime binding between separate components (such as two activities)
  • 4. Intent carry a collection of various data types as key-value pairs called extras through putExtra()
  • 5. It’s a good practice.. to define keys for intent extras using your app's package name as a prefix. This ensures they are unique, in case your app interacts with other apps.
  • 7. Starting Another Activity public final static String EXTRA_MESSAGE = "com.example.intetsample.MESSAGE"; public void sendMessage(View view) { Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.editText1); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); }
  • 9. AndroidManifest.xml <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".DisplayMessageActivity" android:label="@string/title_activity_display_message" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.example.intetsample.MainActivity" /> </activity> </application>
  • 10. Managing the Activity Life Cycle
  • 11.
  • 12. Destroy the activity onDestroy()
  • 14. onPasue() @Override public void onPause() { // Always call the superclass method first super.onPause(); // Release the Camera because // we don't need it when paused // and other activities might need to use it. if (mCamera != null) { mCamera.release() mCamera = null; } }
  • 15. onResume() @Override public void onResume() { // Always call the superclass method first super.onResume(); // Get the Camera instance as the activity // achieves full user focus if (mCamera == null) { // Local method to handle camera init initializeCamera(); } }
  • 16. Recreating activity onSaveInstanceState
  • 18. Draggable stick project sample attached
  • 20. How can we animate?
  • 21. 'Must Override a Superclass Method' Errors after importing a project into Eclipse Problem http://stackoverflow.com/questions/1678122/must-override-a-superclass- method-errors-after-importing-a-project-into-eclips
  • 22. @Override public boolean onTouchEvent(MotionEvent e) { float x = e.getX(); float y = e.getY(); switch (e.getAction()) { case MotionEvent.ACTION_MOVE: float dx = x - mPreviousX; float dy = y - mPreviousY; // reverse direction of rotation above the mid-line if (y > getHeight() / 2) { dx = dx * -1 ; } // reverse direction of rotation to left of the mid-line if (x < getWidth() / 2) { dy = dy * -1 ; } mRenderer.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR; // = 180.0f / 320 requestRender(); } mPreviousX = x; mPreviousY = y; return true; }
  • 23. Let’s get our hands dirty with code!
  • 24. Advanced Training • Making Your App Location Aware • Performing Network Operations • Transferring Data Without Draining the Battery • Syncing to the Cloud • Designing for Multiple Screens • Improving Layout Performance • Managing Audio Playback • Optimizing Battery Life • Creating Custom Views • Adding Search Functionality • Remembering Users • Sharing Content • Capturing Photos • Maintaining Multiple APKs • Creating Backward-Compatible UIs • Developing for Enterprise • Monetizing Your App • Designing Effective Navigation • Implementing Effective Navigation • Designing for TV • Displaying Bitmaps Efficiently • Implementing Accessibility • Displaying Graphics with OpenGL ES
  • 25. See you nxt time!