Wednesday, April 24, 2019

Understanding Android Manifest File


                                           

                                               Android Manifest file



Every Android application must have a manifest file. Manifest file contains very essential information about the application. Having a proper understanding of manifest is necessary for Android application development.

A manifest file contains following information of Android application

  • Package name: The package name serves as a unique identifier for the application.
  • Activities : All activities are declared in manifest file.
  • Services : All the services used in you application must be declared in activities.
  • BroadcastReceivers : If your application has broadcast receiver, it must be declared in the manifest file.
  • Permissions : Lists the permissions required for your application.
  • API Level : It declares the minimum, maximum and target API level of the Android API that the application requires.
  • Application version : specifies the application version.
  • Features used in application : it specifies which android feature the application require to run properly.
  • Supported screen size : Android devices comes in many shapes and size. You need to specify which screen types your application supports.


Let us have a sample manifest file and discuss each element in detail.



<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.calculator"
    android:versionCode="1"
    android:versionName="1.1" >

    <uses-sdk
        android:minSdkVersion="8"
        android:maxSdkVersion="16"
        android:targetSdkVersion="15" />
   
    <!--  list of permissions  -->
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_MMS" />
   
    <!--  Screen types supported  -->
    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="false"/>
   
    <!--  Features needed -->
    <uses-feature android:name="android.hardware.bluetooth" />
    <uses-feature android:name="android.hardware.camera" />

    <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>
       
         <receiver android:name=".SmsReceiver">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>
        <service  android:name="VibrateService"/>
       
    </application>

</manifest>



Let us discuss each attribute
1:   package="com.android.calculator"
package name of the application is "com.android.calculator".
2: android:versionName="1.1"
version of application is 1.1
3: <uses-sdk
        android:minSdkVersion="8"
        android:maxSdkVersion="16"
        android:targetSdkVersion="15" />

minSdkVersion attribute: specifies the lowest API level that the application supports, here it is 8.
maxSdkVersion attribute: specifies the maximum/highst API level that the application supports, here it is 16.
targetSdkVersion attribute: specifies the optimun API level that the application supports, here it is 15.



4: <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_MMS" />

The application has requested four permissons
Permission to read contacts.
Permission to access internet.
Permission to vibrate the device.
Permission to receive the SMS.


Note: If you not declare the required permission in the manifest and use the feature in your application you will get “SecurityException”. List of all imporatnt permissions is given in the appendix.

5:    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="false"/>

application supports devices with small and normal screens but not support devices with large screens.

6: <uses-feature android:name="android.hardware.bluetooth" />
   <uses-feature android:name="android.hardware.camera" />

Application uses camera and Bluetooth hardware of the device.


7: the     <application> tag

In the application tag all activities, services and broadcast receivers are declared.

