kivy / pyjnius

Access Java classes from Python
https://pyjnius.readthedocs.org
MIT License
1.4k stars 255 forks source link

Accessing Android's clipboard #55

Closed crust3 closed 11 years ago

crust3 commented 11 years ago

I'm trying to access Android's clipboard using jnius, but I'm running into some issues. So far I've tried the following:

if platform() == 'android':
    from jnius import autoclass
    Context = autoclass('org.renpy.android.PythonActivity')
    ClipboardManager = autoclass('android.content.ClipboardManager')
    ClipData = autoclass('android.content.ClipData')
    ClipDescription = autoclass('android.content.ClipDescription')
    ClipItem = autoclass('android.content.ClipData.Item') #it throws an error saying that the class was not found
    context = Context.mActivity
    vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) #vibrator implementation works very well, thans tshirtman!
    android_clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE)

I then tried putting data to the clipboard using an example provided here (http://developer.android.com/guide/topics/text/copy-paste.html):

clip = ClipData.newPlainText("simple text","Hello, World!") #it throws an error saying that it was expecting java/lang/charsequence' but got 'simple text'
android_clipboard.setPrimaryClip(clip)

Is it actually possible to access the aforementioned classes through pyjnius. If yes, what am I doing wrong in the implementation. Thanks for any help.

tito commented 11 years ago

I guess it's the same as some others issues, the detection of a "subclass" or "implements" is not done. So you have to cast it (String implement CharSequence):

String = autoclass('java.lang.String')
clip = ClipData.newPlainText(
    cast('java.lang.CharSequence', String('simple text')),
    cast('java.lang.CharSequence', String('Hello, World!')))
crust3 commented 11 years ago

Thanks for the reply. I've used cast but when I try to put it onto clipboard it throws an error 'JVM exception occured'. Any ideas?

tito commented 11 years ago

What the log said on the device?

crust3 commented 11 years ago

Hi, here's the log:

[INFO ] Logger: Record log in /storage/sdcard0/org.test.ExpressN16/.kivy/logs/kivy_13-03-02_0.txt [WARNING] [Config ] Upgrading configuration in progress. [WARNING] [Config ] Older configuration version detected (0 instead of 7) [ERROR ] Error when copying logo directory [INFO ] Kivy v1.5.2-dev [INFO ] Factory: 137 symbols loaded [DEBUG ] Cache: register with limit=None, timeout=Nones [DEBUG ] Cache: register with limit=None, timeout=60s [DEBUG ] Cache: register with limit=None, timeout=Nones [WARNING ] stderr: /data/data/org.test.ExpressN16/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:11: RuntimeWarning: import cdrom: No module named cdrom [WARNING ] stderr: (ImportError: No module named cdrom) [INFO ] Image: Providers: img_dds, img_pygame, img_gif (img_pil ignored) [DEBUG ] Cache: register with limit=1000, timeout=60s [DEBUG ] Cache: register with limit=1000, timeout=3600s [INFO ] Text: Provider: pygame [DEBUG ] Cache: register with limit=500, timeout=60s [INFO ] Loader: using as thread loader [DEBUG ] Cache: register with limit=None, timeout=60.0s [DEBUG ] Cache: register with limit=None, timeout=60.0s [DEBUG ] App: Loading configuration </sdcard/.calc.ini> [DEBUG ] App: Loading kv <./calc.kv> [INFO ] Window: Provider: pygame [DEBUG ] WinPygame: Set window to fullscreen mode [DEBUG ] Window: Display driver android [DEBUG ] Window: Actual window size: %dx%d [INFO ] GL: OpenGL version <OpenGL ES 2.0> [INFO ] GL: OpenGL vendor [INFO ] GL: OpenGL renderer [INFO ] GL: OpenGL parsed version: 2, 0 [INFO ] GL: Shading version <OpenGL ES GLSL ES 1.00> [INFO ] GL: Texture max size <4096> [INFO ] GL: Texture max units <8> [INFO ] Shader: fragment compiled successfully [INFO ] Shader: vertex compiled successfully [DEBUG ] ImagePygame: Load </data/data/org.test.ExpressN16/files/lib/python2.7/site-packages/kivy/data/glsl/default.png> [INFO ] Support: Android install hooks [INFO ] Window: virtual keyboard not allowed, single mode, not docked [DEBUG ] Atlas: Load </data/data/org.test.ExpressN16/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme.atlas> [DEBUG ] Atlas: Need to load 1 images [DEBUG ] Atlas: Load </data/data/org.test.ExpressN16/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png> [DEBUG ] ImagePygame: Load </data/data/org.test.ExpressN16/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png> [INFO ] OSC: using for socket [DEBUG ] Base: Create provider from android [INFO ] Base: Start application main loop [INFO ] Android: found 17 joystick [INFO ] Android: create joystick <0> [INFO ] Android: discard joystick <0> cause no button [INFO ] Android: create joystick <1> [INFO ] Android: create joystick <2> [INFO ] Android: create joystick <3> [INFO ] Android: create joystick <4> [INFO ] Android: create joystick <5> [INFO ] Android: create joystick <6> [INFO ] Android: create joystick <7> [INFO ] Android: create joystick <8> [INFO ] Android: create joystick <9> [INFO ] Android: create joystick <10> [INFO ] Android: create joystick <11> [INFO ] Android: create joystick <12> [INFO ] Android: create joystick <13> [INFO ] Android: create joystick <14> [INFO ] Android: create joystick <15> [INFO ] Android: create joystick <16> [INFO ] GL: NPOT texture support is available [INFO ] Base: Leaving application in progress... [WARNING ] stderr: Traceback (most recent call last): [WARNING ] stderr: File "/home/kivy/calc/main.py", line 2160, in [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 546, in run [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 445, in runTouchApp [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 324, in mainloop [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 230, in _mainloop [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 296, in idle [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 283, in dispatch_input [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 208, in post_dispatch_input [WARNING ] stderr: File "_event.pyx", line 224, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2992) [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/init.py", line 638, in on_motion [WARNING ] stderr: File "_event.pyx", line 224, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2992) [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/init.py", line 650, in on_touch_down [WARNING ] stderr: File "_event.pyx", line 224, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2992) [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/widget.py", line 225, in on_touch_down [WARNING ] stderr: File "_event.pyx", line 224, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2992) [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/widget.py", line 225, in on_touch_down [WARNING ] stderr: File "_event.pyx", line 224, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2992) [WARNING ] stderr: File "/home/kivy/android/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/button.py", line 127, in on_touch_down [WARNING ] stderr: File "_event.pyx", line 220, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:2941) [WARNING ] stderr: File "./calc.kv", line 1, in [WARNING ] stderr: : [WARNING ] stderr: File "/home/kivy/calc/main.py", line 1064, in do_actionBuMR [WARNING ] stderr: File "/home/kivy/calc/main.py", line 1081, in copy_expression [WARNING ] stderr: File "jnius_export_class.pxi", line 509, in jnius.jnius.JavaMethod.call (jnius/jnius.c:12613) [WARNING ] stderr: File "jnius_export_class.pxi", line 577, in jnius.jnius.JavaMethod.call_method (jnius/jnius.c:13168) [WARNING ] stderr: File "jnius_conversion.pxi", line 87, in jnius.jnius.convert_jobject_to_python (jnius/jnius.c:4392) [WARNING ] stderr: File "jnius_utils.pxi", line 82, in jnius.jnius.lookup_java_object_name (jnius/jnius.c:2316) [WARNING ] stderr: File "jnius_export_class.pxi", line 509, in jnius.jnius.JavaMethod.call (jnius/jnius.c:12613) [WARNING ] stderr: File "jnius_export_class.pxi", line 590, in jnius.jnius.JavaMethod.call_method (jnius/jnius.c:13283) [WARNING ] stderr: File "jnius_utils.pxi", line 40, in jnius.jnius.check_exception (jnius/jnius.c:1844) [WARNING ] stderr: jnius.jnius.JavaException: JVM exception occured

crust3 commented 11 years ago

Just for clarity, the line in my code referred by [WARNING ] stderr: File "/home/kivy/calc/main.py", line 1081, in copy_expression is the following

line 1081 = android_clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE)

tito commented 11 years ago

Is the log you sent is the Android log ? It seem to be the Kivy log only. Use "adb logcat", then paste the output from the app start to the exception. The non-kivy message (ie, the message from the Android system) are important.

crust3 commented 11 years ago

Hi, that was indeed the kivy log only. Here's the log from adb logcat `--------- beginning of /dev/log/system

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

V/AlarmManager( 2033): waitForAlarm result :8

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

--------- beginning of /dev/log/main

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8064 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/power ( 2033): *\ acquire_dvfs_lock : lockType : 1 freq : 1000000

D/PowerManagerService( 2033): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 2033 tag : ActivityManager

W/ActivityManager( 2033): mDVFSLock.acquire()

W/System.err( 2033): java.lang.reflect.InvocationTargetException

W/System.err( 2033): at java.lang.reflect.Method.invokeNative(Native Method)

W/System.err( 2033): at java.lang.reflect.Method.invoke(Method.java:511)

W/System.err( 2033): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3316)

W/System.err( 2033): at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1760)

W/System.err( 2033): at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:2862)

W/System.err( 2033): at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:8424)

W/System.err( 2033): at android.os.Handler.dispatchMessage(Handler.java:99)

W/System.err( 2033): at android.os.Looper.loop(Looper.java:137)

W/System.err( 2033): at com.android.server.wm.WindowManagerService$WMThread.run(WindowManagerService.java:924)

W/System.err( 2033): Caused by: java.lang.ClassCastException: android.app.ContextImpl cannot be cast to android.content.ContextWrapper

W/System.err( 2033): at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.(MultiPhoneWindowEvent.java:335)

W/System.err( 2033): at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:235)

W/System.err( 2033): ... 9 more

D/dalvikvm(26111): Late-enabling CheckJNI

I/SurfaceFlinger( 1726): id=2122(421) createSurf 0x40fdccfc (1x1),2 flag=400, FxpressN16

D/KeyguardViewMediator( 2033): setHidden false

I/dalvikvm(26111): Turning on JNI app bug workarounds for target SDK version 8...

V/WindowManager( 2033): rotationForOrientationLw(orient=1, last=0); user=0 USER_ROTATION_LOCKED mLidState=-1 mCoverState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false sensorRotation=-1

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw

D/KeyguardViewMediator( 2033): setHidden false

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/PointerIcon( 2033): setHoveringSpenIconStyle1 pointerType: 10001iconType:1

D/PointerIcon( 2033): setHoveringSpenCustomIcon IconType is same.1

D/KeyguardViewMediator( 2033): setHidden false

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/PowerManagerService( 2033): acquireWakeLock flags=0xa tag=Screen On uid=10136 pid=26111

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsdl.so 0x429dc580

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsdl.so 0x429dc580

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsdl_image.so 0x429dc580

D/WindowManager( 2033): mInputFocus is not null.

I/SurfaceFlinger( 1726): id=2123(1) createSurf 0x40fd67dc (1x1),1 flag=0, QythonActiv

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw: Call setFocusedWindow()

