Pres Android 1

download Pres Android 1

of 28

Transcript of Pres Android 1

  • 8/13/2019 Pres Android 1

    1/28

    Universidad Autonoma de TamaulipasFacultad de Ingeniera y Ciencias

    Programacion en Android

    M.C. Juan Jose Garza Saldana

    M.C. Juan Jose Garza Saldana Programacion en Android 1/1

    http://find/
  • 8/13/2019 Pres Android 1

    2/28

  • 8/13/2019 Pres Android 1

    3/28

  • 8/13/2019 Pres Android 1

    4/28

  • 8/13/2019 Pres Android 1

    5/28

    Applications

    SecurityThere are ways for an app to share data with other application and

    to access system services.Sharing the same Linux User ID.Request permission to access users contacts, SMS messages, SDcard, camera, ...

    M.C. Juan Jose Garza Saldana Programacion en Android 5/1

    http://find/
  • 8/13/2019 Pres Android 1

    6/28

  • 8/13/2019 Pres Android 1

    7/28

  • 8/13/2019 Pres Android 1

    8/28

  • 8/13/2019 Pres Android 1

    9/28

    Four types of application components

    Broadcast receiversAlthough broadcast receivers dont display a user interface, they maycreate a status bar notication to alert the user when a broadcast

    event occurs.More commonly, though, a broadcast receiver is just a gatewaytoother components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some workbased on the event.

    M.C. Juan Jose Garza Saldana Programacion en Android 9/1

    http://find/
  • 8/13/2019 Pres Android 1

    10/28

    Activating components

    Three of the four component typesactivities, services, andbroadcast receiversare activated by an asynchronous messagecalled an intent.Intents bind individual components to each other at runtime (youcan think of them as the messengers that request an action fromother components), whether the component belongs to yourapplication or another.Content provider, is not activated by intents. Rather, it is activatedwhen targeted by a request from a ContentResolver.

    M.C. Juan Jose Garza Saldana Programacion en Android 10/1

    http://find/
  • 8/13/2019 Pres Android 1

    11/28

    The Manifest File

    Application must declare all its components in this leMust be at the root of the application project directory

    M.C. Juan Jose Garza Saldana Programacion en Android 11/1

    h f l

    http://find/
  • 8/13/2019 Pres Android 1

    12/28

    The Manifest File

    Identify any user permissions the application requires, such asInternet access or read-access to the users contacts.Declare the minimum API Level required by the application, basedon which APIs the application uses.

    Declare hardware and software features used or required by theapplication, such as a camera, bluetooth services, or a multitouchscreen.API libraries the application needs to be linked against (other thanthe Android framework APIs), such as the Google Maps library.More

    M.C. Juan Jose Garza Saldana Programacion en Android 12/1

    S i i i

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    13/28

    Starting an activity

    Android system initiate code in an Activity instance (not in a main()function)There is a sequence of callback methods that start up an activityand a sequence of callback methods that tear down an activity.

    M.C. Juan Jose Garza Saldana Programacion en Android 13/1

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    14/28

    St ti ti it

  • 8/13/2019 Pres Android 1

    15/28

    Starting an activity

    Depending on the complexity of your activity, you probably dontneed to implement all the lifecycle methods.

    Its important that you understand each one and implement thosethat ensure your app behaves the way users expect.Implementing your activity lifecycle methods properly ensures yourapp behaves well in several ways

    M.C. Juan Jose Garza Saldana Programacion en Android 15/1

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    16/28

    Simplied life cycle

  • 8/13/2019 Pres Android 1

    17/28

    Simplied life cycle

    M.C. Juan Jose Garza Saldana Programacion en Android 17/1

    Main Activity

    http://find/
  • 8/13/2019 Pres Android 1

    18/28

    Main Activity

    Dene which activity to use as the main activity in the Android manifest

    le, AndroidManifest.xml

    M.C. Juan Jose Garza Saldana Programacion en Android 18/1

    Create a New Instance

    http://find/
  • 8/13/2019 Pres Android 1

    19/28

    Create a New Instance

    M.C. Juan Jose Garza Saldana Programacion en Android 19/1

    Destroy the Activity

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    20/28

    Destroy the Activity

    Check listThe system calls this method on your activity as the nal signal thatyour activity instance is being completely removed from the system

    memory.Most apps dont need to implement this method because local classreferences are destroyed with the activity and your activity shouldperform most cleanup

    M.C. Juan Jose Garza Saldana Programacion en Android 20/1

    Pausing and Resuming an Activity

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    21/28

    Pausing and Resuming an Activity

    M.C. Juan Jose Garza Saldana Programacion en Android 21/1

    Pause Your Activity

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    22/28

    Pause Your Activity

    Technically means your activity is still partially visibleOften is an indication that the user is leaving the activity and it willsoon enter the Stopped state

    Uses:Stop animations or other ongoing actions that could consume CPU.Commit unsaved changes (such as a draft email).Release system resources, that may affect battery life while youractivity is paused and the user does not need them.

    M.C. Juan Jose Garza Saldana Programacion en Android 22/1

    Resume Your Activity

    http://find/http://goback/
  • 8/13/2019 Pres Android 1

    23/28

    Resume Your Activity

    When the user resumes your activity from the Paused state, thesystem calls the onResume() method.The system calls this method every time your activity comes into theforeground, including when its created for the rst time.

    M.C. Juan Jose Garza Saldana Programacion en Android 23/1

    http://find/
  • 8/13/2019 Pres Android 1

    24/28

    Stopping and Restarting an Activity

  • 8/13/2019 Pres Android 1

    25/28

    Stopp g a d esta t g a ct v ty

    M.C. Juan Jose Garza Saldana Programacion en Android 25/1

    Recreating an Activity

    http://find/
  • 8/13/2019 Pres Android 1

    26/28

    g y

    M.C. Juan Jose Garza Saldana Programacion en Android 26/1

    Permissions

    http://find/
  • 8/13/2019 Pres Android 1

    27/28

    Using PermissionsA basic Android application has no permissions associated with it bydefault.

    Meaning it can not do anything that would adversely impact theuser experience or any data on the deviceMust include in your AndroidManifest.xml one or more< uses-permission> tags declaring the permissions that yourapplication needs

    M.C. Juan Jose Garza Saldana Programacion en Android 27/1

    Permissions

    http://find/
  • 8/13/2019 Pres Android 1

    28/28

    Using PermissionsAt application install time, permissions requested by the applicationare granted to it by the package installer.No checks with the user are done while an application is running (Itcan run or not because of permissions).

    http://developer.android.com/guide/topics/security/permissions.html

    M.C. Juan Jose Garza Saldana Programacion en Android 28/1

    http://find/