从 J2ME 迁移到 Android

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/64745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:04:49  来源:igfitidea点击:

Moving to Android from J2ME

androidjava-memobile

提问by

Coming from J2MEprogramming are there any similarities that would make it easy to adapt to Android API. Or is Android APIcompletely different from the J2MEway of programming mobile apps.

来自J2ME编程的任何相似之处都可以使其易于适应Android API. 或者Android API完全不同于J2ME编写移动应用程序的方式。

回答by Alexandre Hauser

Actually the Android API is much more powerful than the J2ME.

实际上,Android API 比 J2ME 强大得多。

It is much easier to create an application for the Android.

为 Android 创建应用程序要容易得多。

Using the J2ME you are limited to simple forms due to the absent of swing-like libraries (though now there exists a library called LWUIT, avoiding the need to recreate from scratch a swing-like library).

使用 J2ME,由于缺少类似 Swing 的库(尽管现在有一个名为 LWUIT 的库,避免了从头开始重新创建类似 Swing 的库),因此您只能使用简单的形式。

In Android you will be able to create complex form very quickly, and software package for the android SDK is easy to install (while in J2ME you have to install the wireless development toolkit from sun, or install one of Nokia's, Samsung's or SonyEricsson's... it gets a bit confusing sometimes).

在Android中,您将能够非常快速地创建复杂的表单,并且Android SDK的软件包易于安装(而在J2ME中,您必须安装sun的无线开发工具包,或者安装诺基亚、三星或索尼爱立信的其中之一。 . 有时会有点混乱)。

The things I had to change when switching from j2me to android were:

从 j2me 切换到 android 时我必须改变的事情是:

1/ The font and graphics class is easier to use on j2me. The API is more thorough on Android, but also more complicated.

1/字体和图形类在j2me上更容易使用。该 API 在 Android 上更全面,但也更复杂。

2/ If you are used to the database storage of j2me (RecordStore), well you can forget it in Android. You will have to use a SQL-like databased, so be prepared to rethink your data model.

2/如果你习惯了j2me(RecordStore)的数据库存储,那么在Android中你可以忘记它。您将不得不使用类似 SQL 的数据库,因此准备重新考虑您的数据模型。

回答by haseman

I've also found the path from Java ME to Android to be pretty simple. Here are a few things I've noticed:

我还发现从 Java ME 到 Android 的路径非常简单。以下是我注意到的一些事情:

  1. There is ONE ui draw thread in Android. You have to be aware of the difference between calling postInvalidateand invalidateon Views to force them to update.

  2. The actual bit-wise graphic manipulation is very similar. I was able to port large amounts of custom J2ME draw code by writing a few shims for drawRectand drawImage.

  3. Android's UI library is much more extensive, much less useless, and much more complicated than Java ME's

  4. Threadwise, you have to be much more careful about thread saftey with Android. In Java ME you can get away with not making methods synchronous or variables volatile most of the time. Not so in Android.

  1. Android 中有一个 ui 绘制线程。您必须了解调用postInvalidateinvalidate打开视图以强制它们更新之间的区别。

  2. 实际的按位图形操作非常相似。通过为drawRect和编写一些垫片,我能够移植大量自定义 J2ME 绘图代码drawImage

  3. Android 的 UI 库比 Java ME 的要广泛得多,无用得多,也复杂得多

  4. Threadwise,您必须更加注意 Android 的线程安全性。在 Java ME 中,您可以避免大多数时间不使方法同步或变量可变。在 Android 中并非如此。

I will say, on the whole, that Android's UI library fails a critical test. I call this the "roll my own" test.

我会说,总的来说,Android 的 UI 库没有通过严格的测试。我称之为“自己动手”测试。

Your UI library fails this test if it takes me longer to complete a detailed task task (say, changing the background on one individual menu item) than it would take me two write my ownMenu from scratch. Android fails the "roll your own" test by a factor of 3 or 4. In fact, if you look, the majority of the questions on this website are "How do I make the Android UI toolkit do my bidding?" questions.

如果我完成一项详细的任务任务(例如更改单个菜单项的背景)所需的时间比我从头开始编写自己的菜单所需的时间更长,则您的 UI 库无法通过此测试。Android 在“自己动手”测试中失败了 3 或 4 倍。事实上,如果你看一下,这个网站上的大多数问题都是“我如何让 Android UI 工具包满足我的要求?” 问题。

Android is an amazing platform and it has been worth every frustrating moment I've sunk into it. It is, however, a young platform, and needs some serious work in times to come.

Android 是一个了不起的平台,我沉浸在它的每一个令人沮丧的时刻都是值得的。然而,它是一个年轻的平台,未来需要一些认真的工作。

回答by peregrine

A good start would be to watch the Android architecture videos and look at some of the documentation.

一个好的开始是观看 Android 架构视频并查看一些文档。

http://www.youtube.com/view_play_list?p=586D322B5E2764CFhttp://code.google.com/android/what-is-android.html

http://www.youtube.com/view_play_list?p=586D322B5E2764CF http://code.google.com/android/what-is-android.html

Google is very good about documenting. From what I've heard Android very very similar to J2ME in its goals. It may be slightly different in programming style and structure but if you have J2ME experience you should be more then ready to move on to Android.

谷歌非常擅长记录。据我所知,Android 的目标与 J2ME 非常相似。它在编程风格和结构上可能略有不同,但如果您有 J2ME 经验,那么您应该已经准备好转向 Android。

Good Luck!!!

祝你好运!!!

回答by michael aubert

Well, you may not actually need to adapt.

好吧,您实际上可能不需要适应。

There is a good chance that a J2ME stack will become available for Android before long since Android is not supposed to become as restrictive of third-party runtimes as the iPhone.

J2ME 堆栈很有可能在不久之后可用于 Android,因为 Android 不应该像 iPhone 那样限制第三方运行时。

I know one guy who has been working on just that: http://justanapplication.wordpress.com/

我认识一个一直致力于此的人:http: //justanapplication.wordpress.com/

Now, of course, that doesn't mean you shouldn't have a look at the Android APIs and application lifecycle.

现在,当然,这并不意味着您不应该查看 Android API 和应用程序生命周期。