Unit - 02 Working with permission and resource



Lesson Plan: Unit - 02
Subject: P15A2AAD - Android Application Development
Topic of Study: Working with permission and Resources
Grade/Level: Master of Computer Applications
Objective: To understand the mechanism of permission and resources for Android OS.
Time Allotment: 55 Minutes
  • Working with Permission
    • The permission defined from (android.Manifest.permission).
    • The Android OS has been locked down so that applications have limited capability.
    • Android applications have no permissions by default.
    • These permissions are granted when the application is installed.
    • It is defines a permission using the uses-permission tag.
      • Exa.
    • Applications can also define their own permissions by using the uses-permission tag.
    • Permissions can be enforced at several points:
      • When starting an Activity or Service
      • When accessing data provided by a content provider
      • At the function call level
      • When sending or receiving broadcasts by an Intent.
  • Working with Resources
    • Android applications are composed of two things: functionality (code instructions) and data (resources).
      • The functionality is the code that determines how your application behaves.
      • Resources include text strings, images and icons, audio files, videos, and other data used by the application.
    • Rules for Resources:
      • Android resource files are stored separately in XML.
      • Resources are organized in a strict directory hierarchy.
      • All resources must be stored under the /res project directory
      • It must be lowercase.
    • Different resource types are stored in different directories.
    • Each resource type corresponds to a specific resource sub-directory name.
    • Exa.
    • Resources can be further organized in a variety of ways of /res/drawable directory.
    • Exa.
    • Why we need AAPT
      • AAPT stands for Android Asset Packaging Tool
      • The plug-in detects new resources when you add them to the appropriate project resource directory under /res automatically.
      • These resources are compiled, resulting in the generation of the R.java file, which enables you to access your resources programmatically.
      • If you use a different development environment, you need to use the aapt tool command-line interface to compile your resources and package your application binaries  to deploy to the phone or emulator.
      • You can find the aapt tool in the /tools sub-directory of each specific Android SDK version.
    • Resource Value Types
      • Types of resources—such as text strings, graphics, and color schemes—for user interface design.
      • These resources are stored in the /res directory.
      • All resources filenames must be lowercase and simple.
      • Exa.
        • Strings
          • Arrays of Strings
        • Booleans
        • Colors
        • Dimensions
        • Integers
          • Arrays of Integers
        • Layout
        • Style and Themes
        • Simple Drawable
        • Graphics
        • Animation
          • Tweened Animation
          • Frame by Frame Animation
    • Accessing Resources Programmatically
      • Developers access specific application resources using the R.java class file and its sub-classes, which are automatically generated when you add resources to your project.
      • You can refer to any resource identifier in your project by name. 
      • Exa.
        • String resource named strHello defined within the resource file called /res/values/strings.xml is accessed in the code as R.string.strHello.
          String myString = getResources().getString(R.string.strHello);
      • The Resources tab provides a friendly method to easily insert primitive resource types such as strings, colors, and dimension resources.
        1. Developers can define resource types by editing resource XML files manually.
        2. Using Android Studio with the Android plug-in, which includes some very handy resource editors.
      • Navigate to the /res/values/strings.xml file.
        1. Double-click the file to edit it manually using tag code. Exa.
        2. On the strings.xml, see at the right side - Click on Open Editor. Exa.
  • Resources types
    • Exa.



Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form