WO2015196756A1 - 一种运行应用程序的方法及设备 - Google Patents

一种运行应用程序的方法及设备 Download PDF

Info

Publication number
WO2015196756A1
WO2015196756A1 PCT/CN2014/094434 CN2014094434W WO2015196756A1 WO 2015196756 A1 WO2015196756 A1 WO 2015196756A1 CN 2014094434 W CN2014094434 W CN 2014094434W WO 2015196756 A1 WO2015196756 A1 WO 2015196756A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
j2me
android
graphics
interface
Prior art date
Application number
PCT/CN2014/094434
Other languages
English (en)
French (fr)
Inventor
陈万琛
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015196756A1 publication Critical patent/WO2015196756A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and device for running a Java 2 Platform Micro Edition (J2me, Java 2 Platform Micro Edition) application on an Android system.
  • J2me Java 2 Platform Micro Edition
  • J2me platform is a development platform developed by Sun for embedded, consumer electronics products designed to run the same Java applications on different mobile devices.
  • J2me can be a set-top box, mobile phone and PDA (Personal Digital Assistant).
  • Java technology platform provided by embedded consumer electronics devices such as handheld computers.
  • the present invention provides a method and apparatus for running an application that overcomes the above technical problems or at least partially solves the above technical problems, and realizes the normal operation of the J2me application on the Android system.
  • a method of running an application including:
  • the method further includes:
  • the Android application is installed on the Android system, and the Android application is started.
  • the step of calling, by the Java local interface, the graphic application interface of the Android application, and rendering and rendering the graphic in the J2me application into the screen window provided by the Android application comprises:
  • the refresh refresh interface is called to notify the renderer Renderer rendering thread to refresh the screen window
  • the graphics in the preset graphics buffer are rendered into the OpenGL texture of the open graphics library
  • a graphic in the OpenGL texture is displayed in the screen window to form a picture of the J2me application runtime that the user finally sees.
  • the screen window provided by the Android application is an OpenGL view window GLSurfaceview.
  • the method further includes:
  • the button event is obtained by the J2me virtual machine and sent to the J2me application, and the button event processing is performed by the J2me application.
  • a device for running an application including a startup module, an interface calling module, and a graphics processing module, wherein:
  • the startup module is configured to: after starting the Android application on the Android system, start the J2me virtual machine to run the J2me application;
  • the interface calling module is configured to: when the J2me application needs to invoke a graphics port, invoke the Java local interface of the Android application by using the J2me virtual machine;
  • the graphics processing module is configured to: invoke a graphics application interface of the Android application through the Java local interface, and draw and render a graphic in the J2me application into a screen window provided by the Android application.
  • the device further includes a download detection module, a download module, and an installation module, where:
  • the download detection module is configured to: detect a download command to download the Android application
  • the downloading module is configured to: when detecting a download command to download the Android application, download an installation package of the Android application;
  • the installation module is configured to: after the download is completed, install an installation package of the Android application on an Android system, and start the Android application.
  • the graphics processing module is configured to invoke a graphics application interface of the Android application through the Java local interface, and draw and render graphics in the J2me application to the Android application.
  • the screen window In the screen window:
  • the screen window provided by the Android application is an OpenGL view window. GLSurfaceview.
  • the device further includes a button event receiving module, a button event sending module, and a button event processing module, where:
  • the button event receiving module is configured to: receive a button event when the J2me application is running;
  • the button event sending module is configured to: send the received button event to the Android application, store the queue and notify the J2me virtual machine;
  • the button event processing module is configured to: acquire the button event by using the J2me virtual machine, and send the button event to the J2me application, and perform key event processing by the J2me application.
  • a computer program comprising program instructions that, when executed by a computer, cause the computer to perform any of the methods described above for running an application.
  • a carrier carrying the computer program A carrier carrying the computer program.
  • the Android application starts the J2me virtual machine to run the corresponding J2me application, and the J2me application runs on the J2me virtual machine, and the graphical interface invoked by the J2me virtual machine is modified.
  • the J2me application calls the graphical interface, it calls the JNI (Java native call interface) of the Android application, and calls it back to the J2me application's Java layer through JNI to render and render it to the screen window, thus realizing the J2me application on the Android system. run.
  • JNI Java native call interface
  • FIG. 1 shows one of the flowcharts of a method of running an application in an embodiment of the present invention
  • FIG. 2 is a schematic diagram showing an operating environment of a J2me application in an embodiment of the present invention
  • Figure 3 is a timing chart showing the drawing of a graphic in the embodiment of the present invention.
  • Figure 5 is a flow chart 2 showing a method of running an application according to an embodiment of the present invention.
  • Figure 6 is a flow chart showing the operation of the J2me game in the embodiment of the present invention.
  • Figure 7 shows a block diagram of an apparatus for running an application in an embodiment of the present invention.
  • a method for running an application in an embodiment of the present invention includes the following steps:
  • Step S101 After starting the Android application on the Android system, start the J2me virtual machine to run the corresponding J2me application.
  • Android is a Linux-based open source electronic device operating system, in which electronic devices can be set-top boxes, mobile phones, tablets and other devices.
  • An Android application may be an application running on a device such as a set top box, a mobile phone, or a tablet of an Android system, for example, an Android application may be a game application.
  • the Android application can be used for: (1) display of graphics; (2) enabling the thread to start the J2me virtual machine; (3) receiving the key event and sending it to the J2me virtual machine; (4) providing the graphic application
  • the interface is used by the J2me virtual machine; (4) the WatchService (the standard interface for file monitoring provided in the WatchService) is transmitted and stored in the database.
  • the Android application is a bridge for communication between the Android system and the J2me virtual machine. .
  • the J2me virtual machine is a Java Virtual Machine (JVM), a specification for computing devices.
  • JVM Java Virtual Machine
  • Step S103 When the J2me application needs to invoke the graphic application interface, the Java local interface of the Android application is invoked through the J2me virtual machine.
  • JNI Java Native Interface
  • Step S105 calling the graphic application interface of the Android application through the JNI, and drawing and rendering the graphic in the J2me application into a screen window provided by the Android application.
  • the graphical application interface of the Android application can be called by LibJavaprocess.so.
  • the parameter LibJavaprocess.so is provided by the product line, which is responsible for parsing the bytecode in the J2me application, converting the data passed in the J2me application into interface data and controlling the graphics rendering. .
  • the J2me application and the J2me virtual machine can be kept unchanged, and only the original QT graphics application interface is modified.
  • the J2ME virtual machine is called by the JNI provided by the Android application, and then called by the JNI.
  • the graphical application interface of the Android application which draws graphics from the J2me application on a screen window (also known as a screen container) provided by the Android application.
  • FIG. 3 it is a timing diagram of graphic drawing in an embodiment of the present invention, and the graphic drawing process includes:
  • Step S301 the J2me application calls JNI to start drawing
  • Step S303 notifying the Renderer to render the thread update screen.
  • Step S305 rendering the graphic into the OpenGL texture
  • Step S307 updating the graphic to the screen window.
  • the screen window provided by the Android application is an OpenGL view window (GLSurfaceview).
  • the J2me application calls the Java layer of the Android application through the JNI to perform graphics drawing and stores it in a preset graphics buffer; after the drawing is finished, the J2me application calls the Refresh interface to notify the Renderer rendering thread to refresh the screen window. After receiving the refresh request, the Renderer rendering thread renders the graphics in the preset graphics buffer to the OpenGL texture, and finally displays the graphics in the texture in the screen window to form the J2me application that the user finally sees. The picture at the time.
  • an API (application programming interface) of an Android application implements a function of a QT-based graphical application interface.
  • the first is to create an Android application, and the view used by the Android application.
  • Is GLSurfaceview in this Android application will create three threads: UIThread (user interface thread), GLRenderThread (GL rendering thread) and appThread, where UIThread is the Android box
  • UIThread is the Android box
  • the content of the shelf through the UIThread to get the button pause, exit and other buttons, received the button and stored in the queue and notify appThread, appThread to the queue to take the button and pass the JNI to the J2me virtual machine to complete the key event delivery.
  • GLRenderThread is a thread used by GLSurfaceview for GL rendering. It has two modes: timed refresh and dirty refresh. For example, its refresh mode is set to dirty refresh. When the drawing ends to call the refresh interface, the Renderer is notified to refresh.
  • appThread is the JVM process of the original Linux platform, responsible for parsing bytecode and controlling drawing.
  • a second flowchart of the method for running an application in the embodiment of the present invention is different from the method shown in FIG. 1, and further includes, before step S101 in FIG.
  • Step S107 When detecting a download command for downloading an Android application, download an installation package of the Android application;
  • Step S109 After the download is completed, install and launch the Android application on the Android system.
  • the download command is detected by the Java WatchService (WatchService is used to monitor the file system change), and the WatchService is started by the Android system.
  • WatchService is used to monitor the file system change
  • the WatchService is started by the Android system.
  • the installation package is downloaded and the Android application is started, and the Android application starts the J2me virtual machine to run correspondingly.
  • the J2me application the J2me application runs on the J2me virtual machine, and modifies the graphical interface invoked by the J2me virtual machine.
  • the J2me application calls the graphical interface, it calls the JNI of the Android application and calls the Java of the J2me application via JNI.
  • the layers are drawn and rendered onto the screen window.
  • the third flowchart of the J2me application running in the embodiment of the present invention is different from the method shown in FIG. 1.
  • the method further includes:
  • Step S111 receiving a button event
  • Step S113 Send the received button event to the Android application to be queued, and notify the J2me virtual machine;
  • Step S115 The J2me virtual machine acquires a key event and sends it to the J2me application, and the J2me application performs button processing.
  • Step S601 the WatchService listens to the download command
  • Step S603 after receiving the download command, downloading the game package
  • IPTV interactive network television
  • a network download game package provided by the broadcasting and television.
  • Step S605 after the download is completed, installing and starting the game device APP;
  • the game device APP is used to provide a display window for display of the game and to provide JNI, which is a graphical application interface that the game needs to use. After installing and launching the game device APP, the J2me game is launched as a thread.
  • Step S607 starting a J2me virtual machine
  • Step S609 parsing the game package through the J2me virtual machine to run the J2me game, and then proceeds to step S611 and step S617;
  • Step S611 calling the JNI of the game device APP through the J2me virtual machine
  • Step S613 calling a graphic application program interface of the game device APP;
  • Step S615 drawing and rendering the graphic in the J2me game to the screen window provided by the game device APP;
  • Step S617 receiving a button event
  • Step S619 sending the received button event to the game device APP, storing the queue and notifying the J2me virtual machine;
  • Step S621 Acquire a key event through the J2me virtual machine.
  • step S623 the button event is sent to the J2me game, and the button event processing is performed by the J2me game.
  • the Java game and the J2me virtual machine can remain unchanged, and only the original QT interface is modified.
  • the entire modified model diagram is shown in Figure 2, which is to provide the J2me virtual machine to invoke the game device APP.
  • the JNI calls the graphics API of the game device APP by JNI, and draws the graphics in the game on the screen window, which is provided by the game device APP.
  • the device 700 includes: a startup module 701, configured to: after starting an Android application on an Android system, start a J2me virtual machine and run a corresponding J2me. application;
  • the interface invoking module 703 is configured to: when the J2me application needs to invoke a graphics port, Calling the JNI of the Android application through the J2me virtual machine;
  • the graphics processing module 705 is configured to: invoke the graphics application interface of the Android application through the JNI, and draw and render the graphics in the J2me application into a screen window provided by the Android application.
  • the device further includes:
  • Downloading a detection module configured to: detect a download command for downloading the Android application
  • a downloading module configured to: when detecting a download command of downloading the Android application, download an installation package of the Android application;
  • the installation module is configured to: after the download is completed, install the installation package of the Android application on the Android system, and start the Android application.
  • the graphics processing module 705 is further configured to: call the Java layer of the Android application to perform graphics drawing by using the Java local interface, and store the data in a preset graphics buffer.
  • the J2me application calls to refresh the Refresh interface to notify the renderer Renderer rendering thread to refresh the screen window; the Renderer rendering thread will preset the graphics buffer after receiving the refresh request.
  • the graphics are rendered into the OpenGL texture of the open graphics library; the graphics in the texture are displayed in the screen window to form the runtime of the J2me application that the user finally sees.
  • the screen window provided by the Android application is an OpenGL view window GLSurfaceview.
  • the device further includes:
  • a button event receiving module configured to: receive a button event when the J2me application is running
  • the button event sending module is configured to: send the received button event to the Android application, store the queue and notify the J2me virtual machine;
  • the button event processing module is configured to: acquire the button event by using the J2me virtual machine, and send the button event to the J2me application, where the button event processing is performed by the J2me application.
  • the embodiment of the invention also discloses a computer program, comprising program instructions, which when executed by a computer, enable the computer to execute any of the above methods for running an application.
  • the embodiment of the invention also discloses a carrier carrying the computer program.
  • the Android application starts the J2me virtual machine to run the corresponding J2me application, and the J2me application runs on the J2me virtual machine to modify the graphical interface invoked by the J2me virtual machine.
  • JNI Java native call interface
  • the J2me application is called back to the J2me application's Java layer for drawing and rendering to the screen window, so that the J2me application runs normally on the Android system. Therefore, the present invention has strong industrial applicability.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

