summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/topics/manifest/uses-library-element.jd
blob: 253807e89a0bee24351cc056c67f0054e7c2c200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
page.title=<uses-library>
parent.title=The AndroidManifest.xml File
parent.link=manifest-intro.html
@jd:body

<div class="sidebox-wrapper"> 
<div class="sidebox">
    <img src="{@docRoot}assets/images/icon_play.png" style="float:left;margin:0;padding:0;"> 
    <p style="color:#669999;padding-top:1em;">Google Play Filtering</p> 
    <p style="padding-top:1em;">Google Play uses the &lt;uses-library&gt; elements declared
    in your app manifest to filter your app from devices that do not meet it's library
    requirements. For more information about filtering, see the topic
    <a href="{@docRoot}google/play/filters.html">Google Play filters</a>.</p>
  </div>
</div>

<dl class="xml">

<dt>syntax:</dt>
<dd>
<pre class="stx">
&lt;uses-library
  android:<a href="#nm">name</a>="<var>string</var>"
  android:<a href="#rq">required</a>=["true" | "false"] /&gt;
</pre>
</dd>
<dt>contained in:</dt>
<dd>
    <code>
        <a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a>
    </code>
</dd>
<dt>description:</dt>
<dd>
    Specifies a shared library that the application must be linked against.
    This element tells the system to include the library's code in the class
    loader for the package.
    <p>
        All of the {@code android} packages (such as {@link android.app},
        {@link android.content}, {@link android.view}, and {@link android.widget})
        are in the default library that all applications are automatically linked
        against.  However, some packages (such as {@code maps}) are
        in separate libraries that are not automatically linked.  Consult the
        documentation for the packages you're using to determine which library
        contains the package code.
    </p>
    <p>
        This element also affects the installation of the application on a particular device and
        the availability of the application on Google Play:
    </p>
    <dl>
        <dt><em>Installation</em></dt>
        <dd>
            If this element is present and its {@code android:required} attribute is set to
            {@code true}, the {@link android.content.pm.PackageManager} framework won't let the user
            install the application unless the library is present on the user's device.
        </dd>
    </dl>
    <p>
        The {@code android:required} attribute is described in detail in the following section.
    </p>
</dd>
<dt>attributes:</dt>
<dd>
    <dl class="attr">
        <dt><a name="nm"></a>{@code android:name}</dt>
        <dd>
            The name of the library. The name is provided by the
            documentation for the package you are using. An example of this is
            &quot;<code>android.test.runner</code>&quot;, a package that contains Android test
            classes.
        </dd>
        <dt><a name="rq"></a>{@code android:required}</dt>
        <dd>
            Boolean value that indicates whether the application requires the
            library specified by {@code android:name}:
            <ul>
                <li>
                    <code>&quot;true&quot;</code>: The application does not function without this
                    library. The system will not allow the application on a device that does not
                    have the library.
                </li>
                <li>
                    <code>&quot;false&quot;</code>: The application can use the
                    library if present, but is designed to function without it if necessary.
                    The system will allow the application to be installed, even if the library is
                    not present. If you use <code>&quot;false&quot;</code>, you are responsible for
                    checking at runtime that the library is available.
                    <p>
                        To check for a library, you can use reflection to determine
                        if a particular class is available.
                    </p>
                </li>
            </ul>
            <p>
                The default is <code>&quot;true&quot;</code>.
            </p>
            <p>Introduced in: API Level 7.</p>
        </dd>
    </dl>
</dd>
<!-- ##api level indication## -->
<dt>introduced in:</dt>
<dd>API Level 1</dd>

<dt>see also:</dt>
<dd>
  <ul>
    <li>{@link android.content.pm.PackageManager}</li>
  </ul>
</dd>
</dl>