D/SPenGesture( 2033): SpenGestureView: setFocusedWindow

D/KeyguardViewMediator( 2033): setHidden false

D/STATUSBAR-StatusBarManagerService( 2033): setSystemUiVisibility(0x0)

D/STATUSBAR-StatusBarManagerService( 2033): manageDisableList what=0x0 pkg=WindowManager.LayoutParams

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsdl_image.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libsdl_image.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsdl_ttf.so 0x429dc580

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsdl_ttf.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libsdl_ttf.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsdl_mixer.so 0x429dc580

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsdl_mixer.so 0x429dc580

W/AlarmManager( 2033): FACTORY_ON= 0

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libsdl_mixer.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libpython2.7.so 0x429dc580

D/PointerIcon( 2033): setHoveringSpenIconStyle1 pointerType: 10001iconType:1

V/PhoneStatusBar( 2280): setLightsOn(true)

D/PointerIcon( 2033): setHoveringSpenCustomIcon IconType is same.1

I/SurfaceFlinger( 1726): id=2124(2) createSurf 0x4104cda4 (800x1280),4 flag=400, TurfaceView

D/KeyguardViewMediator( 2033): setHidden false

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libpython2.7.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libpython2.7.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libapplication.so 0x429dc580

I/SDLSurface(26111): surfaceCreated() is not handled :|

W/AlarmManager( 2033): FACTORY_ON= 0

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libapplication.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libapplication.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsdl_main.so 0x429dc580

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsdl_main.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libsdl_main.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/_io.so 0x429dc580

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/_io.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/_io.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/unicodedata.so 0x429dc580

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/unicodedata.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/unicodedata.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/lib/libsqlite3.so 0x429dc580

D/KeyguardViewMediator( 2033): setHidden false

D/dalvikvm(26111): Added shared lib /data/data/org.test.ExpressN16/lib/libsqlite3.so 0x429dc580

D/dalvikvm(26111): No JNI_OnLoad found in /data/data/org.test.ExpressN16/lib/libsqlite3.so 0x429dc580, skipping init

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/_sqlite3.so 0x429dc580

D/dalvikvm(26111): Trying to load lib /data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload/_imaging.so 0x429dc580

I/python (26111): starting audio thread

D/libEGL (26111): loaded /system/lib/egl/libEGL_mali.so

D/libEGL (26111): loaded /system/lib/egl/libGLESv1_CM_mali.so

W/AlarmManager( 2033): FACTORY_ON= 0

D/libEGL (26111): loaded /system/lib/egl/libGLESv2_mali.so

D/ (26111): Device driver API match

D/ (26111): Device driver API version: 10

D/ (26111): User space API version: 10

D/ (26111): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Thu Oct 25 08:43:05 KST 2012

D/KeyguardViewMediator( 2033): setHidden false

W/SDLSurface(26111): Choose egl configuration

I/SDLSurface(26111): Try to use graphics config R8G8B8A8S8

W/SDLSurface(26111): Create egl context

W/SDLSurface(26111): Create egl surface

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

I/libSDL (26111): Physical screen resolution is 800x1280

W/SDLSurface(26111): Done

D/dalvikvm(26111): GC_FOR_ALLOC freed 84K, 6% free 12201K/12931K, paused 14ms, total 14ms

I/dalvikvm-heap(26111): Grow heap (frag case) to 12.962MB for 524304-byte allocation

D/dalvikvm(26111): GC_CONCURRENT freed 1K, 6% free 12712K/13511K, paused 12ms+1ms, total 36ms

D/dalvikvm(26111): WAIT_FOR_CONCURRENT_GC blocked 18ms

D/dalvikvm(26111): WAIT_FOR_CONCURRENT_GC blocked 16ms

I/power ( 2033): *\ release_dvfs_lock : lockType : 1

D/KeyguardViewMediator( 2033): setHidden false

D/PowerManagerService( 2033): releaseDVFSLockLocked : all DVFS_MIN_LIMIT are released

W/ActivityManager( 2033): mDVFSLock.release()

I/SurfaceFlinger( 1726): id=2121 Removed Mauncher idx=2 MapSz=6

I/SurfaceFlinger( 1726): id=2121 Removed Mauncher idx=-2 MapSz=6

D/dalvikvm(26111): GC_FOR_ALLOC freed <1K, 6% free 12712K/13511K, paused 17ms, total 17ms

I/dalvikvm-heap(26111): Grow heap (frag case) to 13.460MB for 524304-byte allocation

D/dalvikvm(26111): GC_FOR_ALLOC freed 0K, 7% free 13224K/14087K, paused 13ms, total 13ms

W/InputMethodManager(26111): Ignoring onBind: cur seq=1365, given seq=1364

I/libSDL (26111): Physical screen resolution is 800x1280

I/python (26111): Initialize Python for Android

D/dalvikvm(26111): GC_CONCURRENT freed 2K, 7% free 13227K/14087K, paused 1ms+2ms, total 28ms

D/KeyguardViewMediator( 2033): setHidden false

I/SurfaceFlinger( 1726): id=2122 Removed FxpressN16 idx=5 MapSz=5

I/SurfaceFlinger( 1726): id=2122 Removed FxpressN16 idx=-2 MapSz=5

D/KeyguardViewMediator( 2033): setHidden false