一种运行应用程序的方法及设备,该方法包括:在Android系统上启动Android应用之后,启动J2me虚拟机运行相应的J2me应用程序;当所述J2me应用程序需要调用图形口时,通过所述J2me虚拟机调用所述Android应用的Java本地接口;通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中,实现J2me应用在Android系统上正常运行。

Description

一种运行应用程序的方法及设备 技术领域
本发明涉及计算机技术领域,尤其涉及一种在安卓(Android)系统上运行Java2平台微型版(J2me,Java2 Platform Micro Edition,)应用的方法及设备。
背景技术
J2me平台是SUN公司为了解决在不同移动终端上运行相同的Java应用而设计的针对于嵌入式、消费类电子产品而推出的开发平台,例如J2me可以为机顶盒、移动电话和PDA(Personal Digital Assistant),掌上电脑)之类的嵌入式消费电子设备提供的Java语言平台。
随着智能机顶盒的不断发展,已经在逐步取代从前的Linux机顶盒,原来在Linux上运行的J2me游戏急需运行在Android机顶盒上。
然而,目前网络上有成千上万个在传统Linux机顶盒上运行的游戏,这些游戏均是J2me基于QT(一种的跨平台C++图形用户界面应用程序开发框架)图形应用程序接口开发的,由于在Android机顶盒上缺少QT加速的组件,如果继续使用原来QT图形应用程序接口,会导致在Android机顶盒上运行游戏的速度会非常慢,从而影响用户体验。
发明内容
鉴于上述技术问题,本发明提供了一种克服上述技术问题或者至少部分地解决上述技术问题的运行应用程序的方法及设备,实现J2me应用在Android系统上正常运行。
为解决上述技术问题,采用如下技术方案:
一种运行应用程序的方法,包括:
在Android系统上启动Android应用之后,启动J2me虚拟机运行J2me应用程序;
当所述J2me应用程序需要调用图形口时,通过所述J2me虚拟机调用所述Android应用的Java本地接口;
通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中。
可选地,所述方法还包括:
当检测到下载所述Android应用的下载命令时,下载所述Android应用的安装包;
在下载完成后,在所述Android系统上安装所述Android应用,并启动所述Android应用。
可选地,所述通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中的步骤包括:
通过所述Java本地接口调用所述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;
绘制结束后,调用刷新Refresh接口,通知渲染器Renderer渲染线程刷新所述屏幕窗口;
在所述Renderer渲染线程在收到刷新的请求后,将预设的图形缓冲区中的图形渲染至开放式图形库OpenGL纹理中;
将OpenGL纹理中的图形显示在所述屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
可选地,所述Android应用提供的屏幕窗口是OpenGL视图窗口GLSurfaceview。
可选地,所述方法还包括:
在所述J2me应用程序运行时,接收按键事件;
将接收到的所述按键事件发送给所述Android应用,存入队列并通知所述J2me虚拟机;
通过所述J2me虚拟机获取所述按键事件,并发送给所述J2me应用程序,由所述J2me应用程序进行按键事件处理。
一种运行应用程序的设备,包括启动模块、接口调用模块和图形处理模块,其中:
所述启动模块设置成:在Android系统上启动Android应用之后,启动J2me虚拟机运行J2me应用程序;
所述接口调用模块设置成:当所述J2me应用程序需要调用图形口时,通过所述J2me虚拟机调用所述Android应用的Java本地接口;
所述图形处理模块设置成:通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中。
可选地,所述设备还包括下载检测模块、下载模块和安装模块,其中:
所述下载检测模块设置成:检测下载所述Android应用的下载命令;
所述下载模块设置成:在检测到下载所述Android应用的下载命令时,下载所述Android应用的安装包;
所述安装模块设置成:在下载完成后,在Android系统上安装所述Android应用的安装包,并启动所述Android应用。
可选地,所述图形处理模块设置成按照如下方式通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中:
通过所述Java本地接口调用所述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;绘制结束后,调用刷新Refresh接口,通知渲染器Renderer渲染线程刷新所述屏幕窗口;在所述Renderer渲染线程在收到刷新的请求后,将预设的图形缓冲区中的图形渲染至开放式图形库OpenGL纹理中;将OpenGL纹理中的图形显示在所述屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
可选地,所述Android应用提供的屏幕窗口是OpenGL视图窗口 GLSurfaceview。
可选地,所述设备还包括按键事件接收模块、按键事件发送模块和按键事件处理模块,其中:
所述按键事件接收模块设置成:在所述J2me应用程序运行时,接收按键事件;
所述按键事件发送模块设置成:将接收到的所述按键事件发送给所述Android应用,存入队列并通知所述J2me虚拟机;
所述按键事件处理模块设置成:通过所述J2me虚拟机获取所述按键事件,并发送给所述J2me应用程序,由所述J2me应用程序进行按键事件处理。
一种计算机程序,包括程序指令,当该程序指令被计算机执行时,使得该计算机可执行上述任意的运行应用程序的方法。
一种载有所述计算机程序的载体。
本发明技术方案的有益效果是:在本发明的实施例中,Android应用启动J2me虚拟机运行相应的J2me应用程序,J2me应用程序运行在J2me虚拟机上,修改J2me虚拟机调用的图形接口,当J2me应用程序调用图形的接口时,调用到Android应用的JNI(Java本地调用接口),通过JNI调用回J2me应用程序的Java层进行绘图并渲染到屏幕窗口上,从而实现J2me应用在Android系统上正常运行。
附图概述
图1表示本发明的实施例中运行应用程序的方法的流程图之一;
图2表示本发明的实施例中J2me应用程序运行环境的示意图;
图3表示本发明的实施例中图形绘制的时序图;
图4表示本发明的实施例中运行应用程序的方法的流程图之二;
图5表示本发明的实施例运行应用程序的方法的流程图之二;
图6表示本发明的实施例中J2me游戏运行的流程图;以及
图7表示本发明的实施例中运行应用程序的设备的框图。
本发明的较佳实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
如图1所示,为本发明的实施例中运行应用程序的方法,包括如下步骤:
步骤S101、在Android系统上启动Android应用之后,启动J2me虚拟机运行相应的J2me应用程序。
其中,Android(安卓)系统是一个以Linux为基础的开放源代码的电子设备操作系统,其中电子设备可以是机顶盒、移动电话、平板电脑等设备。
Android应用(APP)可以是在Android系统的机顶盒、移动电话、平板电脑等设备上运行的应用程序,例如Android应用可以是游戏应用。在本发明的实施例,Android应用可以用于:(1)图形的显示;(2)开启线程启动J2me虚拟机;(3)按键事件的接收并发给J2me虚拟机;(4)提供图形应用程序接口(API)供J2me虚拟机使用;(4)接收WatchService(WatchService里面提供了对文件监控的标准接口)透传过来的参数并存到数据库中,该Android应用是Android系统和J2me虚拟机沟通的桥梁。
J2me虚拟机是一种Java虚拟机(JVM,Java Virtual Machine),Java虚拟机是一种用于计算设备的规范。
步骤S103、当J2me应用程序需要调用图形应用程序接口时,通过J2me虚拟机调用Android应用的Java本地接口。
Java本地调用接口(Java Native Interface,JNI),从Java1.1开始,JNI标准成为Java平台的一部分,JNI标准允许Java代码和其他语言写的代码进行交互。
步骤S105、通过JNI调用Android应用的图形应用程序接口,并将J2me应用程序中的图形绘制并渲染到Android应用提供的屏幕窗口中。
Android应用的图形应用程序接口可以通过LibJavaprocess.so调用,参数LibJavaprocess.so由产品线提供,负责J2me应用程序中字节码的解析,将J2me应用程序中传递的数据转换为接口数据并控制图形绘制。
在本发明的实施例中,可以保持J2me应用程序和J2me虚拟机不变,仅对原来的QT图形应用程序接口进行修改,图2中J2ME虚拟机通过调用Android应用提供的JNI,再由JNI调用Android应用的图形应用程序接口,将J2me应用程序中的图形绘制在屏幕窗口(也可称为屏幕容器)上,该屏幕窗口由Android应用提供。
如图3所示,为本发明的实施例中图形绘制的时序图,该图形绘制流程包括:
步骤S301、J2me应用程序调用JNI开始绘图;
步骤S303、通知Renderer渲染线程更新屏幕。
步骤S305、将图形渲染至OpenGL纹理中;
步骤S307、将图形更新至屏幕窗口。可选地,Android应用提供的屏幕窗口是OpenGL视图窗口(GLSurfaceview)。
具体地,J2me应用程序通过JNI调用述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;绘制结束后,J2me应用程序调用Refresh接口,通知Renderer渲染线程刷新屏幕窗口。Renderer渲染线程在收到刷新的请求后,将预设的图形缓冲区中的图形渲染至OpenGL纹理中,最后将纹理中的图形显示在屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
在本发明的实施例中,Android应用的API(应用程序编程接口)实现之前基于QT的图形应用程序接口的功能,要使用Android应用的API,首先就是创建一个Android应用,该Android应用使用的视图是GLSurfaceview,在该Android应用中将会创建三个线程:UIThread(用户界面线程)、GLRenderThread(GL渲染线程)和appThread,其中UIThread是Android框 架的内容,通过UIThread获取按键暂停,退出等按键,收到按键后存入队列中并通知appThread,appThread到队列中取按键并通过JNI传给J2me虚拟机,完成按键事件传递。GLRenderThread是GLSurfaceview用于GL渲染的线程,其具有定时刷新和脏刷新两种模式,例如将其刷新模式设置为脏刷新,当绘图结束调用refresh接口时,通知Renderer(渲染器)进行刷新。appThread为原Linux平台的JVM进程,负责解析字节码以及控制画图。
如图4所示,为本发明的实施例中运行应用程序的方法的流程图之二,与图1中所示的方法不同的是,图4中在步骤S101之前还包括:
步骤S107、当检测到下载Android应用的下载命令时,下载Android应用的安装包;
步骤S109、在下载完成后,在Android系统上安装并启动Android应用。
具体地,通过Java的WatchService(WatchService用于监视文件系统变更)检测下载命令,该WatchService由Android系统启动,当检测到下载命令时,下载安装包并启动Android应用,Android应用启动J2me虚拟机运行相应的J2me应用程序,J2me应用程序运行在J2me虚拟机上,修改J2me虚拟机调用的图形接口,当J2me应用程序调用图形的接口时,调用到Android应用的JNI,通过JNI调用回J2me应用程序的Java层进行绘图并渲染到屏幕窗口上。
如图5所示,为本发明的实施例中J2me应用程序运行的流程图之三,与图1中所示的方法不同的是,在图5中,在步骤S101之后,该方法还包括:
步骤S111、接收按键事件;
步骤S113、将接收到的按键事件发送给Android应用存入队列,并通知J2me虚拟机;
步骤S115、J2me虚拟机获取按键事件,并发送给J2me应用程序,由J2me应用程序进行按键处理。
为了便于本领域的技术人员理解本发明的实施例,下面结合图6介绍在Android系统上运行J2me游戏的流程,具体步骤如下:
步骤S601、WatchService监听下载命令;
步骤S603、接收到下载命令后,下载游戏包;
例如通过IPTV(交互式网络电视)连接到广电提供的网络下载游戏包。
步骤S605、下载完成后,安装并启动游戏装置APP;
游戏装置APP用于提供显示窗口用于游戏的显示以及提供JNI,即游戏需要使用的图形应用程序接口。在安装并启动游戏装置APP后,将J2me游戏以一个线程的形式启动。
步骤S607、启动J2me虚拟机;
步骤S609、通过J2me虚拟机解析游戏包运行J2me游戏,然后进入步骤S611和步骤S617;
步骤S611、通过J2me虚拟机调用游戏装置APP的JNI;
步骤S613、调用游戏装置APP的图形应用程序接口;
步骤S615、将J2me游戏中的图形绘制并渲染到游戏装置APP提供的屏幕窗口中;
步骤S617、接收按键事件;
步骤S619、将接收到的按键事件发送给游戏装置APP,存入队列并通知J2me虚拟机;
步骤S621、通过J2me虚拟机获取按键事件;
步骤S623、将按键事件发送给J2me游戏,由J2me游戏进行按键事件处理。
如图6所示的流程中,Java游戏和J2me虚拟机可以保持不变,仅对原来的QT接口进行修改,整个修改的模型图如图2所示,就是将J2me虚拟机调用游戏装置APP提供的JNI,再由JNI调用游戏装置APP的图形API,将游戏中的图形绘制在屏幕窗口上,屏幕窗口由游戏装置APP来提供。
如图7所示,为本发明的实施例中运行应用程序的设备的框图,该设备700包括:启动模块701,设置成:在Android系统上启动Android应用之后,启动J2me虚拟机运行相应的J2me应用程序;
接口调用模块703,设置成:当所述J2me应用程序需要调用图形口时, 通过所述J2me虚拟机调用所述Android应用的JNI;
图形处理模块705,设置成:通过所述JNI调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中。
可选地,在本发明的另一个实施例中,所述设备还包括:
下载检测模块,设置成:检测下载所述Android应用的下载命令;
下载模块,设置成:在检测到下载所述Android应用的下载命令时,下载所述Android应用的安装包;
安装模块,设置成:在下载完成后,在Android系统上安装所述Android应用的安装包,并启动所述Android应用。
可选地,在本发明的另一个实施例中,所述图形处理模块705进一步设置成:通过所述Java本地接口调用所述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;绘制结束后,所述J2me应用程序调用刷新Refresh接口,通知渲染器Renderer渲染线程刷新所述屏幕窗口;所述Renderer渲染线程在收到刷新的请求后,将预设的图形缓冲区中的图形渲染至开放式图形库OpenGL纹理中;将纹理中的图形显示在所述屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
可选地,在本发明的另一个实施例中,所述Android应用提供的屏幕窗口是OpenGL视图窗口GLSurfaceview。
可选地,在本发明的另一个实施例中,所述设备还包括:
按键事件接收模块,设置成:在所述J2me应用程序运行时,接收按键事件;
按键事件发送模块,设置成:将接收到的所述按键事件发送给所述Android应用,存入队列并通知所述J2me虚拟机;
按键事件处理模块,设置成:通过所述J2me虚拟机获取所述按键事件,并发送给所述J2me应用程序,由所述J2me应用程序进行按键事件处理。
本发明实施例还公开了一种计算机程序,包括程序指令,当该程序指令被计算机执行时,使得该计算机可执行上述任意的运行应用程序的方法。
本发明实施例还公开了一种载有所述计算机程序的载体。
以上所述的是本发明的优选实施方式,应当指出对于本技术领域的普通人员来说,在不脱离本发明所述的原理前提下还可以作出若干改进和润饰,这些改进和润饰也在本发明的保护范围内。
工业实用性
在本发明的实施例中,Android应用启动J2me虚拟机运行相应的J2me应用程序,J2me应用程序运行在J2me虚拟机上,修改J2me虚拟机调用的图形接口,当J2me应用程序调用图形的接口时,调用到Android应用的JNI(Java本地调用接口),通过JNI调用回J2me应用程序的Java层进行绘图并渲染到屏幕窗口上,从而实现J2me应用在Android系统上正常运行。因此本发明具有很强的工业实用性。

