Calculation service
This commit is contained in:
parent
00181745ea
commit
378bebfb8a
6
calculatorpp-service/AndroidManifest.xml
Normal file
6
calculatorpp-service/AndroidManifest.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest
|
||||||
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.solovyev.android.calculator"
|
||||||
|
a:versionCode="1"
|
||||||
|
a:versionName="1.0"/>
|
69
calculatorpp-service/pom.xml
Normal file
69
calculatorpp-service/pom.xml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.solovyev.android</groupId>
|
||||||
|
<artifactId>calculatorpp-parent</artifactId>
|
||||||
|
<version>1.2.34</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.solovyev.android</groupId>
|
||||||
|
<artifactId>calculatorpp-service</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>apklib</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.intellij</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>7.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.android</groupId>
|
||||||
|
<artifactId>android</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<extensions>
|
||||||
|
<extension>
|
||||||
|
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
|
||||||
|
<artifactId>android-maven-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
</extension>
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>properties-maven-plugin</artifactId>
|
||||||
|
<version>1.0-alpha-2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>read-project-properties</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<files>
|
||||||
|
<file>${basedir}/src/misc/env/env.properties</file>
|
||||||
|
</files>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,74 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.*;
|
||||||
|
import android.os.Process;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 3/5/12
|
||||||
|
* Time: 10:23 PM
|
||||||
|
*/
|
||||||
|
public class CalculationService extends Service {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private ServiceHandler handler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Toast.makeText(this, ".CalculationService.onStartCommand", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// For each start request, send a message to start a job and deliver the
|
||||||
|
// start ID so we know which request we're stopping when we finish the job
|
||||||
|
final Message msg = handler.obtainMessage();
|
||||||
|
msg.arg1 = startId;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
|
||||||
|
// If we get killed, after returning from here, restart
|
||||||
|
return START_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
Toast.makeText(this, ".CalculationService.onCreate", Toast.LENGTH_SHORT).show();
|
||||||
|
// first time initialization
|
||||||
|
|
||||||
|
// Start up the thread running the service. Note that we create a
|
||||||
|
// separate thread because the service normally runs in the process's
|
||||||
|
// main thread, which we don't want to block. We also make it
|
||||||
|
// background priority so CPU-intensive work will not disrupt our UI.
|
||||||
|
final HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
handler = new ServiceHandler(thread.getLooper());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
// last time call
|
||||||
|
Toast.makeText(this, ".CalculationService.onDestroy", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class ServiceHandler extends Handler {
|
||||||
|
|
||||||
|
private ServiceHandler(@NotNull Looper looper) {
|
||||||
|
super(looper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(@NotNull Message msg) {
|
||||||
|
Toast.makeText(CalculationService.this, "Doing job!", Toast.LENGTH_SHORT).show();
|
||||||
|
stopSelf(msg.arg1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
|
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
|
||||||
|
|
||||||
<application android:debuggable="false" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
<application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
||||||
|
|
||||||
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
||||||
|
|
||||||
@ -18,6 +18,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<service android:name="org.solovyev.android.calculator.CalculationService"/>
|
||||||
|
|
||||||
<!--NOTE: a:configChanges="orientation|keyboardHidden" is needed to correct work of dialog windows (not to close them on orientation change) -->
|
<!--NOTE: a:configChanges="orientation|keyboardHidden" is needed to correct work of dialog windows (not to close them on orientation change) -->
|
||||||
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
|
<activity android:configChanges="orientation|keyboardHidden" android:label="@string/c_app_settings" android:name=".CalculatorPreferencesActivity"/>
|
||||||
|
@ -56,6 +56,13 @@
|
|||||||
<type>apklib</type>
|
<type>apklib</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.solovyev.android</groupId>
|
||||||
|
<artifactId>calculatorpp-service</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<type>apklib</type>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.solovyev</groupId>
|
<groupId>org.solovyev</groupId>
|
||||||
<artifactId>jscl</artifactId>
|
<artifactId>jscl</artifactId>
|
||||||
|
@ -9,4 +9,5 @@
|
|||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-15
|
target=android-15
|
||||||
android.library.reference.1=gen-external-apklibs/org.solovyev.android_billing_0.1
|
android.library.reference.1=../../common
|
||||||
|
android.library.reference.2=../calculatorpp-service
|
||||||
|
9
pom.xml
9
pom.xml
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>../common</module>
|
<module>../common</module>
|
||||||
|
<module>calculatorpp-service</module>
|
||||||
<module>calculatorpp</module>
|
<module>calculatorpp</module>
|
||||||
<module>calculatorpp-test</module>
|
<module>calculatorpp-test</module>
|
||||||
</modules>
|
</modules>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.android</groupId>
|
<groupId>com.google.android</groupId>
|
||||||
<artifactId>android</artifactId>
|
<artifactId>android</artifactId>
|
||||||
<version>2.3.3</version>
|
<version>4.0.1.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -68,11 +69,11 @@
|
|||||||
<platform>15</platform>
|
<platform>15</platform>
|
||||||
</sdk>
|
</sdk>
|
||||||
|
|
||||||
<!-- <emulator>
|
<emulator>
|
||||||
<avd>23</avd>
|
<avd>23</avd>
|
||||||
<wait>10000</wait>
|
<wait>10000</wait>
|
||||||
<!–<options>-no-skin</options>–>
|
<!--<options>-no-skin</options>-->
|
||||||
</emulator>-->
|
</emulator>
|
||||||
|
|
||||||
<zipalign>
|
<zipalign>
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
|
Loading…
Reference in New Issue
Block a user