Skip to content

Commit 2f8cc17

Browse files
committed
cherrypick from ics-mr1 docs: source for nw app Change-Id: If50f407a0e56fa802fe9beedaa650e3a131872b2
Change-Id: I55d8668f4065129c844ada239f268a6621df4780
1 parent 0d3a127 commit 2f8cc17

File tree

13 files changed

+750
-0
lines changed

13 files changed

+750
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
Copyright (C) 2012 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
package="com.example.android.networkusage"
19+
android:versionCode="1"
20+
android:versionName="1.0" >
21+
22+
<uses-sdk android:minSdkVersion="4"
23+
android:targetSdkVersion="14" />
24+
25+
<uses-permission android:name="android.permission.INTERNET" />
26+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
27+
28+
<application
29+
android:icon="@drawable/ic_launcher"
30+
android:label="@string/app_name" >
31+
32+
<activity
33+
android:name="com.example.networkusage.NetworkActivity"
34+
android:label="@string/app_name" >
35+
<intent-filter>
36+
<action android:name="android.intent.action.MAIN" />
37+
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:label="SettingsActivity" android:name=".SettingsActivity">
42+
<intent-filter>
43+
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
44+
<category android:name="android.intent.category.DEFAULT" />
45+
</intent-filter>
46+
</activity>
47+
</application>
48+
</manifest>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
README
2+
======
3+
4+
This Network Usage sample app does the following:
5+
6+
-- Downloads an XML feed from StackOverflow.com for the most recent posts tagged "android".
7+
8+
-- Parses the XML feed, combines feed elements with HTML markup, and displays the resulting HTML in the UI.
9+
10+
-- Lets users control their network data usage through a settings UI. Users can choose to fetch the feed
11+
when any network connection is available, or only when a Wi-Fi connection is available.
12+
13+
-- Detects when there is a change in the device's connection status and responds accordingly. For example, if
14+
the device loses its network connection, the app will not attempt to download the feed.
4.05 KB
Loading
1.68 KB
Loading
2.51 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
8+
android:id="@+id/webview"
9+
android:layout_width="fill_parent"
10+
android:layout_height="fill_parent"
11+
/>
12+
</LinearLayout>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
Copyright (C) 2012 The Android Open Source Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
20+
<item android:id="@+id/settings"
21+
android:title="@string/settings" />
22+
<item android:id="@+id/refresh"
23+
android:title="@string/refresh" />
24+
</menu>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
Copyright (C) 2012 The Android Open Source Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<resources>
20+
<string-array name="listArray">
21+
<item>Only when on Wi-Fi</item>
22+
<item>On any network</item>
23+
</string-array>
24+
<string-array name="listValues">
25+
<item>Wi-Fi</item>
26+
<item>Any</item>
27+
</string-array>
28+
</resources>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
Copyright (C) 2012 The Android Open Source Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<resources>
20+
21+
<string name="app_name">NetworkUsage</string>
22+
23+
<!-- Menu items -->
24+
<string name="settings">Settings</string>
25+
<string name="refresh">Refresh</string>
26+
27+
<!-- NetworkActivity -->
28+
<string name="page_title">Newest StackOverflow questions tagged \'android\'</string>
29+
<string name="updated">Last updated:</string>
30+
<string name="lost_connection">Lost connection.</string>
31+
<string name="wifi_connected">Wi-Fi reconnected.</string>
32+
<string name="connection_error">Unable to load content. Check your network connection.</string>
33+
<string name="xml_error">Error parsing XML.</string>
34+
35+
</resources>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
Copyright (C) 2012 The Android Open Source Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
20+
<ListPreference
21+
android:title="Download Feed"
22+
android:summary="Network connectivity required to download the feed."
23+
android:key="listPref"
24+
android:defaultValue="Wi-Fi"
25+
android:entries="@array/listArray"
26+
android:entryValues="@array/listValues"
27+
/>
28+
<CheckBoxPreference
29+
android:title="Show Summaries"
30+
android:defaultValue="false"
31+
android:summary="Show a summary for each link."
32+
android:key="summaryPref" />
33+
</PreferenceScreen>

0 commit comments

Comments
 (0)