I/python (26111): ['/data/data/org.test.ExpressN16/files/lib/python2.7/site-packages', '/data/data/org.test.ExpressN16/files/lib/site-python']

I/python (26111): Android path ['/data/data/org.test.ExpressN16/files/lib/python27.zip', '/data/data/org.test.ExpressN16/files/lib/python2.7', '/data/data/org.test.ExpressN16/files/lib/python2.7/lib-dynload', '/data/data/org.test.ExpressN16/files/lib/python2.7/site-packages', '/storage/sdcard0/org.test.ExpressN16']

I/python (26111): Android kivy bootstrap done. name is main

I/python (26111): Run user program, change dir and execute main.py

D/AbsListView( 2536): [unregisterDoubleTapMotionListener]

D/dalvikvm( 2536): GC_CONCURRENT freed 2059K, 9% free 38106K/41735K, paused 32ms+16ms, total 123ms

I/MotionRecognitionManager( 2536): .unregisterListener : / listener count = 0->0, ubvf 9budiwrd5ordgfl5BakTrklMrfo$,@,+*--8e8

D/AbsListView( 2536): [unregisterDoubleTapMotionListener]

I/MotionRecognitionManager( 2536): .unregisterListener : / listener count = 0->0, ubvf 9budiwrd5ordgfl5BakTrklMrfo$,@,)eed/)8

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

W/PowerManagerService( 2033): Timer 0x3->0x3|0x3

W/AlarmManager( 2033): FACTORY_ON= 0

W/AlarmManager( 2033): FACTORY_ON= 0

I/libSDL (26111): SDL_SetVideoMode(): application requested mode 800x1280

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/STATUSBAR-NetworkController( 2280): onReceive() - RSSI_CHANGED_ACTION, WIFI_STATE, NETWORK_STATE

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

V/AlarmManager( 2033): waitForAlarm result :8

W/AlarmManager( 2033): FACTORY_ON= 0

V/AlarmManager( 2033): waitForAlarm result :8

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8065 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/PopupuiReceiver(23533): onReceive() getAction : android.intent.action.NITZ_SET_TIME

D/PopupuiReceiver(23533): sendStickyBroadcast QUIT_NITZ_ACTION

D/AlarmManagerService( 2033): Kernel timezone updated to -660 minutes west of GMT

D/SystemClock( 2475): Setting time of day to sec=1362285583

D/SystemClock( 2475): Trying to open a file

D/SystemClock( 2475): File Open Failed

D/PopupuiReceiver(23533): onReceive() getAction : android.intent.action.NETWORK_SET_TIMEZONE

D/PopupuiReceiver(23533): NETWORK_SET_TIME prevMCCvalue : 505

D/PopupuiReceiver(23533): gsm.operator.numeric : 505

D/PopupuiReceiver(23533): SAME to prevMCCvalue : mccstrcmp

V/AlarmManager( 2033): waitForAlarm result :65536

W/AlarmManager( 2033): FACTORY_ON= 0

I/DrmEventService( 2033): nitZReceiver intent is recievedandroid.intent.action.NETWORK_SET_TIME

I/DrmEventService( 2033): handleNitztimeUpdation

I/DrmEventService( 2033): date is :: year2013month3day3hour4minute39second43

I/DrmEventService( 2033): calling handleDbOperation : TIME_CLOCK_UPDATE

I/DrmEventService( 2033): handleDbOperation case 6

I/DrmEventService( 2033): handleDbOperation acquireDrmInfo

I/DrmManager(Native)( 1728): DrmManager::acquireDrmInfo calling IDrmEngine

D/STATUSBAR-Clock( 2280): onReceive() - ACTION_TIME_CHANGED

D/STATUSBAR-Clock( 2280): onReceive() - ACTION_TIME_CHANGED

D/accuweather(23548): [MSC_Accu_Daemon]>>> AWDS:44 [0:0] Act

D/accuweather(23548): [MSC_Accu_Daemon]>>> AWDS:49 [0:0] Act : androidintentactionTIME_SET

D/comsamsunglog(23548): [MSC_Accu_Daemon]>>> ====================================================================================================================