23 comments:

  1. First of all I would like to say excellent blog!
    I had a quick question which I'd like to ask if you do not mind.
    I was interested to know how you center yourself and clear your
    head before writing. I've had a difficult time clearing my thoughts in getting my ideas out.

    I truly do enjoy writing but it just seems like the
    first 10 to 15 minutes are wasted just trying to figure
    out how to begin. Any suggestions or hints? Kudos!

    ReplyDelete
  2. Hi there i am kavin, its my first occasion to commenting anywhere, when i read this
    piece of writing i thought i could also create comment due
    to this good paragraph.

    ReplyDelete
  3. Keep on working, great job!

    ReplyDelete
  4. My brother suggested I might like this blog.
    He was entirely right. This post truly made my day.

    You can not imagine just how much time I had spent for this information! Thanks!

    ReplyDelete
  5. My programmer is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he's tryiong none the less. I've been using Movable-type on numerous websites
    for about a year and am concerned about switching to another
    platform. I have heard fantastic things about blogengine.net.
    Is there a way I can import all my wordpress posts into it?
    Any kind of help would be really appreciated!

    ReplyDelete
  6. Hello my family member! I wish to say that this post is amazing, nice written and come with
    almost all important infos. I would like to look more posts like this .

    ReplyDelete
  7. Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn't appear.
    Grrrr... well I'm not writing all that over again. Anyways, just wanted to say superb blog!

    ReplyDelete
  8. Touche. Sound arguments. Keep up the good work.

    ReplyDelete
  9. I've been browsing online greater than three hours as of
    late, but I by no means discovered any interesting article like yours.
    It's pretty price enough for me. Personally, if all site owners and bloggers made excellent content material as you probably did, the net will be much more
    helpful than ever before.

    ReplyDelete
  10. I think that what you posted made a bunch of sense.
    But, what about this? what if you added a little content?
    I am not suggesting your content isn't solid., however suppose you added a
    post title to possibly get folk's attention? I mean "Understanding Android Manifest File" is a little plain. You ought to peek at Yahoo's home
    page and note how they write post titles to grab people
    interested. You might try adding a video or a picture or
    two to get people excited about everything've written.
    In my opinion, it would make your blog a little livelier.

    ReplyDelete
  11. Hi, i believe that i noticed you visited my blog so i
    came to return the choose?.I'm attempting to in finding things to enhance
    my web site!I guess its good enough to make use of some
    of your concepts!!

    ReplyDelete
  12. I've been exploring for a little bit for any high-quality articles or
    weblog posts on this sort of space . Exploring in Yahoo I ultimately stumbled upon this
    site. Studying this information So i am satisfied to express that
    I've a very excellent uncanny feeling I discovered exactly what I needed.
    I such a lot certainly will make certain to don?t overlook this website
    and provides it a look regularly.

    ReplyDelete
  13. Hiya very cool web site!! Guy .. Beautiful .. Amazing ..
    I'll bookmark your blog and take the feeds also?
    I am glad to seek out numerous useful info here within the publish, we need work
    out extra techniques in this regard, thanks for sharing.
    . . . . .

    ReplyDelete
  14. Hi there, I discovered your blog by way of Google even as looking for a similar topic,
    your web site came up, it appears to be like great.
    I have bookmarked it in my google bookmarks.
    Hi there, simply turned into aware of your weblog via Google, and found that it is really informative.
    I'm gonna watch out for brussels. I'll appreciate for those who continue this in future.
    Numerous folks shall be benefited from your writing.
    Cheers!

    ReplyDelete
  15. Hello there! This is my first comment here so I just wanted
    to give a quick shout out and tell you I genuinely
    enjoy reading your blog posts. Can you recommend any
    other blogs/websites/forums that deal with the same subjects?
    Thanks!

    ReplyDelete
  16. Greetings from Carolina! I'm bored at work so I decided to browse your site on my iphone during lunch
    break. I really like the information you present here and can't wait to take a look when I
    get home. I'm amazed at how quick your blog loaded on my mobile ..
    I'm not even using WIFI, just 3G .. Anyhow, excellent site!

    ReplyDelete
  17. Greetings! I know this is somewhat off topic but I was wondering if you knew where I
    could locate a captcha plugin for my comment form?

    I'm using the same blog platform as yours and
    I'm having problems finding one? Thanks a lot!

    ReplyDelete
  18. Hi outstanding blog! Does running a blog such as this require a large amount of work?

    I've virtually no knowledge of computer programming however I was hoping to start my own blog
    soon. Anyhow, should you have any ideas or tips for new blog owners please share.
    I know this is off subject nevertheless I simply needed to ask.

    Thank you!

    ReplyDelete
  19. Hello There. I found your blog using msn. This is a very well written article.
    I'll be sure to bookmark it and return to read more of your useful info.

    Thanks for the post. I will certainly comeback.

    ReplyDelete
  20. Hmm is anyone else experiencing problems with the pictures on this blog
    loading? I'm trying to determine if its a problem on my end or if it's
    the blog. Any feed-back would be greatly appreciated.

    ReplyDelete
  21. Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is valuable and all. But imagine if you added some
    great graphics or videos to give your posts more, "pop"!

    Your content is excellent but with pics and video clips, this website could certainly
    be one of the greatest in its field. Good blog!

    ReplyDelete