简体   繁体   English

将Java应用程序移植到Android平台

[英]Porting java apps to Android platform

I know Java apps can be run in Android. 我知道Java应用程序可以在Android中运行。 But what I want to know is this: I have a perfectly normal Java app and I want to port it to an android platform. 但我想知道的是:我有一个完全正常的Java应用程序,我想把它移植到一个Android平台。 What changes would I need to do to my app in terms of GUI and other code to make it usable in Android? 在GUI和其他代码方面我需要对我的应用程序做些什么更改才能在Android中使用? I know Android uses XML file to control the look and feel of its app. 我知道Android使用XML文件来控制其应用程序的外观。 So would I need to change my GUI completely? 那么我需要完全改变我的GUI吗?

I just want to know the general overview of how porting may be done. 我只想知道如何进行移植的一般概述。 If anyone could point me to right resources, that would be great. 如果有人能指出我正确的资源,这将是伟大的。 Also, for your info I'm a newbie to developing android app, so please be patient with me :) 此外,对于您的信息我是开发Android应用程序的新手,所以请耐心等待我:)

Update: Both very helpful answers. 更新:两个非常有用的答案。 Thank you! 谢谢!

The short answer is that you would simply rewrite all of the GUI from scratch, for Android. 简短的回答是,你只需从头开始重写所有的GUI,对于Android。 It simply uses a completely different UI framework. 它只是使用完全不同的UI框架。 While basically all of the core Java libraries are there, Swing and AWT libraries are not. 虽然基本上所有的核心Java库都存在,但Swing和AWT库却没有。

If you are looking to translate parts of it automatically, I don't think there is any such tool. 如果您希望自动翻译部分内容,我认为没有任何此类工具。 You're going to be building a brand new Android GUI. 您将构建一个全新的Android GUI。

And really, that makes sense. 真的,这是有道理的。 These frameworks are serving reasonably different platforms and needs (desktop vs. phone). 这些框架提供了相当不同的平台和需求(桌面与电话)。 You probably need to be redesigning your app quite a bit to go from a desktop to a phone. 您可能需要重新设计您的应用程序,从桌面到手机。

Good news is the non-GUI parts ought to work as-is with no changes, unless they do something unusual. 好消息是非GUI部分应该按原样工作而不做任何更改,除非他们做了一些不寻常的事情。 You may have to package third party libraries into your project if they are used by your code. 如果代码使用了第三方库,则可能必须将它们打包到项目中。

I expect that it will be a great deal of work to do the porting, as the way that your application works with Android will be different. 我希望进行移植会有很多工作,因为您的应用程序与Android的工作方式会有所不同。

You will also have some issues, perhaps, with the fact that not everything in java is supported, as it is a mobile device, but does more than JavaME. 您也可能遇到一些问题,因为它不是Java中的所有内容,因为它是移动设备,但不仅仅是JavaME。

It would help if you could explain a bit about the application, as how much it needs to interact with the user or any other resources on the device will determine how to port and how much work is involved. 如果您能够解释一下应用程序,它将有所帮助,因为与用户或设备上的任何其他资源进行交互需要多少将决定如何移植以及涉及多少工作。

Your best bet though is to see about learning to program on the Android, and there are several good books on the subject. 你最好的选择是看看如何在Android上学习编程,并且有很多关于这个主题的好书。 I got one from Manning publications that I found helpful. 我从Manning的出版物中得到了一份我认为有用的出版物。

You may want to look at the comments in this article, as I think it would be a good starting point for you on what may need to be changed: http://www.anddev.org/problem_in_android_project_conversion-t1633.html 您可能希望查看本文中的注释,因为我认为这对于您可能需要更改的内容是一个很好的起点: http//www.anddev.org/problem_in_android_project_conversion-t1633.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM