Commit fe0cea96 authored by Philipp Auersperg's avatar Philipp Auersperg

service works under android 7

parent 1d0a586e
package com.example.androidrpcclient
import android.app.Notification
import android.content.ComponentName
import android.content.Intent
import android.support.v7.app.AppCompatActivity
......@@ -12,6 +13,15 @@ import android.app.Service
import android.net.Uri
import android.view.View
import java.io.File
import android.content.Context.NOTIFICATION_SERVICE
import android.app.NotificationManager
import android.app.NotificationChannel
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.support.annotation.RequiresApi
import android.util.Log
class MainActivity : AppCompatActivity() {
......@@ -51,10 +61,12 @@ class MainActivity : AppCompatActivity() {
fun onStartServer(view: android.view.View){
println("start server clicked")
var intent = packageManager.getLaunchIntentForPackage("org.bd.servicetest")
// var intent = packageManager.getLaunchIntentForPackage("org.bd.servicetest")
var intent = packageManager.getLaunchIntentForPackage("org.bd.pureservice")
// startActivity(intent)
val res = startActivity(intent)
println("res: $res")
Log.i("%%%%%%%%%%%","res: $res")
// ComponentName("org.bd.servicetest", "org.bd.servicetest.ServiceTestserv")
......@@ -62,7 +74,25 @@ class MainActivity : AppCompatActivity() {
}
fun onStartService(view: View){
// val intent = packageManager.
val cn = ComponentName("org.bd.pureservice", "org.bd.pureservice.ServiceSchas")
val intent = Intent();
// intent.setAction("org.bd.pureservice.ServiceSchas");
intent.setComponent(cn)
intent.putExtra("androidPrivate", "/data/user/0/org.bd.pureservice/files/app")
intent.putExtra("androidArgument", "/data/user/0/org.bd.pureservice/files/app")
intent.putExtra("serviceEntrypoint","servp3.py")
intent.putExtra("pythonName","schas")
intent.putExtra("pythonHome","/data/user/0/org.bd.pureservice/files/app")
intent.putExtra("pythonPath", "/data/user/0/org.bd.pureservice/files/app:/data/user/0/org.bd.pureservice/files/app/lib")
intent.putExtra("pythonServiceArgument", "test argument ok")
try{
val res=startService(intent)
} catch (e: Exception) {
txtStatus.text = "Exception"
txtMessage.text = e.toString()
}
}
fun onInstallApk(view: View){
......@@ -77,4 +107,5 @@ class MainActivity : AppCompatActivity() {
txtMessage.text=e.message
}
}
}
......@@ -40,7 +40,7 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/textView" android:background="#ffffff"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/linearLayout"/>
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/btnConnect"/>
<TextView
android:text="command"
android:layout_width="wrap_content"
......@@ -86,6 +86,16 @@
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginBottom="56dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.498"/>
<Button
android:text="connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnConnect" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.498"
android:background="@color/colorPrimary" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="299dp"
......@@ -100,19 +110,15 @@
android:layout_height="wrap_content" tools:layout_editor_absoluteY="198dp"
tools:layout_editor_absoluteX="1dp" android:id="@+id/button" android:onClick="onInstallApk"/>
<Button
android:text="start service"
android:text="service"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/btnStartServer" android:layout_weight="1"
android:onClick="onStartServer"/>
android:layout_height="wrap_content" android:id="@+id/startService" android:layout_weight="1"
android:onClick="onStartService"/>
<Button
android:text="connect"
android:text="activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnConnect" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.348"
android:background="@color/colorPrimary" tools:layout_editor_absoluteY="255dp"/>
android:layout_height="wrap_content" android:id="@+id/btnStartServer" android:layout_weight="1"
android:onClick="onStartServer"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -5,13 +5,13 @@ import sys
print('python version is: ', sys.version)
print('python sys.path is: ', sys.path)
from math import sqrt
print('import math worked')
# from math import sqrt
# print('import math worked')
for i in range(45, 50):
print(i, sqrt(i))
# for i in range(45, 50):
# print(i, sqrt(i))
print('Just printing stuff apparently worked, trying a simple service')
# print('Just printing stuff apparently worked, trying a simple service')
from jnius import autoclass
# service = autoclass('org.test.testapp_service.ServiceTime')
......@@ -20,9 +20,6 @@ service = autoclass('org.bd.pureservice.ServiceSchas')
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
argument = 'test argument ok'
print('before start')
try:
service.start(mActivity, argument)
except Exception as e:
print("main: shit:",str(e))
service.start(mActivity, argument)
print('after start')
time.sleep(100)
# time.sleep(100)
......@@ -36,7 +36,7 @@ version = 0.1
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = python3, kivy
requirements = python3
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
......@@ -55,7 +55,7 @@ requirements = python3, kivy
orientation = portrait
# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
services = schas:servp3.py #,NAME2:ENTRYPOINT2_TO_PY
#
# OSX Specific
......@@ -206,6 +206,7 @@ p4a.source_dir = /home/phil/p4a
# (str) Bootstrap to use for android builds
#p4a.bootstrap = sdl2
p4a.bootstrap = service_only
# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
#p4a.port =
......
......@@ -5,13 +5,13 @@ import sys
print('python version is: ', sys.version)
print('python sys.path is: ', sys.path)
from math import sqrt
print('import math worked')
# from math import sqrt
# print('import math worked')
for i in range(45, 50):
print(i, sqrt(i))
# for i in range(45, 50):
# print(i, sqrt(i))
print('Just printing stuff apparently worked, trying a simple service')
# print('Just printing stuff apparently worked, trying a simple service')
from jnius import autoclass
# service = autoclass('org.test.testapp_service.ServiceTime')
......@@ -20,9 +20,6 @@ service = autoclass('org.bd.pureservice.ServiceSchas')
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
argument = 'test argument ok'
print('before start')
try:
service.start(mActivity, argument)
except Exception as e:
print("main: shit:",str(e))
service.start(mActivity, argument)
print('after start')
time.sleep(100)
# time.sleep(100)
......@@ -9,12 +9,15 @@ options = {'apk': {'debug': None,
'ndk-api': 21,
'sdk-dir':'/opt/android/android-sdk/',
'ndk-dir':'/opt/android/android-ndk-r17c/',
'dist-name': 'testapp_service',
'dist-name': 'pureservice',
'bootstrap': 'service_only',
'permissions': ['INTERNET', 'VIBRATE'],
'arch': 'armeabi-v7a',
'service': 'schas:servp3.py:sticky',
# 'service': 'time:p4atime.py',
'blacklist':'',
'whitelist':'whitelist.txt',
# 'include_ext':'*.schas',
# 'service': 'time:p4atime.py',
'package':'org.bd.pureservice',
}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment