当前位置: 首页 > backend >正文

【002】renPy android端启动流程分析

 接上篇分析

org.renpy.android.PythonSDLActivity#onCreate

 它先调用了

org.libsdl.app.SDLActivity#onCreate
源码如下:
@Override  // android.app.Activity
protected void onCreate(Bundle bundle0) {//1. 日志记录String s;Log.v("SDL", "Device: " + Build.DEVICE);Log.v("SDL", "Model: " + Build.MODEL);Log.v("SDL", "onCreate()");super.onCreate(bundle0);try {// 2. 设置线程名称Thread.currentThread().setName("SDLActivity");}catch(Exception exception0) {Log.v("SDL", "modify thread properties failed " + exception0.toString());}
//3. 加载本地库try {this.loadLibraries();SDLActivity.mBrokenLibraries = false;s = "";}catch(UnsatisfiedLinkError unsatisfiedLinkError0) {System.err.println(unsatisfiedLinkError0.getMessage());SDLActivity.mBrokenLibraries = true;s = unsatisfiedLinkError0.getMessage();}catch(Exception exception1) {System.err.println(exception1.getMessage());SDLActivity.mBrokenLibraries = true;s = exception1.getMessage();}if(SDLActivity.mBrokenLibraries) {SDLActivity.mSingleton = this;AlertDialog.Builder alertDialog$Builder0 = new AlertDialog.Builder(this);alertDialog$Builder0.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall.\n\nError: " + s);alertDialog$Builder0.setTitle("SDL Error");alertDialog$Builder0.setPositiveButton("Exit", new DialogInterface.OnClickListener() {@Override  // android.content.DialogInterface$OnClickListenerpublic void onClick(DialogInterface dialogInterface0, int v) {SDLActivity.mSingleton.finish();}});alertDialog$Builder0.setCancelable(false);alertDialog$Builder0.create().show();return;}//5. 初始化 SDL JNI 接口SDL.setupJNI();// 6. 全局状态初始化SDL.initialize();SDLActivity.mSingleton = this;SDL.setContext(this);SDLActivity.mClipboardHandler = new SDLClipboardHandler();SDLActivity.mSurface = new SDLSurface(this.getApplication());RelativeLayout relativeLayout0 = new RelativeLayout(this);SDLActivity.mLayout = relativeLayout0;relativeLayout0.addView(SDLActivity.mSurface);int v = SDLActivity.getCurrentOrientation();SDLActivity.mCurrentOrientation = v;SDLActivity.onNativeOrientationChanged(v);try {SDLActivity.mCurrentLocale = Build.VERSION.SDK_INT < 24 ? SDLActivity.getContext().getResources().getConfiguration().locale : SDLActivity.getContext().getResources().getConfiguration().getLocales().get(0);}catch(Exception unused_ex) {}//7. 设置内容视图this.setContentView(SDLActivity.mLayout);//8. 窗口样式与 UI 设置SDLActivity.setWindowStyle(false);this.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this);//9. 处理 Intent 数据(如文件路径)Intent intent0 = this.getIntent();if(intent0 != null && intent0.getData() != null) {String s1 = intent0.getData().getPath();if(s1 != null) {Log.v("SDL", "Got filename: " + s1);SDLActivity.onNativeDropFile(s1);}}
}


功能
描述
日志输出
输出设备信息和生命周期状态,便于调试
本地库加载
加载 SDL 核心库和游戏逻辑库
异常处理
处理加载失败的情况并提示用户
JNI 初始化
设置 Java 与 C/C++ 交互的基础环境
UI 初始化
创建 SDLSurface 并设置为内容视图
全局状态管理
初始化 SDL 相关的全局状态和事件处理器
Intent 支持
支持通过 Intent 传入外部数据(如文件路径)

实际加载的是

@Override  // org.libsdl.app.SDLActivity
protected String[] getLibraries() {return new String[]{"renpython"};
}

里面有一堆native的方法

http://www.xdnf.cn/news/5734.html

相关文章:

  • 主播美颜API常见问题解析:兼容性、性能与SDK效果调优
  • 【MCP】其他MCP服务((GitHub)
  • 001大模型-认识大模型以及大模型应用场景
  • docker gaussdb常用命令
  • 从MCU到SoC的开发思维转变
  • 【Python】杂乱-转义字符
  • 安装 NVIDIA 驱动 570.133.20 的自动化脚本
  • 鲁滨逊归结原理详解:期末考点+解题指南
  • 【AI论文】HunyuanCustom:一种多模态驱动的定制视频生成架构
  • 自适应蒙特卡洛定位-AMCL
  • HomeBank:免费且强大的个人财务管理软件
  • 【MySQL】牛客网sql语句简单例题,sql入门
  • 使用Daemonset部署日志收集守护进程
  • snoop操作怎么维护一致性?
  • 射频ADRV9026驱动
  • 供应链学习
  • 电脑端实用软件合集:土拨鼠+Rufus+实时网速监控工具
  • IDEA+git将分支合并到主分支、IDEA合并分支
  • 力扣2094题解
  • langchain4j中使用milvus向量数据库做RAG增加索引
  • 激光雷达点云畸变消除:MCU vs CPU 方案详解
  • AI Agent(11):垂直行业应用
  • 如何避免Java中的ConcurrentModificationException
  • 网页jupyter如何显示jpipvenv虚拟环境
  • android setImageResource和setBackgroundResource区别
  • 【Dv3Admin】工具视图配置文件解析
  • PTA:jmu-ds-最短路径
  • 日常组件复用与基于构件开发的本质区别
  • 第三章 仿真器介绍
  • python标准库--itertools - 迭代器工具在算法比赛的应用