Claims (12)

  1. 一种运行应用程序的方法,包括:
    在Android系统上启动Android应用之后,启动J2me虚拟机运行J2me应用程序;
    当所述J2me应用程序需要调用图形口时,通过所述J2me虚拟机调用所述Android应用的Java本地接口;
    通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中。
  2. 根据权利要求1所述的运行应用程序的方法,所述方法还包括:
    当检测到下载所述Android应用的下载命令时,下载所述Android应用的安装包;
    在下载完成后,在所述Android系统上安装所述Android应用,并启动所述Android应用。
  3. 根据权利要求1所述的运行应用程序的方法,其中,所述通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中的步骤包括:
    通过所述Java本地接口调用所述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;
    绘制结束后,调用刷新Refresh接口,通知渲染器Renderer渲染线程刷新所述屏幕窗口;
    在所述Renderer渲染线程在收到刷新的请求后,将预设的图形缓冲区中的图形渲染至开放式图形库OpenGL纹理中;
    将OpenGL纹理中的图形显示在所述屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
  4. 根据权利要求3所述的运行应用程序的方法,其中,所述Android应用提供的屏幕窗口是OpenGL视图窗口GLSurfaceview。
  5. 根据权利要求1~4任一项所述的运行应用程序的方法,所述方法还包 括:
    在所述J2me应用程序运行时,接收按键事件;
    将接收到的所述按键事件发送给所述Android应用,存入队列并通知所述J2me虚拟机;
    通过所述J2me虚拟机获取所述按键事件,并发送给所述J2me应用程序,由所述J2me应用程序进行按键事件处理。
  6. 一种运行应用程序的设备,包括启动模块、接口调用模块和图形处理模块,其中:
    所述启动模块设置成:在Android系统上启动Android应用之后,启动J2me虚拟机运行J2me应用程序;
    所述接口调用模块设置成:当所述J2me应用程序需要调用图形口时,通过所述J2me虚拟机调用所述Android应用的Java本地接口;
    所述图形处理模块设置成:通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中。
  7. 根据权利要求6所述的运行应用程序的设备,所述设备还包括下载检测模块、下载模块和安装模块,其中:
    所述下载检测模块设置成:检测下载所述Android应用的下载命令;
    所述下载模块设置成:在检测到下载所述Android应用的下载命令时,下载所述Android应用的安装包;
    所述安装模块设置成:在下载完成后,在Android系统上安装所述Android应用的安装包,并启动所述Android应用。
  8. 根据权利要求6所述的运行应用程序的设备,其中,所述图形处理模块设置成按照如下方式通过所述Java本地接口调用所述Android应用的图形应用程序接口,并将所述J2me应用程序中的图形绘制并渲染到所述Android应用提供的屏幕窗口中:
    通过所述Java本地接口调用所述Android应用的Java层进行图形绘制,并存储至预设的图形缓冲区中;绘制结束后,调用刷新Refresh接口,通知渲染器Renderer渲染线程刷新所述屏幕窗口;在所述Renderer渲染线程在收到 刷新的请求后,将预设的图形缓冲区中的图形渲染至开放式图形库OpenGL纹理中;将OpenGL纹理中的图形显示在所述屏幕窗口中,以形成用户最终看到的J2me应用程序运行时的画面。
  9. 根据权利要求8所述的设备,其中,所述Android应用提供的屏幕窗口是OpenGL视图窗口GLSurfaceview。
  10. 根据权利要求6~9任一项所述的运行应用程序的设备,所述设备还包括按键事件接收模块、按键事件发送模块和按键事件处理模块,其中:
    所述按键事件接收模块设置成:在所述J2me应用程序运行时,接收按键事件;
    所述按键事件发送模块设置成:将接收到的所述按键事件发送给所述Android应用,存入队列并通知所述J2me虚拟机;
    所述按键事件处理模块设置成:通过所述J2me虚拟机获取所述按键事件,并发送给所述J2me应用程序,由所述J2me应用程序进行按键事件处理。
  11. 一种计算机程序,包括程序指令,当该程序指令被计算机执行时,使得该计算机可执行权利要求1-5中任一项所述的运行应用程序的方法。
  12. 一种载有权利要求11所述计算机程序的载体。
