forked from phonegap/phonegap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cordova_splashscreen_splashscreen.md.html
359 lines (307 loc) · 13.7 KB
/
cordova_splashscreen_splashscreen.md.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>Apache Cordova API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
</head>
<body>
<div id="header">
<h1><a href="index.html">Apache <strong>Cordova</strong> Documentation</a></h1>
<small>
<select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="2.2.0rc2">2.2.0rc2</option>
<option value="2.2.0rc1">2.2.0rc1</option>
<option selected value="2.2.0">2.2.0</option>
<option value="2.1.0rc2">2.1.0rc2</option>
<option value="2.1.0rc1">2.1.0rc1</option>
<option value="2.1.0">2.1.0</option>
<option value="2.0.0rc1">2.0.0rc1</option>
<option value="2.0.0">2.0.0</option>
<option value="1.9.0rc1">1.9.0rc1</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.8.0rc1">1.8.0rc1</option>
<option value="1.8.0">1.8.0</option>
<option value="1.7.0rc1">1.7.0rc1</option>
<option value="1.7.0">1.7.0</option>
<option value="1.6.1">1.6.1</option>
<option value="1.6.0rc1">1.6.0rc1</option>
<option value="1.6.0">1.6.0</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value="0.9.5.1">0.9.5.1</option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
</optgroup>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
</optgroup>
<optgroup label="Japanese" value="jp">
<option value="2.0.0">2.0.0</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.7.0">1.7.0</option>
<option value="0.9.5">0.9.5</option>
</optgroup>
<optgroup label="Korean" value="kr"><option value="2.0.0">2.0.0</option></optgroup></select></small>
</div>
<div id="subheader">
<h1>Splashscreen</h1>
<small><select><option value="Splashscreen">Splashscreen</option>
<option value="Splashscreen_methods"> - Methods</option>
<option value="Splashscreen_permissions"> - Permissions</option>
<option value="Splashscreen_setup"> - Setup</option>
<option value="show">show</option>
<option value="show_description"> - Description</option>
<option value="show_supported_platforms"> - Supported Platforms</option>
<option value="show_quick_example"> - Quick Example</option>
<option value="show_full_example"> - Full Example</option>
<option value="hide">hide</option>
<option value="hide_description"> - Description</option>
<option value="hide_supported_platforms"> - Supported Platforms</option>
<option value="hide_quick_example"> - Quick Example</option>
<option value="hide_full_example"> - Full Example</option>
<option value="hide_ios_quirk"> - iOS Quirk</option></select></small>
</div>
<div id="sidebar">
<div class="vertical_divider"></div>
<h1>API Reference</h1>
<ul>
<li><a href="cordova_accelerometer_accelerometer.md.html#Accelerometer">Accelerometer</a></li>
<li><a href="cordova_camera_camera.md.html#Camera">Camera</a></li>
<li><a href="cordova_media_capture_capture.md.html#Capture">Capture</a></li>
<li><a href="cordova_compass_compass.md.html#Compass">Compass</a></li>
<li><a href="cordova_connection_connection.md.html#Connection">Connection</a></li>
<li><a href="cordova_contacts_contacts.md.html#Contacts">Contacts</a></li>
<li><a href="cordova_device_device.md.html#Device">Device</a></li>
<li><a href="cordova_events_events.md.html#Events">Events</a></li>
<li><a href="cordova_file_file.md.html#File">File</a></li>
<li><a href="cordova_geolocation_geolocation.md.html#Geolocation">Geolocation</a></li>
<li><a href="cordova_globalization_globalization.md.html#Globalization">Globalization</a></li>
<li><a href="cordova_media_media.md.html#Media">Media</a></li>
<li><a href="cordova_notification_notification.md.html#Notification">Notification</a></li>
<li><a href="cordova_splashscreen_splashscreen.md.html#Splashscreen">Splashscreen</a></li>
<li><a href="cordova_storage_storage.md.html#Storage">Storage</a></li>
</ul>
<h1>Guides</h1>
<ul>
<li><a href="guide_getting-started_index.md.html#Getting%20Started%20Guides">Getting Started Guides</a></li>
<li><a href="guide_command-line_index.md.html#Command-Line%20Usage">Command-Line Usage</a></li>
<li><a href="guide_upgrading_index.md.html#Upgrading%20Guides">Upgrading Guides</a></li>
<li><a href="guide_project-settings_index.md.html#Project%20Settings">Project Settings</a></li>
<li><a href="guide_plugin-development_index.md.html#Plugin%20Development%20Guide">Plugin Development Guide</a></li>
<li><a href="guide_whitelist_index.md.html#Domain%20Whitelist%20Guide">Domain Whitelist Guide</a></li>
<li><a href="guide_cordova-webview_index.md.html#Embedding%20WebView">Embedding WebView</a></li>
<li><a href="_index.html">Keyword Index</a></li>
</ul>
</div>
<div id="scrollable">
<div id="content">
<h1><a name="Splashscreen">Splashscreen</a></h1>
<blockquote>
<p>Enables developers to <a href="cordova_splashscreen_splashscreen.md.html#show">show</a>/<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a> the application's splash screen.</p>
</blockquote>
<h2>
<a name="Splashscreen_methods">Methods</a>
</h2>
<ul>
<li><a href="cordova_splashscreen_splashscreen.md.html#show">show</a></li>
<li><a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a></li>
</ul>
<h2>
<a name="Splashscreen_permissions">Permissions</a>
</h2>
<h3>Android</h3>
<h4>app/res/xml/config.xml</h4>
<pre class="prettyprint"><code><plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
</code></pre>
<h3>iOS</h3>
<h4>Cordova.plist</h4>
<pre class="prettyprint"><code> Add an entry under the Plugins dictionary - with the key "SplashScreen" and value "CDVSplashScreen".
New projects should already have this key.
</code></pre>
<h2>
<a name="Splashscreen_setup">Setup</a>
</h2>
<h3>Android</h3>
<ol>
<li>
<p>Copy your splash screen image into the res/drawable directories of your Android project. The sizes of each image should be:</p>
<ul>
<li>xlarge (xhdpi): at least 960 x 720</li>
<li>large (hdpi): at least 640 x 480</li>
<li>medium (mdpi): at least 470 x 320</li>
<li>small (ldpi): at least 426 x 320</li>
</ul>
<p>It is highly recommended that you use a <a class="external" href="https://developer.android.com/tools/help/draw9patch.html">9-patch image</a> for your splash screen.</p>
</li>
<li>
<p>In the onCreate method of the class that extends DroidGap add the following two lines:</p>
<pre class="prettyprint"><code>super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 10000);
</code></pre>
<p>The first line 'super.setIntegerProperty' sets the image to be displayed as the splashscreen. If you have named your image anything other than splash.png you will have to modify this line.
The second line is the normal 'super.loadUrl' line but it has a second parameter which is the timeout value for the splash screen. In this example the splash screen will display for 10 seconds. If you want to dismiss the splash screen once you get the "<a href="cordova_events_events.md.html#deviceready">deviceready</a>" event you should call the navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>() method.</p>
</li>
</ol>
<h3>iOS</h3>
<ol>
<li>
<p>Copy your splash screen images into the <strong>Resources/splash</strong> directory of your iOS project. Only add the images for the devices you want to support (iPad screen size or iPhone screen size). The sizes of each image should be:</p>
<ul>
<li>Default-568h@2x~iphone.png (640x1136 pixels)</li>
<li>Default-Landscape@2x~ipad.png (2048x1496 pixels)</li>
<li>Default-Landscape~ipad.png (1024x768 pixels)</li>
<li>Default-Portrait@2x~ipad.png (1536x2008 pixels)</li>
<li>Default-Portrait~ipad.png (768x1024 pixels)</li>
<li>Default@2x~iphone.png (640x960 pixels)</li>
<li>Default~iphone.png (320x240 pixels)</li>
</ul>
</li>
</ol>
<hr>
<h1><a name="show">show</a></h1>
<p>Displays the splash screen.</p>
<pre class="prettyprint"><code>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#show">show</a>();
</code></pre>
<h2>
<a name="show_description">Description</a>
</h2>
<p>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#show">show</a>() displays the applications splash screen.</p>
<h2>
<a name="show_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>iOS</li>
</ul>
<h2>
<a name="show_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#show">show</a>();
</code></pre>
<h2>
<a name="show_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="cordova_splashscreen_splashscreen.md.html#Splashscreen">Splashscreen</a> Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#show">show</a>();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
</code></pre>
<hr>
<h1><a name="hide">hide</a></h1>
<p>Dismiss the splash screen.</p>
<pre class="prettyprint"><code>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>();
</code></pre>
<h2>
<a name="hide_description">Description</a>
</h2>
<p>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>() dismisses the applications splash screen.</p>
<h2>
<a name="hide_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>iOS</li>
</ul>
<h2>
<a name="hide_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>();
</code></pre>
<h2>
<a name="hide_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="cordova_splashscreen_splashscreen.md.html#Splashscreen">Splashscreen</a> Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
</code></pre>
<h2>
<a name="hide_ios_quirk">iOS Quirk</a>
</h2>
<ol>
<li><p>In your Cordova.plist, you need to <a href="guide_project-settings_index.md.html#Project%20Settings">modify the value</a> for <strong>"AutoHideSplashScreen”</strong> to false</p></li>
<li>
<p>Then, if you want to delay hiding the splash screen for 2 seconds, you can do this in your <strong><a href="cordova_events_events.md.html#deviceready">deviceready</a></strong> event handler:</p>
<pre class="prettyprint"><code>setTimeout(function() {
navigator.splashscreen.<a href="cordova_splashscreen_splashscreen.md.html#hide">hide</a>();
}, 2000);
</code></pre>
</li>
</ol>
</div>
</div>
<!-- Functionality and Syntax Highlighting -->
<script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
</body>
</html>