Commit 11d88962 authored by Philipp Auersperg's avatar Philipp Auersperg

...

parent 2fa316c0
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
......
......@@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.example.androidrpcclient">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
......
package com.example.androidrpcclient
import android.app.Notification
import android.Manifest
import android.app.*
import android.content.ComponentName
import android.content.Intent
import android.support.v7.app.AppCompatActivity
......@@ -9,21 +10,23 @@ import android.provider.Contacts
import kotlinx.android.synthetic.main.activity_main.*
import java.lang.Exception
import kotlinx.coroutines.*
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.content.pm.PackageManager
import android.graphics.Color
import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import android.util.Log
import java.lang.reflect.InvocationTargetException
class MainActivity : AppCompatActivity() {
val TAG="KivyService"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -144,6 +147,52 @@ class MainActivity : AppCompatActivity() {
}
fun onAcquirePermissions(view: View){
println("onAcquirePermissions")
txtStatus.text="onAcquirePermissions"
val file=File("/sdcard")
setupPermissions()
val lsf=file.listFiles()
if (lsf != null) {
val ls = lsf.joinToString(",")
txtMessage.text = ls
} else {
txtMessage.text = "null"
}
}
private fun setupPermissions() {
val permission = ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE)
if (permission != PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "Permission to record denied")
makeRequest()
}
}
private fun makeRequest() {
val permissions = arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE)
ActivityCompat.requestPermissions(this, permissions,0)
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 225);
// ActivityCompat.requestPermissions(this,
// arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),0)
}
// override fun onRequestPermissionsResult(requestCode: Int,
// permissions: Array<String>, grantResults: IntArray) {
// when (requestCode) {
// RECORD_REQUEST_CODE -> {
//
// if (grantResults.isEmpty() || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
//
// Log.i(TAG, "Permission has been denied by user")
// } else {
// Log.i(TAG, "Permission has been granted by user")
// }
// }
// }
// }
}
......@@ -19,6 +19,8 @@ from jnius import autoclass
print("before loading service class")
service = autoclass('org.bd.pureservice.ServiceSchas')
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
print('trying permissions')
mActivity.requestPermissions(['READ_EXTERNAL_STORAGE','WRITE_EXTERNAL_STORAGE'])
argument = 'test argument ok'
print('------before start')
service.start(mActivity, argument)
......
......@@ -35,7 +35,9 @@ def version(self, **kw):
@delegate.api
def dir(self, **kw):
import os
return os.listdir('/sdcard')
res = os.listdir('/sdcard')
print ('dir:', res)
return str(res)
def runit():
host = '0.0.0.0'
......
......@@ -85,7 +85,7 @@ fullscreen = 0
#android.presplash_color = #FFFFFF
# (list) Permissions
android.permissions = INTERNET
android.permissions = INTERNET, READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
# (int) Android API to use
#android.api = 19
......
......@@ -19,6 +19,8 @@ from jnius import autoclass
print("before loading service class")
service = autoclass('org.bd.pureservice.ServiceSchas')
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
print('trying permissions')
mActivity.requestPermissions(['READ_EXTERNAL_STORAGE','WRITE_EXTERNAL_STORAGE'])
argument = 'test argument ok'
print('------before start')
service.start(mActivity, argument)
......
......@@ -35,7 +35,9 @@ def version(self, **kw):
@delegate.api
def dir(self, **kw):
import os
return os.listdir('/sdcard')
res = os.listdir('/sdcard')
print ('dir:', res)
return str(res)
def runit():
host = '0.0.0.0'
......
......@@ -11,7 +11,7 @@ options = {'apk': {'debug': None,
'ndk-dir':'/opt/android/android-ndk-r17c/',
'dist-name': 'pureservice',
'bootstrap': 'service_only',
'permissions': ['INTERNET', 'VIBRATE'],
'permissions': ['INTERNET', 'VIBRATE','READ_EXTERNAL_STORAGE','WRITE_EXTERNAL_STORAGE'],
'arch': 'armeabi-v7a',
# 'service': 'schas:servp3.py:sticky',
'service': 'schas:servp3.py',
......
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