PCT/CN2014/094434 2014-06-25 2014-12-19 一种运行应用程序的方法及设备 WO2015196756A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410295046.0 2014-06-25
CN201410295046.0A CN105204881A (zh) 2014-06-25 2014-06-25 在Android系统上运行J2me应用程序的方法及设备

Publications (1)

Publication Number Publication Date
WO2015196756A1 true WO2015196756A1 (zh) 2015-12-30

Family

ID=54936663

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/094434 WO2015196756A1 (zh) 2014-06-25 2014-12-19 一种运行应用程序的方法及设备

Country Status (2)

Country Link
CN (1) CN105204881A (zh)
WO (1) WO2015196756A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110865894A (zh) * 2019-11-22 2020-03-06 腾讯科技(深圳)有限公司 跨终端控制应用程序的方法及装置
WO2023065740A1 (zh) * 2021-10-21 2023-04-27 北京字节跳动网络技术有限公司 窗口显示方法、装置、设备和存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107818588B (zh) * 2016-09-12 2021-12-28 深圳市鸿合创新信息技术有限责任公司 Android系统基于JNI多线程调用Qt绘图的装置和方法
CN106534880A (zh) * 2016-11-28 2017-03-22 深圳Tcl数字技术有限公司 视频合成方法及装置
CN109213607B (zh) * 2017-06-30 2021-07-23 武汉斗鱼网络科技有限公司 一种多线程渲染的方法和装置
CN110109718B (zh) * 2019-03-26 2023-06-02 创新先进技术有限公司 一种应用程序接口调用方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101400165A (zh) * 2008-10-15 2009-04-01 中兴通讯股份有限公司 基于j2me规范的移动终端主菜单界面的实现方法、j2me虚拟机
CN103366780A (zh) * 2012-03-31 2013-10-23 盛乐信息技术(上海)有限公司 多媒体播放器引擎系统及其使用方法和多媒体播放器
CN103777999A (zh) * 2014-01-09 2014-05-07 深圳市星策网络科技有限公司 安卓软件模拟方法及装置
CN103870316A (zh) * 2014-04-11 2014-06-18 烽火通信科技股份有限公司 一种智能操作系统上的java虚拟机实现方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7907966B1 (en) * 2005-07-19 2011-03-15 Aol Inc. System and method for cross-platform applications on a wireless phone
CN102486693B (zh) * 2010-12-06 2014-09-03 腾讯科技(深圳)有限公司 在j2me平台上实现加速滑动效果的方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101400165A (zh) * 2008-10-15 2009-04-01 中兴通讯股份有限公司 基于j2me规范的移动终端主菜单界面的实现方法、j2me虚拟机
CN103366780A (zh) * 2012-03-31 2013-10-23 盛乐信息技术(上海)有限公司 多媒体播放器引擎系统及其使用方法和多媒体播放器
CN103777999A (zh) * 2014-01-09 2014-05-07 深圳市星策网络科技有限公司 安卓软件模拟方法及装置
CN103870316A (zh) * 2014-04-11 2014-06-18 烽火通信科技股份有限公司 一种智能操作系统上的java虚拟机实现方法

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110865894A (zh) * 2019-11-22 2020-03-06 腾讯科技(深圳)有限公司 跨终端控制应用程序的方法及装置
CN110865894B (zh) * 2019-11-22 2023-09-22 腾讯科技(深圳)有限公司 跨终端控制应用程序的方法及装置
WO2023065740A1 (zh) * 2021-10-21 2023-04-27 北京字节跳动网络技术有限公司 窗口显示方法、装置、设备和存储介质

