将黑莓应用程序代码移植到 Android 平台
我有一个使用 JAVA 以及 Blackberry(RIM) 特定 API 编写的 Blackberry 库。我想将相同的库移植到 Android 平台,而不进行任何代码更改并使其运行。
在这里,我正在寻找实现它的最佳方法。
任何交叉编译器/交叉框架都可用于使我的黑莓在 Android 平台上运行。认为这将使我的工作变得轻松;)
请分享您对此的意见。 提前致谢。
I have an Blackberry library written using JAVA as well Blackberry(RIM) specific API's. I would like to port the same library in to Android platform without making any code changes and make it run.
Here i am looking for the best way to achieve it
Any cross compiler/cross framework is available for making my Blackberry run on Android platform.Thinking this would make my job easy ;)
Please share your inputs on this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不能那样做。 AFAIK,Blackberry 使用 J2ME 技术(这里可能是错误的)。 Android 系统完全是按照其他原则构建的。您必须学习 Android 才能了解如何构建 GUI、如何处理后台任务以及存储数据的位置。对不起。
从应用程序基础知识开始。
You can't do that. AFAIK, Blackberry uses J2ME technologies(can be wrong here). Android system is built in absolutely other principles. You have got to learn android in order to understand how to build GUI, how to process with background tasks and where you store your data. Sorry.
Start with application fundamentals.
如果移植如此简单,那么很多开发人员就会失业。
您不必重写整个应用程序,但肯定必须完成相当多的更改。如果您有一个干净的设计,您可能能够按原样重用大量代码。否则事情会变得更加复杂。对于 RIM API,首先编写接口类(“RIMXyz 实现 IntrfXyz”)可能是一个好主意,其中包含您使用 RIM-API 的所有函数调用。然后您可以使用“AndrXyz Implements IntrfXyz”编写Android API 类。将依赖于 RIM 的内容放在单独的外部库中,并对依赖于 android 的内容执行相同的操作。然后您可以拥有一个 RIM-prj 和一个 Android-prj,每个仅链接到依赖类和可重用类。这样你就可以很好地构建你的移植项目。
此外,应用程序的“顶层”肯定也必须更改,因为您必须使用 Android 中的“活动”类才能运行任何内容。这是我看到的两个方面。
我希望这是可以理解的,有点难以用几句话来表达......
我已经启动了一个 Android/Java 小程序的跨平台项目,这就是我所做的。有用。 ;-)
If porting was that easy, a lot of developer would be out of work.
You will not have to rewrite the whole application, but surely there must be quite a few changes done. If you have a clean design, you might be able to reuse a lot of code as it is. Otherwise it will get more complicated. For the RIM API, it might be a good idea to write interface-classes first ("RIMXyz implements IntrfXyz"), that have all the function-call that you use of the RIM-API. Then you can write the Android API classes using "AndrXyz implements IntrfXyz". Put the RIM-dependend stuff in a separate external lib, and do the same with the android-dependent stuff. Then you can have a RIM-prj and an Android-prj, each only linking to the dependent classes and the reusable classes. That way you could structure you porting project quite nicely.
Also the "top" end of the application surely has to change, because you have to use the "activity"-class in Android to get anything running. Those are the two aspects I see.
I hope this is understandable, a bit hard to put it in a few words...
I have started a cross-platform project for Android/Java applet, and this is how I've done it. It works. ;-)
如果不重写一些代码,您就无法做到这一点。如果您可以告诉我们有关您正在使用的 RIM API 中的类的更多信息,您可能会得到一些关于要使用 Android API 中的哪些类的具体答案。
You cannot do this without some code rewrite. If you can tell us more about the classes in the RIM API that you are using, you might get some specific answers as to what classes from the Android API to use.
您应该在 android api 中找到类似的函数来替换 RIM API 调用并使用抽象工厂设计模式重构您的代码。 (http://sourcemaking.com/design_patterns/abstract_factory)
You should find similar functions in android api to replace RIM API invocations and refactor your code using for example Abstract Factory design pattern. (http://sourcemaking.com/design_patterns/abstract_factory)