Skip to content

Commit 947236c

Browse files
committed
Android JobScheduler example
1 parent 67b2e3a commit 947236c

File tree

20 files changed

+449
-0
lines changed

20 files changed

+449
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
8+
<classpathentry kind="output" path="bin/classes"/>
9+
</classpath>
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+
<projectDescription>
3+
<name>com.vogella.android.jobscheduler</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.vogella.android.jobscheduler"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="21"
9+
android:targetSdkVersion="21" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@drawable/ic_launcher"
14+
android:label="Test"
15+
android:theme="@style/AppTheme" >
16+
<activity
17+
android:name=".MainActivity"
18+
android:label="Test" >
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
26+
<service android:name="TestJobService" >
27+
</service>
28+
</application>
29+
30+
</manifest>
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-21
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
7+
<LinearLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent"
10+
android:layout_weight="1"
11+
android:orientation="vertical">
12+
<TextView
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:text="@string/constraints"
16+
android:layout_margin="15dp"
17+
android:textSize="18dp"/>
18+
<LinearLayout
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:orientation="vertical"
22+
android:layout_marginLeft="10dp">
23+
<LinearLayout
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content">
26+
<TextView
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:text="@string/connectivity"
30+
android:layout_marginRight="10dp"/>
31+
<RadioGroup
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:orientation="horizontal">
35+
<RadioButton android:id="@+id/checkbox_any"
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:text="@string/any"/>
39+
<RadioButton android:id="@+id/checkbox_unmetered"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:text="@string/unmetered"/>
43+
</RadioGroup>
44+
45+
</LinearLayout>
46+
<LinearLayout
47+
android:layout_width="match_parent"
48+
android:layout_height="wrap_content">
49+
<TextView
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:text="@string/timing"/>
53+
<TextView
54+
android:layout_width="wrap_content"
55+
android:layout_height="wrap_content"
56+
android:layout_marginLeft="15dp"
57+
android:textSize="17dp"
58+
android:text="@string/delay"/>
59+
<EditText
60+
android:id="@+id/delay_time"
61+
android:layout_width="60dp"
62+
android:layout_height="wrap_content"
63+
android:inputType="number"/>
64+
<TextView
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content"
67+
android:text="Deadline:"
68+
android:textSize="17dp"/>
69+
<EditText
70+
android:id="@+id/deadline_time"
71+
android:layout_width="60dp"
72+
android:layout_height="wrap_content"
73+
android:inputType="number"/>
74+
</LinearLayout>
75+
<LinearLayout
76+
android:layout_width="match_parent"
77+
android:layout_height="wrap_content">
78+
<TextView
79+
android:layout_width="wrap_content"
80+
android:layout_height="wrap_content"
81+
android:text="@string/charging_caption"
82+
android:layout_marginRight="15dp"/>
83+
<CheckBox
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:id="@+id/checkbox_charging"
87+
android:text="@string/charging_text"/>
88+
</LinearLayout>
89+
<LinearLayout
90+
android:layout_width="match_parent"
91+
android:layout_height="wrap_content">
92+
<TextView
93+
android:layout_width="wrap_content"
94+
android:layout_height="wrap_content"
95+
android:text="@string/idle_caption"
96+
android:layout_marginRight="15dp"/>
97+
<CheckBox
98+
android:layout_width="wrap_content"
99+
android:layout_height="wrap_content"
100+
android:id="@+id/checkbox_idle"
101+
android:text="Requires device in idle mode."/>
102+
</LinearLayout>
103+
104+
</LinearLayout>
105+
<Button
106+
android:id="@+id/schedule_button"
107+
android:layout_width="match_parent"
108+
android:layout_height="wrap_content"
109+
android:layout_marginTop="20dp"
110+
android:layout_marginLeft="40dp"
111+
android:layout_marginRight="40dp"
112+
android:onClick="scheduleJob"
113+
android:text="Schedule Job"/>
114+
<Button
115+
android:id="@+id/cancel_button"
116+
android:layout_width="match_parent"
117+
android:layout_height="wrap_content"
118+
android:layout_marginLeft="40dp"
119+
android:layout_marginRight="40dp"
120+
android:onClick="cancelAllJobs"
121+
android:text="Cancel all"/>
122+
</LinearLayout>
123+
</ScrollView>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme for API 11+. This theme completely replaces
5+
AppBaseTheme from res/values/styles.xml on API 11+ devices.
6+
-->
7+
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
8+
<!-- API 11 theme customizations can go here. -->
9+
</style>
10+
11+
</resources>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme for API 14+. This theme completely replaces
5+
AppBaseTheme from BOTH res/values/styles.xml and
6+
res/values-v11/styles.xml on API 14+ devices.
7+
-->
8+
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
9+
<!-- API 14 theme customizations can go here. -->
10+
</style>
11+
12+
</resources>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<resources>
2+
3+
<!--
4+
Example customization of dimensions originally defined in res/values/dimens.xml
5+
(such as screen margins) for screens with more than 820dp of available width. This
6+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
7+
-->
8+
<dimen name="activity_horizontal_margin">64dp</dimen>
9+
10+
</resources>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="none_received">#999999</color>
4+
<color name="start_received">#00FF00</color>
5+
<color name="stop_received">#FF0000</color>
6+
</resources>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<resources>
2+
3+
<!-- Default screen margins, per the Android Design guidelines. -->
4+
<dimen name="activity_horizontal_margin">16dp</dimen>
5+
<dimen name="activity_vertical_margin">16dp</dimen>
6+
7+
</resources>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="finish_job_button_text">taskFinished</string>
5+
<string name="charging_caption">Charging:</string>
6+
<string name="charging_text">Requires device plugged in.</string>
7+
<string name="idle_caption">Idle:</string>
8+
<string name="constraints">Constraints</string>
9+
<string name="connectivity">Connectivity:</string>
10+
<string name="any">Any</string>
11+
<string name="unmetered">WiFi</string>
12+
<string name="timing">Timing:</string>
13+
<string name="delay">Delay:</string>
14+
15+
16+
17+
</resources>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme, dependent on API level. This theme is replaced
5+
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6+
-->
7+
<style name="AppBaseTheme" parent="android:Theme.Light">
8+
<!--
9+
Theme customizations available in newer API levels can go in
10+
res/values-vXX/styles.xml, while customizations related to
11+
backward-compatibility can go here.
12+
-->
13+
</style>
14+
15+
<!-- Application theme. -->
16+
<style name="AppTheme" parent="AppBaseTheme">
17+
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
18+
</style>
19+
20+
</resources>

0 commit comments

Comments
 (0)