Permalink
Browse files

updates

  • Loading branch information...
1 parent 5229e18 commit 2c11598b93d26ecc7b2246ef04c09feba45a59d2 @vogella vogella committed Apr 24, 2012
Showing with 854 additions and 54 deletions.
  1. +8 −0 TutorialServiceSolution/.classpath
  2. +33 −0 TutorialServiceSolution/.project
  3. +32 −0 TutorialServiceSolution/AndroidManifest.xml
  4. +20 −0 TutorialServiceSolution/proguard-project.txt
  5. +14 −0 TutorialServiceSolution/project.properties
  6. BIN TutorialServiceSolution/res/drawable-hdpi/ic_launcher.png
  7. BIN TutorialServiceSolution/res/drawable-ldpi/ic_launcher.png
  8. BIN TutorialServiceSolution/res/drawable-mdpi/ic_launcher.png
  9. BIN TutorialServiceSolution/res/drawable-xhdpi/ic_launcher.png
  10. +22 −0 TutorialServiceSolution/res/layout/main.xml
  11. +7 −0 TutorialServiceSolution/res/values/strings.xml
  12. +96 −0 TutorialServiceSolution/src/de/vogella/android/intentservice/download/DownloadService.java
  13. +51 −0 TutorialServiceSolution/src/de/vogella/android/intentservice/download/MainActivity.java
  14. +8 −0 TutorialServiceTodo/.classpath
  15. +33 −0 TutorialServiceTodo/.project
  16. +26 −0 TutorialServiceTodo/AndroidManifest.xml
  17. +20 −0 TutorialServiceTodo/proguard-project.txt
  18. +14 −0 TutorialServiceTodo/project.properties
  19. BIN TutorialServiceTodo/res/drawable-hdpi/ic_launcher.png
  20. BIN TutorialServiceTodo/res/drawable-ldpi/ic_launcher.png
  21. BIN TutorialServiceTodo/res/drawable-mdpi/ic_launcher.png
  22. BIN TutorialServiceTodo/res/drawable-xhdpi/ic_launcher.png
  23. +22 −0 TutorialServiceTodo/res/layout/main.xml
  24. +7 −0 TutorialServiceTodo/res/values/strings.xml
  25. +99 −0 TutorialServiceTodo/src/de/vogella/android/intentservice/download/DownloadService.java
  26. +58 −0 TutorialServiceTodo/src/de/vogella/android/intentservice/download/MainActivity.java
  27. +1 −1 android.training.frankfurt/AndroidManifest.xml
  28. BIN android.training.frankfurt/res/drawable-hdpi/fire.png
  29. +6 −2 android.training.frankfurt/res/layout/main.xml
  30. +13 −0 android.training.frankfurt/res/menu/mymenu.xml
  31. +0 −1 android.training.frankfurt/res/values/styles.xml
  32. +17 −0 android.training.frankfurt/res/xml/mypref.xml
  33. +35 −0 android.training.frankfurt/src/android/training/frankfurt/MainActivity.java
  34. +3 −4 android.training.frankfurt/src/android/training/frankfurt/NextActivity.java
  35. +5 −6 com.example.android.rssfeed/AndroidManifest.xml
  36. +6 −0 com.example.android.rssfeed/res/menu/mymenu.xml
  37. +29 −14 ...example.android.rssfeed/src/com/example/android/rssfeed/{ReadRssFeed.java → RssFeedActivity.java}
  38. +2 −9 ...la.android.intentservice.download/src/de/vogella/android/intentservice/download/MainActivity.java
  39. +3 −0 ...id.intentservice.download/src/de/vogella/android/intentservice/download/WrongDownloadService.java
  40. +1 −1 de.vogella.android.listactivity/AndroidManifest.xml
  41. +2 −2 de.vogella.android.listactivity/res/layout/rowlayout.xml
  42. +9 −0 de.vogella.android.listactivity/res/menu/rowselection.xml
  43. +93 −0 de.vogella.android.listactivity/src/de/vogella/android/listactivity/MyListActivityActionbar.java
  44. +59 −14 de.vogella.android.socialapp/src/de/vogella/android/socialapp/OverviewActivity.java
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TutorialServiceSolution</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="de.vogella.android.intentservice.download"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk android:minSdkVersion="15" />
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <service android:name="DownloadService" >
+ </service>
+ <service android:name="WrongDownloadService"
+ android:process=":download"
+ >
+ </service>
+ </application>
+
+</manifest>
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=Google Inc.:Google APIs:15
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/startIntentService"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="onClick"
+ android:text="Start IntentService" />
+
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="showToast"
+ android:text="Show Toast" />
+
+</LinearLayout>
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, MainActivity!</string>
+ <string name="app_name">Test</string>
+
+</resources>
@@ -0,0 +1,96 @@
+package de.vogella.android.intentservice.download;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import android.app.Activity;
+import android.app.IntentService;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Message;
+import android.os.Messenger;
+import android.util.Log;
+
+public class DownloadService extends IntentService {
+
+ private int result = Activity.RESULT_CANCELED;
+
+ public DownloadService() {
+ super("DownloadService");
+ }
+
+ // Will be called asynchronously be Android
+ @Override
+ protected void onHandleIntent(Intent intent) {
+
+ try {
+ Thread.sleep(4000);
+ } catch (InterruptedException e2) {
+ e2.printStackTrace();
+ }
+ Uri data = intent.getData();
+ String urlPath = intent.getStringExtra("urlpath");
+ String fileName = data.getLastPathSegment();
+ File output = new File(Environment.getExternalStorageDirectory(),
+ fileName);
+ if (output.exists()) {
+ output.delete();
+ }
+
+ InputStream stream = null;
+ FileOutputStream fos = null;
+ try {
+
+ URL url = new URL(urlPath);
+ stream = url.openConnection().getInputStream();
+ InputStreamReader reader = new InputStreamReader(stream);
+ fos = new FileOutputStream(output.getPath());
+ int next = -1;
+ while ((next = reader.read()) != -1) {
+ fos.write(next);
+ }
+ // Sucessful finished
+ result = Activity.RESULT_OK;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (fos != null) {
+ try {
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Bundle extras = intent.getExtras();
+ if (extras != null) {
+ Messenger messenger = (Messenger) extras.get("MESSENGER");
+ Message msg = Message.obtain();
+ msg.arg1 = result;
+ Bundle bundle = new Bundle();
+ bundle.putString("absolutePath", output.getAbsolutePath());
+ msg.setData(bundle);
+ try {
+ messenger.send(msg);
+ } catch (android.os.RemoteException e1) {
+ Log.w(getClass().getName(), "Exception sending message", e1);
+ }
+
+ }
+ }
+}
@@ -0,0 +1,51 @@
+package de.vogella.android.intentservice.download;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Messenger;
+import android.view.View;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+ private Handler handler = new Handler() {
+ public void handleMessage(Message message) {
+ Bundle data = message.getData();
+ if (message.arg1 == RESULT_OK && data != null) {
+
+ String path = data.getString("absolutePath");
+ Toast.makeText(MainActivity.this, "Downloaded" + path,
+ Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(MainActivity.this, "Download failed.",
+ Toast.LENGTH_LONG).show();
+ }
+
+ };
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ }
+
+ public void onClick(View view) {
+ Intent intent = null;
+ intent = new Intent(this, DownloadService.class);
+ // Create a new Messenger for the communication back
+ Messenger messenger = new Messenger(handler);
+ intent.putExtra("MESSENGER", messenger);
+ intent.setData(Uri.parse("http://www.vogella.de/index.html"));
+ intent.putExtra("urlpath", "http://www.vogella.de/index.html");
+ startService(intent);
+ }
+
+ public void showToast(View view) {
+ Toast.makeText(this, "Still interactive", Toast.LENGTH_SHORT).show();
+ }
+}
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TutorialServiceTodo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="de.vogella.android.intentservice.download"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk android:minSdkVersion="15" />
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest>
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
Oops, something went wrong.

0 comments on commit 2c11598

Please sign in to comment.