跨平台的Java? Android和桌面桌面、平台、Java、Android

2023-09-06 03:37:51 作者:天涯浪人

我们有一个台式机/网络Java应用程序,也进入Android开发。

We have a desktop/web java application and also getting into Android development.

在理想情况下,我们想创建一个应用程序,桌面和Android同时运行。

Ideally we would like one app that runs both on desktop and android.

这是我们可以告诉,这不是多大可能在Android上正常运行Java应用程序。但是,不知道是否可以做其他的方式?也就是说,在桌面上运行Android应用程序很容易(无需用户安装SDK或Android仿真器)?

From what we can tell, it's not much possible to run normal java apps on android. But wondering if it can do it the other way? That is, run android apps easily on the desktop (without the user install the sdk or android emulator)?

在一个prefect世界,我们希望一个应用程序两个平台。现实虽然它看起来像我们将必须有一个应用程序有两个前端?

In a prefect world we'd like one app for both platforms. Realistically though it seems like we're going to have to have one app with two front ends?

推荐答案

基本上你会打破你的应用程序成至少三个项目......为Android特有的东西,一款使用Android操作系统的项目,一体台式机的Java项目特定于桌面东西,再一个Java库项目的公共功能(其中大部分的实际工作中应该做的)。然后,你可以在Android和桌面项目既重用库项目。

Basically you would break your application into at least three projects... one Android project for the Android-specific stuff, one desktop Java project for the desktop-specific stuff and then one Java library project for the common functionality (where most of your real work should be done). Then you can reuse the library project in both the Android and desktop projects.

有什么在Android环境中使用,所以你需要密切关注的是,但也有一些很好的设计,你应该没有问题,分享您的项目之间颇有几分code有所不同。

There are some differences in what is available in the Android environment so you will need to keep an eye on that, but with some good design you should have no problems sharing quite a bit of code between your projects.

祝你好运。