Skip to content

Commit 888db7a

Browse files
committed
more android examples
1 parent 733a1c5 commit 888db7a

11 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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 kind="output" path="bin"/>
7+
</classpath>

de.vogella.android.alarm/.project

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>de.vogella.android.alarm</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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="de.vogella.android.alarm" android:versionCode="1"
4+
android:versionName="1.0">
5+
<application android:icon="@drawable/icon" android:label="@string/app_name">
6+
<activity android:name=".AlarmActivity" android:label="@string/app_name">
7+
<intent-filter>
8+
<action android:name="android.intent.action.MAIN" />
9+
<category android:name="android.intent.category.LAUNCHER" />
10+
</intent-filter>
11+
</activity>
12+
<receiver android:name=".MyBroadcastReceiver" android:enabled="true">
13+
</receiver>
14+
</application>
15+
<uses-sdk android:minSdkVersion="8" />
16+
17+
18+
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
19+
</manifest>
20+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 use,
7+
# "build.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-8
4.05 KB
Loading
1.68 KB
Loading
2.51 KB
Loading
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+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="fill_parent"
4+
android:layout_height="fill_parent">
5+
6+
7+
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/time" android:hint="Number of seconds" android:inputType="numberDecimal"></EditText><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ok" android:onClick="startAlert" android:text="Start Counter"></Button>
8+
9+
</LinearLayout>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="hello">Hello World, AlarmActivity!</string>
4+
<string name="app_name">Alarm</string>
5+
</resources>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package de.vogella.android.alarm;
2+
3+
import android.app.Activity;
4+
import android.app.AlarmManager;
5+
import android.app.PendingIntent;
6+
import android.content.Intent;
7+
import android.os.Bundle;
8+
import android.view.View;
9+
import android.widget.EditText;
10+
import android.widget.Toast;
11+
12+
public class AlarmActivity extends Activity {
13+
/** Called when the activity is first created. */
14+
@Override
15+
public void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
setContentView(R.layout.main);
18+
}
19+
20+
public void startAlert(View view) {
21+
EditText text = (EditText) findViewById(R.id.time);
22+
int i = Integer.parseInt(text.getText().toString());
23+
Intent intent = new Intent(this, MyBroadcastReceiver.class);
24+
PendingIntent pendingIntent = PendingIntent.getBroadcast(
25+
this.getApplicationContext(), 234324243, intent, 0);
26+
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
27+
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
28+
+ (i * 1000), pendingIntent);
29+
Toast.makeText(this, "Alarm set in " + i + " seconds",
30+
Toast.LENGTH_LONG).show();
31+
}
32+
33+
}

0 commit comments

Comments
 (0)