SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
Android


                      Android Training Part 2
                            RGUIG Saad - AIMAF




lundi 21 janvier 13                                        1
Android


                              Morning Program :

                      1. Acess and permissions
                      2. Layouts and screens
                      3. Maps and geolocation
                      4. Implementation of Geolocation app




lundi 21 janvier 13                                                    2
Acess and permissions         Android

                      Permissions in Manifest

          A basic Android application has no permissions
          associated with it by default, meaning it can not do
          anything that would adversely impact the user
          experience or any data on the device. To make use of
          protected features of the device, you must include in
          your AndroidManifest.xml one or more <uses-
          permission> tags declaring the permissions that your
          application needs.



lundi 21 janvier 13                                               3
Acess and permissions                             Android

                      Sample permissins in Manifest
        <uses-permission android:name="android.permission.INTERNET" />
           <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

              <permission
                  android:name="lu.luxauto.permission.C2D_MESSAGE"
                  android:protectionLevel="signature" />

              <uses-permission android:name="lu.luxauto.permission.C2D_MESSAGE" />

              <!-- App must have this permission to use the library -->
              <uses-permission android:name="android.permission.WAKE_LOCK" />
              <uses-permission android:name="android.permission.GET_ACCOUNTS" />
              <uses-permission android:name="android.permission.USE_CREDENTIALS" />
              <uses-permission android:name="android.permission.CALL_PHONE" />
              <uses-permission android:name="android.permission.INTERNET" />
              <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
              <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
              <uses-permission android:name="android.permission.READ_PHONE_STATE" />
              <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
              <uses-permission android:name="android.permission.GET_ACCOUNTS" />
              <uses-permission android:name="com.android.vending.BILLING" />

lundi 21 janvier 13                                                                            4
Acess and permissions    Android

                      Sample permissins in Manifest




lundi 21 janvier 13                                             5
Acess and permissions    Android

                      Sample permissins in Manifest




lundi 21 janvier 13                                             6
Acess and permissions   Android
                      Sample permissins




lundi 21 janvier 13                                      7
Layout and screens   Android
                      Sample permissins




lundi 21 janvier 13                                   8
Layout and screens   Android
                      View Hierarchy




lundi 21 janvier 13                                  9
Layout and screens   Android
                          Demo




lundi 21 janvier 13                                  10
Map and Geolocation   Android
                        Introduction




lundi 21 janvier 13                                   11
Map and Geolocation                 Android
                        Steps of implementation




      Add Map Library and
       User Permissions

            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-library android:name="com.google.android.maps"/>




lundi 21 janvier 13                                                         12
Map and Geolocation                 Android
                        Steps of implementation




      Add Map Library and
       User Permissions

            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-library android:name="com.google.android.maps"/>




lundi 21 janvier 13                                                         13
Map and Geolocation                 Android

                               Steps of implementation



        Map Layout
                      <?xml version="1.0" encoding="utf-8"?>
                      <com.google.android.maps.MapView
                          xmlns:android="http://schemas.android.com/apk/res/android"
                          android:id="@+id/mapview"
                          android:layout_width="fill_parent"
                          android:layout_height="fill_parent"
                          android:clickable="true"
                          android:apiKey="My Map Key"
                      />