D/comsamsunglog(23548): [MSC_Accu_Daemon]>>> daemonappapaccuweather [Version : 12111301 ] [ 1 ]

D/comsamsunglog(23548): [MSC_Accu_Daemon]>>> Header set to : ===> "accuweather" <===

D/comsamsunglog(23548): [MSC_Accu_Daemon]>>> ====================================================================================================================

D/accuweather(23548): [MSC_Accu_Daemon]>>> AWDS:64 [0:0] SerStus:0,ASerStus:0,TmpS:1,AtRfr:4

D/accuweather(23548): [MSC_Accu_Daemon]>>> AWDS:468 [0:0] CnclAtRftAl

I/DrmEventService( 2033): acquireDrmInfo status issuccess

I/DrmEventService( 2033): handleDbOperation : TIME_CLOCK_UPDATE secure clock ret is 0

I/DrmEventService( 2033): calling handleDbOperation : TIME_CLOCK_UPDATE

I/DrmEventService( 2033): handleDbOperation case 6

I/DrmEventService( 2033): handleDbOperation acquireDrmInfo

I/DrmManager(Native)( 1728): DrmManager::acquireDrmInfo calling IDrmEngine

I/DrmEventService( 2033): acquireDrmInfo status issuccess

I/DrmEventService( 2033): handleDbOperation : TIME_CLOCK_UPDATE secure clock for PR ret is 0

I/DrmEventService( 2033): userUpdatedTimeReceiver intent is recievedandroid.intent.action.TIME_SET

I/DrmEventService( 2033): autoEnable = 1

I/DrmEventService( 2033): timeFormat before setting = 12

I/DrmEventService( 2033): nowTimeFormat before setting = 12

I/DrmEventService( 2033): timeFormat after setting = 12

I/DrmEventService( 2033): nowTimeFormat after setting = 12

I/DrmEventService( 2033): userUpdatedTimeReceiver time format is not changed check if it is NITZ Update

I/DrmEventService( 2033): This is a NITZ update.So no need to update delta

W/AlarmManager( 2033): FACTORY_ON= 0

I/PhoneErrorReceiver(23562): onReceive

V/PhoneErrorReceiver(23562): beginStartingService

V/PhoneErrService(23562): Creating SmsReceiverService

V/PhoneErrService(23562): Starting #1: Bundle[mParcelledData.dataSize=36]

I/PhoneErrService(23562): mResultCode: 0

V/PhoneErrService(23562): Handling incoming message: { what=0 when=-2ms arg1=1 obj=Intent { act=android.intent.action.TIME_SET flg=0x28000010 cmp=com.sec.app.RilErrorNotifier/.PhoneErrService (has extras) } }

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8066 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

W/AlarmManager( 2033): FACTORY_ON= 0

V/PhoneErrorReceiver(23562): finishStartingService

V/PhoneErrService(23562): Destroying PhoneErrorReceiverService

I/Process (26139): Sending signal. PID: 26139 SIG: 9

I/ActivityManager( 2033): Process com.sec.android.widgetapp.SPlannerAppWidget (pid 26139) (adj 0) has died.

I/Process (26153): Sending signal. PID: 26153 SIG: 9

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/ActivityManager( 2033): Process com.sec.android.widgetapp.SPlannerAppWidget (pid 26153) (adj 0) has died.

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/SA (23607): [SBR] StdBroadcastReceiver received Intent of android.intent.action.TIME_SET

D/comdaemonstockapp(23648): [Daemon_Stock]>>> Stockclock_DaemonService.java:48 [0:0] onReceive: androidintentactionTIME_SET

D/comdaemonstockapp(23648): [Daemon_Stock]>>> Stockclock_DaemonService.java:55 [0:0] appServiceStatus: 0

D/comdaemonstockapp(23648): [Daemon_Stock]>>> Stockclock_DaemonService.java:56 [0:0] [AR]: 0

D/comdaemonstockapp(23648): [Daemon_Stock]>>> Stockclock_DaemonService.java:130 [0:0] Daemon is not receive event: servic off

W/AlarmManager( 2033): FACTORY_ON= 0

W/BackupManagerService( 2033): dataChanged but no participant pkg='com.android.providers.settings' uid=10191

