layout: post title: "android" subtitle: "android" date: 2019-05-11 10:51:40 author: "none" header-img: "img/posts/default_post.jpg" catalog: true tags: - tag
application 应用什么周期内仅允许一次
service 调用顺序 onCreate onStartCommand
service debug android代码中添加 android.os.Debug.waitForDebugger();
使用app_process启动java进程(进程和shell用户权限相同)
adb shell "CLASSPATH=/data/local/tmp/server-debug.apk app_process / com.genymobile.scrcpy.Server 0 8000000 false - false"
使用am start 启动apk,apk需要已安装
adb shell "am start -n com.genymobile.scrcpy/com.genymobile.scrcpy.Server"
启动service
adb shell am start-foreground-service -n com.genymobile.scrcpy/.MouseService adb shell am start-service -n com.genymobile.scrcpy/.MouseService
在service中显示悬浮窗
原生java线程中访问android 相关接口
Activity, Service的启动方法startActivity, startService依赖Intent和Context
ActivityManager, ServiceManager 原生线程中获取android的service
private final ServiceManager serviceManager = new ServiceManager(); DisplayInfo displayInfo = serviceManager.getDisplayManager().getDisplayInfo(); serviceManager.getInputManager().injectInputEvent(inputEvent, mode); serviceManager.getWindowManager().registerRotationWatcher(rotationWatcher); serviceManager.getStatusBarManager().expandNotificationsPanel();
系统服务
系统进程system_server, 为所有应用提供服务 ActivityManagerService WindowManagerService