向android市场发布依赖性(Publishing a dependancy to android market)

编程入门 行业动态 更新时间:2024-10-15 20:16:26
向android市场发布依赖性(Publishing a dependancy to android market)

我正在为我的公司开发一个连接到蓝牙视频设备的Android应用程序。 我们正在使用的第三方公司构建了蓝牙摄像头并构建了一个服务(Android服务),我们的应用程序连接到我们用来与摄像头交互的服务。 该公司不希望我们访问源代码,因此他们以服务的形式创建了一个SDK,该服务必须安装在手机上才能与相机进行交互。 如果未安装该服务(只是一个APK),我们的应用程序将无法运行。

但是,我们可以检测到该服务不存在,然后继续获取apk,现在我们正在尝试找出最佳方法。 是否有可能我们可以让另一家公司在Android市场上发布这项服务,即使它没有ui,安装时似乎什么都不做? 你可以在Android市场上放一些东西,而不是在正常的过滤器下显示它(意味着到达它的唯一方法是直接进入页面吗?)。 我不认为他们希望人们安装它,因为第三方公司确实销售自己的相机(几乎与他们为我们制造的相机),并且他们在市场上有应用程序。

另一种可能性是我们自己托管文件并在用户首次安装应用程序时下载它。但问题是我们必须弄清楚我们自己的升级方法。

有没有人有这方面的经验或有任何想法可能是处理我们的情况的最佳方法?

I am working on an android application for my company which connects to a bluetooth video device. A 3rd party company that we are working with built the bluetooth camera and have built a service (android service) that our app connects to which we use to interact with the camera. This company did not want us to have access to the source code so they created an SDK in the form of a service which must be installed on the phone for interaction with the camera to take place. If the service (which is just an APK) is not installed our app won't work.

However, we can detect that the service does not exist and then proceed to get the apk and now we are trying to figure out the best way to do that. Is it possible we could have the other company publish this service in the android market even though it has no ui and when installed would appear to do nothing? Can you put something in the android market and not have it show up under normal filters (meaning the only way to get to it would be by going directly to the page?). I don't think they want people installing it since the 3rd party company does sell there own camera (almost the same as the one they make for us) and they have applications in the market for it.

The other possibility is we host the file ourselves and download it when the user first installs the app.. The problem with that though is we have to figure out our own methodology for upgrades.

Does anyone have experience with this or have any ideas what might be the best way to handle our situation?

最满意答案

如果您遇到这种情况,我建议您从公司服务器托管apk。

I ended up solving the issue by bundling the service apk under the /assets folder of my application. You can read from that data as an inputstream and write it to sdcard where you can then launch the intent to have the apk installed. All the user has to do is click Install (as long as they have 3rd party apps allowed, which they will since our app is not in the market either.

public static final String SERVICE_APK_FILENAME = "SomeService.apk"; protected void installService() { File apk = getServiceFileOnDisk(); if (!apk.exists()) { try { writeServiceToFile(); } catch (Exception ex) { Log.e(TAG, "", ex); return; } } Intent promptInstall = new Intent(Intent.ACTION_VIEW); promptInstall.setDataAndType(Uri.fromFile(getServiceFileOnDisk()), "application/vnd.android.package-archive"); startActivityForResult(promptInstall, REQUEST_INSTALL_APK); } protected File getServiceFileOnDisk() { return new File(Util.getAppStorageDirectory(this), SERVICE_APK_FILENAME); } protected void writeServiceToFile() throws IOException { File apk = getServiceFileOnDisk(); InputStream assetIs = mAssetMgr.open(SERVICE_APK_FILENAME); OutputStream out = new FileOutputStream(apk); // Transfer bytes from in to out byte[] buf = new byte[4 * 1024]; int len; while ((len = assetIs.read(buf)) > 0) { out.write(buf, 0, len); } assetIs.close(); out.close(); }

So what happens is when the app first launches I check if the service needs to be installed (or upgraded).. That code is a bit more complex and outside the scope of what I'm doing here so I didn't post it. But if I determine the service needs to be installed I prompt the user with a dialog and if they click ok I then call the installService method shown above.

更多推荐

本文发布于:2023-08-06 23:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456584.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:依赖性   市场   android   market   dependancy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!