lundi 21 janvier 13                                                                14
Map and Geolocation                 Android

                               Steps of implementation



        MapActivity
              public class MainActivity extends MapActivity {

              	       @Override
              	       protected void onCreate(Bundle savedInstanceState) {
              	       	 super.onCreate(savedInstanceState);
              	       	 setContentView(R.layout.activity_main);
              	       	 MapView mapView = (MapView) findViewById(R.id.mapview);
              	           mapView.setBuiltInZoomControls(true);
              	       }


lundi 21 janvier 13                                                               15
Map and Geolocation                 Android

                               Steps of implementation



        MapActivity
              public class MainActivity extends MapActivity {

              	       @Override
              	       protected void onCreate(Bundle savedInstanceState) {
              	       	 super.onCreate(savedInstanceState);
              	       	 setContentView(R.layout.activity_main);
              	       	 MapView mapView = (MapView) findViewById(R.id.mapview);
              	           mapView.setBuiltInZoomControls(true);
              	       }


lundi 21 janvier 13                                                               16
Map and Geolocation    Android

                      Steps of implementation


      Make sure
      Build target
       is of type
      Google API




lundi 21 janvier 13                                       17
Map and Geolocation         Android
                       Get Google Map Key
           https://developers.google.com/maps/documentation/
              android/v1/mapkey?hl=fr#getdebugfingerprint
           https://developers.google.com/maps/documentation/
                     android/v1/maps-api-signup?hl=fr




lundi 21 janvier 13                                            18
Map and Geolocation   Android
                      Get Google Map Key




lundi 21 janvier 13                                    19
Map and Geolocation   Android
                         App install




lundi 21 janvier 13                                   20
Map and Geolocation                             Android
                       Steps of implementation
        Marker
     // Add Marker
  	      List<Overlay> mapOverlays = mapView.getOverlays();
  	      Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
  	      HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);
  	      GeoPoint point = new GeoPoint(48856628,2370228);
  	      OverlayItem overlayitem = new OverlayItem(point, "Aimaf Formation Android", "Salut
  les amis! nous sommes ici :)");
  	      itemizedoverlay.addOverlay(overlayitem);
  	      mapOverlays.add(itemizedoverlay);
  	
     //Add controller and animate to GeoPoint
          MapController mc = mapView.getController();
          MyLocationOverlay myLoc = new MyLocationOverlay(this, mapView);
          myLoc.enableCompass();
          mapView.getOverlays().add(myLoc);
          mc.animateTo(point);



lundi 21 janvier 13                                                                           21
Map and Geolocation   Android
                        ScreenShot




lundi 21 janvier 13                                   22
Android




lundi 21 janvier 13             23

Weitere ähnliche Inhalte

Ähnlich wie Formation aimaf-android-part2

Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
A journey through android development
A journey through android developmentA journey through android development
A journey through android developmentraditya gumay
 
Maps in android
Maps in androidMaps in android
Maps in androidSumita Das
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N HighligtsSercan Yusuf
 
Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30Somkiat Khitwongwattana
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialDanish_k
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android ProgrammingRaveendra R
 
Androidbasedtaskschedulerandindicator (2).pdf
Androidbasedtaskschedulerandindicator (2).pdfAndroidbasedtaskschedulerandindicator (2).pdf
Androidbasedtaskschedulerandindicator (2).pdfShubhamDiggikar
 
Android workshop - 02. Glass development 101
Android workshop - 02. Glass development 101Android workshop - 02. Glass development 101
Android workshop - 02. Glass development 101Johnny Sung
 
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Skills Matter
 
Google Maps API for Android
Google Maps API for AndroidGoogle Maps API for Android
Google Maps API for AndroidMaksim Golivkin
 
MTC13 Android UIs für alle(s)
MTC13 Android UIs für alle(s)MTC13 Android UIs für alle(s)
MTC13 Android UIs für alle(s)Andreas Hölzl
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial pptRehna Renu
 

Ähnlich wie Formation aimaf-android-part2 (20)

Android in practice
Android in practiceAndroid in practice
Android in practice
 
Android Sunumu
Android SunumuAndroid Sunumu
Android Sunumu
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
A journey through android development
A journey through android developmentA journey through android development
A journey through android development
 
Android development beginners faq
Android development  beginners faqAndroid development  beginners faq
Android development beginners faq
 
Maps in android
Maps in androidMaps in android
Maps in android
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N Highligts
 
Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
Androidbasedtaskschedulerandindicator (2).pdf
Androidbasedtaskschedulerandindicator (2).pdfAndroidbasedtaskschedulerandindicator (2).pdf
Androidbasedtaskschedulerandindicator (2).pdf
 
Android workshop - 02. Glass development 101
Android workshop - 02. Glass development 101Android workshop - 02. Glass development 101
Android workshop - 02. Glass development 101
 
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
 
Google Maps API for Android
Google Maps API for AndroidGoogle Maps API for Android
Google Maps API for Android
 
MTC13 Android UIs für alle(s)
MTC13 Android UIs für alle(s)MTC13 Android UIs für alle(s)
MTC13 Android UIs für alle(s)
 
Permissions
PermissionsPermissions
Permissions
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial ppt
 

Formation aimaf-android-part2

  • 1. Android Android Training Part 2 RGUIG Saad - AIMAF lundi 21 janvier 13 1
  • 2. Android Morning Program : 1. Acess and permissions 2. Layouts and screens 3. Maps and geolocation 4. Implementation of Geolocation app lundi 21 janvier 13 2
  • 3. Acess and permissions Android Permissions in Manifest A basic Android application has no permissions associated with it by default, meaning it can not do anything that would adversely impact the user experience or any data on the device. To make use of protected features of the device, you must include in your AndroidManifest.xml one or more <uses- permission> tags declaring the permissions that your application needs. lundi 21 janvier 13 3
  • 4. Acess and permissions Android Sample permissins in Manifest <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <permission android:name="lu.luxauto.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="lu.luxauto.permission.C2D_MESSAGE" /> <!-- App must have this permission to use the library --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="com.android.vending.BILLING" /> lundi 21 janvier 13 4
  • 5. Acess and permissions Android Sample permissins in Manifest lundi 21 janvier 13 5
  • 6. Acess and permissions Android Sample permissins in Manifest lundi 21 janvier 13 6
  • 7. Acess and permissions Android Sample permissins lundi 21 janvier 13 7
  • 8. Layout and screens Android Sample permissins lundi 21 janvier 13 8
  • 9. Layout and screens Android View Hierarchy lundi 21 janvier 13 9
  • 10. Layout and screens Android Demo lundi 21 janvier 13 10
  • 11. Map and Geolocation Android Introduction lundi 21 janvier 13 11
  • 12. Map and Geolocation Android Steps of implementation Add Map Library and User Permissions <uses-permission android:name="android.permission.INTERNET"/> <uses-library android:name="com.google.android.maps"/> lundi 21 janvier 13 12
  • 13. Map and Geolocation Android Steps of implementation Add Map Library and User Permissions <uses-permission android:name="android.permission.INTERNET"/> <uses-library android:name="com.google.android.maps"/> lundi 21 janvier 13 13
  • 14. Map and Geolocation Android Steps of implementation Map Layout <?xml version="1.0" encoding="utf-8"?> <com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="My Map Key" /> lundi 21 janvier 13 14
  • 15. Map and Geolocation Android Steps of implementation MapActivity public class MainActivity extends MapActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); } lundi 21 janvier 13 15
  • 16. Map and Geolocation Android Steps of implementation MapActivity public class MainActivity extends MapActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); } lundi 21 janvier 13 16
  • 17. Map and Geolocation Android Steps of implementation Make sure Build target is of type Google API lundi 21 janvier 13 17
  • 18. Map and Geolocation Android Get Google Map Key https://developers.google.com/maps/documentation/ android/v1/mapkey?hl=fr#getdebugfingerprint https://developers.google.com/maps/documentation/ android/v1/maps-api-signup?hl=fr lundi 21 janvier 13 18
  • 19. Map and Geolocation Android Get Google Map Key lundi 21 janvier 13 19
  • 20. Map and Geolocation Android App install lundi 21 janvier 13 20
  • 21. Map and Geolocation Android Steps of implementation Marker // Add Marker List<Overlay> mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.marker); HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this); GeoPoint point = new GeoPoint(48856628,2370228); OverlayItem overlayitem = new OverlayItem(point, "Aimaf Formation Android", "Salut les amis! nous sommes ici :)"); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); //Add controller and animate to GeoPoint MapController mc = mapView.getController(); MyLocationOverlay myLoc = new MyLocationOverlay(this, mapView); myLoc.enableCompass(); mapView.getOverlays().add(myLoc); mc.animateTo(point); lundi 21 janvier 13 21
  • 22. Map and Geolocation Android ScreenShot lundi 21 janvier 13 22