D/PowerManagerService( 2033): setScreenOffTimeouts mKeylightDelay=1500 mDimDelay=591500 mScreenOffDelay=7000 mDimScreen=true

D/ApplicationPolicy( 2033): isStatusBarNotificationAllowed: packageName = com.alarmclock.xtreme.free

D/STATUSBAR-NotificationService( 2033): Noti Alert - mSystemReady:true, AlertEnabled:true

D/StatusBar( 2280): expanding top notification at 6entry.userCollapsed() = false

D/dalvikvm( 2033): GC_CONCURRENT freed 1844K, 37% free 45728K/72583K, paused 16ms+14ms, total 143ms

W/BackupManagerService( 2033): dataChanged but no participant pkg='com.android.providers.settings' uid=10019

D/PowerManagerService( 2033): setScreenOffTimeouts mKeylightDelay=1500 mDimDelay=591500 mScreenOffDelay=7000 mDimScreen=true

V/AlarmManager( 2033): waitForAlarm result :8

W/PowerManagerService( 2033): Timer 0x3->0x3|0x3

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8067 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8068 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

V/AlarmManager( 2033): waitForAlarm result :8

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8069 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/STATUSBAR-NetworkController( 2280): onReceive() - RSSI_CHANGED_ACTION, WIFI_STATE, NETWORK_STATE

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

I/InputReader( 2033): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8070 ]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x0

W/System.err(26111): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

W/System.err(26111): at android.os.Handler.(Handler.java:121)

W/System.err(26111): at android.content.ClipboardManager$2.(ClipboardManager.java:83)

W/System.err(26111): at android.content.ClipboardManager.(ClipboardManager.java:83)

W/System.err(26111): at android.app.ContextImpl$9.createService(ContextImpl.java:350)

W/System.err(26111): at android.app.ContextImpl$ServiceFetcher.getService(ContextImpl.java:252)

W/System.err(26111): at android.app.ContextImpl.getSystemService(ContextImpl.java:1443)

W/System.err(26111): at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:79)

W/System.err(26111): at android.app.Activity.getSystemService(Activity.java:4613)

W/System.err(26111): at org.renpy.android.SDLSurfaceView.nativeInit(Native Method)

W/System.err(26111): at org.renpy.android.SDLSurfaceView.run(SDLSurfaceView.java:636)

W/System.err(26111): at java.lang.Thread.run(Thread.java:856)

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

I/InputReader( 2033): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/InputDispatcher( 2033): Delivering touch to current input target: action: 0x1

I/python (26111): Python for android ended.

I/AndroidRuntime(26111): VM exiting with result code 0, cleanup skipped.

I/ActivityManager( 2033): Process org.test.ExpressN16:python (pid 26111) (adj 0) has died.

E/PowerManagerService( 2033): WakeLock : binderDied()

W/InputDispatcher( 2033): channel ~ Consumer closed input channel or an error occurred. events=0x9

E/InputDispatcher( 2033): channel ~ Channel is unrecoverably broken and will be disposed!

D/PowerManagerService( 2033): releaseWakeLockLocked flags=0x0 tag=Screen On

I/SurfaceFlinger( 1726): id=2124 Removed TurfaceView idx=2 MapSz=4

I/SurfaceFlinger( 1726): id=2124 Removed TurfaceView idx=-2 MapSz=4

D/KeyguardViewMediator( 2033): setHidden false

W/InputDispatcher( 2033): Attempted to unregister already unregistered input channel

I/SurfaceFlinger( 1726): id=2123 Removed QythonActiv idx=2 MapSz=3

D/KeyguardViewMediator( 2033): setHidden false

I/SurfaceFlinger( 1726): id=2123 Removed QythonActiv idx=-2 MapSz=3

I/SurfaceFlinger( 1726): id=2123 Removed QythonActiv idx=-2 MapSz=3

I/SurfaceFlinger( 1726): id=2124 Removed TurfaceView idx=-2 MapSz=3

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw

D/PointerIcon( 2033): setHoveringSpenIconStyle1 pointerType: 10001iconType:1

D/WindowManager( 2033): mInputFocus is not null.