Also Published As

Publication number Publication date
CN105204881A (zh) 2015-12-30

Similar Documents

Publication Publication Date Title
WO2015196756A1 (zh) 一种运行应用程序的方法及设备
WO2019174473A1 (zh) 用户界面渲染方法、装置及终端
US20230077467A1 (en) Card Display Method, Electronic Device, and Computer Readable Storage Medium
US10684871B2 (en) Multi-process model for cross-platform applications
CN104995601B (zh) 切换到本机网页应用程序及从本机网页应用程序切换离开
US10310722B2 (en) Method and electronic device for controlling scroll speed of content
US20150193241A1 (en) Multi-operating system mobile and other computing devices with proxy applications running under a browser
US20180275835A1 (en) System and method for on-screen graphical user interface encapsulation and reproduction
WO2017167127A1 (zh) 一种图形合成方法、窗口设置方法及系统
TW201706834A (zh) 應用程式與虛擬機器通訊連接的系統與方法
US9870239B2 (en) Method and device for running application program
WO2021196970A1 (zh) 一种创建应用快捷方式的方法、电子设备及系统
US20220325460A1 (en) Electronic apparatus and control method therefor
US20160077850A1 (en) Methods, systems, and media for binary compatibility
WO2016197590A1 (zh) 用于在终端设备上提供截屏服务的方法、装置、存储介质及设备
KR20120087967A (ko) 응용 프로그램 화상의 표시 방법 및 장치
US20140026086A1 (en) Methods and Systems for Cross-Platform Computing Applications Featuring Adaptable User Interfaces
CN106250083A (zh) 双屏双控智能终端及实现方法
CN112445545B (zh) 一种网页应用的启动方法及显示设备
CN107818588A (zh) Android系统基于JNI多线程调用Qt绘图的装置和方法
WO2018129269A1 (en) Execution of multiple applications on a device
US20160034116A1 (en) Hand-held electronic apparatus having function of activating application program of electronic apparatus, and method thereof
KR20210067785A (ko) 사용자 단말 및 그 제어 방법
WO2021052488A1 (zh) 一种信息处理方法及电子设备
EP2924563A1 (en) Methods and systems for communications between apps and virtual machines

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14895521

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14895521

Country of ref document: EP

Kind code of ref document: A1