コード例 #1
0
try:
    import jni

    System = jni.cls("java/lang/System")
except:
    print("SKIP")
    raise SystemExit

System.out.println("Hello, Java!")
コード例 #2
0
ファイル: object.py プロジェクト: OS-Q/Y511
import sys
import jni
try:
    Integer = jni.cls("java/lang/Integer")
except:
    print("SKIP")
    sys.exit()

# Create object
i = Integer(42)
print(i)
# Call object method
print(i.hashCode())
# Pass object to another method
System = jni.cls("java/lang/System")
System.out.println(i)
コード例 #3
0
ファイル: list.py プロジェクト: Netzvamp/micropython_m5stack
import jni
try:
    ArrayList = jni.cls("java/util/ArrayList")
except:
    print("SKIP")
    raise SystemExit

l = ArrayList()
print(l)
l.add("one")
l.add("two")

print(l.toString())
print(l)
print(l[0], l[1])
コード例 #4
0
ファイル: system_out.py プロジェクト: Achimh3011/micropython
try:
    import jni
    System = jni.cls("java/lang/System")
except:
    print("SKIP")
    raise SystemExit

System.out.println("Hello, Java!")
コード例 #5
0
ファイル: pm.py プロジェクト: pfalcon/micropython-projs
# Implementation of native Android "pm list packages"
# command in MicroPython.
import ffi
import jni

# Bootstrap JVM
jni.cls("java/lang/Object")
rt = ffi.open("/system/lib/libandroid_runtime.so")
# Note in 5.x, function may be called: jint registerFrameworkNatives(JNIEnv* env)
# https://android-review.googlesource.com/#/c/157981/1/core/jni/AndroidRuntime.cpp
registerNatives = rt.func("p", "Java_LoadClass_registerNatives", "pp")
registerNatives(jni.env(), None)

# This is older, Java-level way to register framework natives, but
# "registerNatives" method may be absent in 4.x devices, and class
# itself is removed in 5.x.
#fw = jni.cls("com.android.internal.util.WithFramework")
#fw.registerNatives()

ServiceManager = jni.cls("android/os/ServiceManager")
pm = ServiceManager.getService("package")
#print("Service:", pm)
IPackageManager = jni.cls("android/content/pm/IPackageManager")
#print("IPackageManager", IPackageManager)
IPackageManager_Stub = jni.cls("android/content/pm/IPackageManager$Stub")
#print(IPackageManager_Stub)
mPm = IPackageManager_Stub.asInterface(pm)
#print("mPm:", mPm, mPm.toString())
#print("=================")
res = mPm.getInstalledPackages(0, 0)
#res = pm.getInstalledPackages(0)