Porting Android app to run on BlackBerry 10 Android runtime - Google Maps

坚强是说给别人听的谎言 提交于 2019-12-04 05:04:18

问题


I have an Android app that I want to make available to BlackBerry 10 users by porting for the BB Android Runtime. The only stumbling block is my Android app uses Google Maps API (com.google.android.maps) which the runtime doesn't support. The map screen is only a small feature of the app and I'm happy to disable it for BlackBerry users, but is this possible? I don't want to maintain two copies of the application, can I somehow code the one app so that the conversion to BAR works but the maps are still available on Android?


回答1:


The map screen is only a small feature of the app and I'm happy to disable it for BlackBerry users, but is this possible?

You can add android:required="false" to your <uses-library> element, and detect at runtime whether you have the MapActivity class before trying to link to your map. Here is a sample app demonstrating this.

In theory, BB's packager should allow this. Whether it does or not, I cannot say.




回答2:


Turns out what I want to do is not possible - any references to Google Maps API has to be removed completely from the app. See response from the BlackBerry forums :

"No, it's not going to work. Save yourself time trying to find a fix, and just copy your project to a new one and make the needed changes for blackberry. If you are using source control, then you can try branching off for that probject.

By the way. If you want Google maps in your app, it can be done using a webview and Google's javascript API."




回答3:


You have to remove all references to MapView or MapActivity in the Android code for you to be able to port over to BlackBerry. I'd recommend going one step further: replace MapView with WebView and load the Google Maps mobile site with Javascript. More info can be found here:

http://developer.blackberry.com/android/apisupport/apisupport_mapping_support.html

Yes, that will result in maintaining two versions of your app, but it will provide a better experience for BlackBerry users.

Hope this helps.



来源:https://stackoverflow.com/questions/14648231/porting-android-app-to-run-on-blackberry-10-android-runtime-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!