Android 与 Blackberry 开发(可重用代码?)

发布于 2025-01-05 06:43:18 字数 261 浏览 0 评论 0原文

我知道这个问题已经以某种形式、这样或那样地出现了。然而,其中很多都已经过时了,所以我想我会再问一次,并询问这个问题的真正原因。

Android和BB的开发都可以通过Java来完成,虽然Android在Java SDK之上添加了很多类和功能,但Blackberry似乎依赖于Java的J2ME。如果我编写一个针对两个平台的应用程序,特别是从媒体播放的角度来看,那么两个平台之间可以重用多少代码?根据记录,基于 PhoneGap 的应用程序是不可能的(特别是由于 BB 实施了 Webkit)。

I know this question has come up in some form, one way or another. However, a lot of them are outdated, so I figured I'd ask again plus also ask the real reason for this question.

Both Android and BB development can be accomplished via Java, and while Android adds a lot of classes and functionality on top of the Java SDK, Blackberry seems to rely on Java's J2ME. If I write an application that targets both platforms, especially from a media playback perspective, how much code reuse can I expect between both platforms? For the record, a PhoneGap based app is not possible (esp due to BB's implementation of Webkit).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆流 2025-01-12 06:43:18

恕我直言,不要期望重用大量代码。这些是您可能无法共享代码的领域:UI、网络、安全、正则表达式、java 1.4+ 类。

另外,android 不需要自制的事件系统。所有的活动都可以相互通信,或者你可以使用服务......黑莓没有这些。

我使用这两个平台已经有一段时间了,我只分享这个想法......每个平台的实现几乎都是特定的。

IMHO, don't expect to reuse tons of code. These are the areas where you probably can't share code: UI, network, security, regex, java 1.4+ classes.

Also, android doesn't need a self made eventing system. All activities can talk with each other, or you can use services... BlackBerry doesn't have any of this.

I've being working with these two platforms for a while, and I only share the idea... The implementation is almost specific for each one.

神魇的王 2025-01-12 06:43:18

我正在开发一个大型应用程序,该应用程序在 Android、BlackBerry、MIDP 和 J2SE(即桌面 Java)之间共享通用代码。我想说,给定平台上大约 75% 的代码是通用代码。

优点:

  • 需要开发/测试大量代码。这是一个巨大的积极因素!
  • 如果您决定移植到其他平台,那么您已经完成了大部分工作。

缺点:

  • 公共代码中的 java 1.3 兼容性受到限制(无注释、集合等)。
  • UI 差异可能会很麻烦,尤其是对于不同的事件模型。 MVC 是您的朋友 - 至少您可以共享模型!
  • 您需要为所有需要与公共代码交互的依赖于平台的内容编写包装类。这是额外的代码,如果您不共享代码,则无需编写这些代码。

它是否值得你花时间取决于一些事情......我至少会考虑以下问题:

  1. 该项目有多大? (更大=更多地共享代码。)
  2. 您的核心功能有多少实际上是可共享的?您提到媒体播放 - 如果这将占您应用程序代码的 80%,那么可能不值得花费精力来设置共享代码。
  3. 您对不同平台的熟悉程度如何? (更熟悉=更了解潜在的陷阱=更有可能知道应该共享哪些代码以及如何构建它。)

I work on a large app which shares common code across Android, BlackBerry, MIDP, and J2SE (i.e. Desktop Java). I would say that about 75% of the code on a given platform is common code.

Pros:

  • One lot of code to develop/test. This is a huge positive!
  • If you ever decide to port to other platforms, you've already done most of it.

Cons:

  • You're limited to java 1.3 compatibility in the common code (no annotations, collections, etc).
  • UI differences can be a pain, particularly with the different event models. MVC is your friend here - at least you can share the model!
  • You'll want to write wrapper classes for all the platform-dependent stuff which needs to interact with your common code. This is extra code which you wouldn't have to write if you weren't code sharing.

Whether it's going to be worth your while depends on a few things... I'd at least think about the following:

  1. How large is the project? (Larger = more of a case for sharing code.)
  2. How much of your core functionality is realistically going to be shareable? You mention media playback - if that's going to be 80% of your app's code then it's probably not worth the effort to set up shared code.
  3. How familiar are you with the different platforms? (More familiar = more idea of the potential pitfalls = more likely to know which code should be shared and how to structure it.)
请恋爱 2025-01-12 06:43:18

Android 和 Blackberry 代码可以重复使用。我以前做过并且效果很好。确实存在一些小的差异。我记不清了,但有几个

  • Https / Http api 调用是不同的。因此,您需要对两者进行稍微不同的编码。
  • 黑莓编译器不喜欢未使用的导入

除了这些之外,我想你会没事的。但是,是的,尝试一下可以节省很多时间。

Android and Blackberry code can be reused. I have done it before and works beautifully. A few small differences do exist. I cant remember them all, but a few

  • Https / Http api calls are different. So you need to code them a bit differently for both.
  • Blackberry compiler does not like unused imports

Other than these, I think you will be ok. But yes, do give it a shot saves a lot of time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文