D/PointerIcon( 2033): setHoveringSpenCustomIcon IconType is same.1

V/AlarmManager( 2033): waitForAlarm result :8

D/KeyguardViewMediator( 2033): setHidden false

V/WindowManager( 2033): rotationForOrientationLw(orient=5, last=0); user=0 USER_ROTATION_LOCKED mLidState=-1 mCoverState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false sensorRotation=-1

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

D/KeyguardViewMediator( 2033): setHidden false

D/WindowManager( 2033): mInputFocus is not null.

D/KeyguardViewMediator( 2033): setHidden false

D/WindowManager( 2033): mInputFocus is not null.

D/WindowManager( 2033): mInputFocus is not null.

W/AlarmManager( 2033): FACTORY_ON= 0

V/AlarmManager( 2033): waitForAlarm result :8

I/SurfaceFlinger( 1726): id=2125(172) createSurf 0x410f6ed4 (800x1280),1 flag=0, Mauncher

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw

D/WindowManager( 2033): PhoneWindowManager: focusChangedLw: Call setFocusedWindow()

D/SPenGesture( 2033): SpenGestureView: setFocusedWindow

D/KeyguardViewMediator( 2033): setHidden false

D/STATUSBAR-StatusBarManagerService( 2033): setSystemUiVisibility(0x400)

D/STATUSBAR-StatusBarManagerService( 2033): manageDisableList what=0x0 pkg=WindowManager.LayoutParams

D/PointerIcon( 2033): setHoveringSpenIconStyle1 pointerType: 10001iconType:1

D/PointerIcon( 2033): setHoveringSpenCustomIcon IconType is same.1

D/dalvikvm( 2304): GC_CONCURRENT freed 386K, 9% free 12171K/13319K, paused 12ms+2ms, total 41ms

W/InputMethodManagerService( 2033): Got RemoteException sending setActive(false) notification to pid 26111 uid 10136

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/KeyguardViewMediator( 2033): setHidden false

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

W/PowerManagerService( 2033): Timer 0x3->0x3|0x0

V/AlarmManager( 2033): waitForAlarm result :8

D/STATUSBAR-NetworkController( 2280): onReceive() - RSSI_CHANGED_ACTION, WIFI_STATE, NETWORK_STATE

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

D/STATUSBAR-NetworkController( 2280): refreshSignalCluster: data=0 bt=false

V/AlarmManager( 2033): waitForAlarm result :8

V/AlarmManager( 2033): waitForAlarm result :8`

tito commented 11 years ago

Here is the relevant part:

W/System.err(26111): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
W/System.err(26111): at android.os.Handler.(Handler.java:121)
W/System.err(26111): at android.content.ClipboardManager$2.(ClipboardManager.java:83)
W/System.err(26111): at android.content.ClipboardManager.(ClipboardManager.java:83)
W/System.err(26111): at android.app.ContextImpl$9.createService(ContextImpl.java:350)
W/System.err(26111): at android.app.ContextImpl$ServiceFetcher.getService(ContextImpl.java:252)
W/System.err(26111): at android.app.ContextImpl.getSystemService(ContextImpl.java:1443)
W/System.err(26111): at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:79)
W/System.err(26111): at android.app.Activity.getSystemService(Activity.java:4613)
W/System.err(26111): at org.renpy.android.SDLSurfaceView.nativeInit(Native Method)
W/System.err(26111): at org.renpy.android.SDLSurfaceView.run(SDLSurfaceView.java:636)
W/System.err(26111): at java.lang.Thread.run(Thread.java:856)

When i google that error, i'm seeing threads about UI seperation, and they mostly use Runnable to be able to run that in the UI thread. I'm not sure how that apply to us, but you cannot use pyjnius (yet) for creating java class from python.

tito commented 11 years ago

http://stackoverflow.com/a/12946228/69877 -> this guy resolve the issue by creating an instance into the activity.

So the answer is: you can't do that with pyjnius, because of the separation between the PythonActivity and the our UI. In our case, accessing to this context from the UI is not possible, so you need to manually change the PythonActivity.java for creating the ClipboardManager, then you can access from pyjnius with autoclass('org.renpy.android.PythonAndroid').m_clipboarManager.