简体   繁体   English

Android installLocation和BOOT_COMPLETED

[英]Android installLocation and BOOT_COMPLETED

I have an Android app that uses the AlarmService. 我有一个使用AlarmService的Android应用程序。 According to the docs, I should not allow installing/moving this app to external storage. 根据文档,我不应该允许安装/移动此应用程序到外部存储。 Users, however, do not understand this (probably due to very little internal storage on some devices) - and demand the option to install on external storage (via low-star ratings). 但是,用户不理解这一点(可能是由于某些设备上的内部存储空间很小) - 并要求选择在外部存储上安装(通过低星级评级)。

I need to re-register the alarms on boot and have a BroadcastReceiver listening for BOOT_COMPLETED. 我需要在启动时重新注册警报并让BroadcastReceiver监听BOOT_COMPLETED。 This, however, is not called for applications installed on the sd-card since this is not yet mounted then the intent is fired. 但是,对于安装在SD卡上的应用程序,不会调用此方法,因为尚未安装该应用程序,因此会触发该意图。 EXTERNAL_APPLICATIONS_AVAILABLE is, sadly, also not -- hence I get no notification that we have booted and thus have no change to re-set the alarms. 遗憾的是,EXTERNAL_APPLICATIONS_AVAILABLE也没有 - 因此我没有得到启动的通知,因此没有更改重新设置警报。

Is there any way around this predicament? 这种困境有什么办法吗?

Sorry, no, this is not something you can get around. 对不起,不,这不是你可以解决的问题。 This is why we say you should not put apps on SD card that do such things. 这就是为什么我们说你不应该把应用程序放在SD卡上做这些事情。

Worst-case option: create a second app (that would be light-weight enough to not matter that it cannot be installed on the SD Card) that will listen for the BOOT_COMPLETED event on start-up and will trigger your main app when it is available. 最坏情况选项:创建第二个应用程序(重量轻,无论它无法安装在SD卡上),它将在启动时监听BOOT_COMPLETED事件,并在它启动时触发您的主应用程序可用。 Tell the user that they have to install that to get your app to work when it is installed to the SD Card. 告诉用户他们必须安装它才能使您的应用程序在安装到SD卡时正常工作。

If there is a event/trigger that occurs when your app is moved to the SD Card, you could pop up a notification telling them to grab this second app from the market. 如果您的应用程序移动到SD卡时发生事件/触发器,您可以弹出通知,告诉他们从市场上抓取第二个应用程序。

I understand that this is a terrible option but it would work if you are desperate. 我知道这是一个可怕的选择,但如果你绝望,它会奏效。

Well, if the reason the users are asking for the move to SD is because of size constraints (ie your app requires a large amount of space) then I'd suggest storing the data your app uses on the SD card but restricting the app install location to internal storage. 好吧,如果用户要求转移到SD的原因是由于尺寸限制(即您的应用需要大量空间),那么我建议存储您的应用在SD卡上使用的数据但限制应用安装位置到内部存储。

Explain to your users if they are asking for things that don't make sense or are technically infeasible on the platform you're developing for: if they continue to ask then I'd say just ignore them. 向您的用户解释他们是否要求您正在开发的平台上没有意义或在技术上不可行的事情:如果他们继续问我那么我会说只是忽略它们。 Your star rating will take a hit but agonizing over that won't fix the problem. 你的星级评分会受到打击,但令人痛苦的是,这无法解决问题。

You already have a few fine answers to the question -- this is to clarify, correct, or otherwise address points you bring up in your comments. 您已经对问题有了一些很好的答案 - 这是为了澄清,纠正或以其他方式解决您在评论中提出的要点。

users want this if the app is just a few MB 如果应用程序只有几MB,用户想要这个

Some day, users might also decide they want your app to be pink, or in 3D, or be able to interface with their Kenmore dishwasher, none of which may be in your plans. 有一天,用户可能还会决定他们希望您的应用程序是粉红色的,或3D的,或者能够与他们的Kenmore洗碗机接口,这些都不在您的计划中。 So, I suggest that you come up with a system for communicating with your customers to explain why your app is not pink, not 3D, not dishwasher-ready, and not stored on external storage. 因此,我建议您提出一个与客户沟通的系统,以解释为什么您的应用不是粉红色,不是3D,不是洗碗机,而是存储在外部存储上。

Now, I will readily admit that the Android Market should be providing more help with this sort of communication channel (eg, replies to comments). 现在,我很乐意承认Android Market应该为这种沟通渠道提供更多帮助(例如,回复评论)。

Coming up with long technical explanations (== excuses) is just not the right answer 提出长期技术解释(==借口)并不是正确的答案

You are entirely welcome to your opinion. 非常欢迎您的意见。 I hope you like pink. 我希望你喜欢粉红色。

What were they thinking, designing an alarm service that only works until next reboot? 他们在想什么,设计一个只能在下次重启之前工作的闹钟服务?

They did not want applications registering alarms and more or less forgetting about them. 他们不希望应用程序注册警报,或多或少地忘记它们。 They wanted users to be able to start with as clean of a slate as possible after a reboot. 他们希望用户能够在重新启动后尽可能以干净的方式开始。

Well -- even a "potent" phone like the HTC Desire ships with only 150 MB of user space (en.wikipedia.org/wiki/HTC_Desire). 好吧 - 即使像HTC Desire这样的“强效”手机也只有150 MB的用户空间(en.wikipedia.org/wiki/HTC_Desire)。 That's pathetic. 那太可悲了。

Feel free to take this up with HTC. 随意使用HTC。 I do not believe that they regularly read StackOverflow. 我不相信他们经常阅读StackOverflow。

Android's solution to installing apps here is at best half-hearted Android在这里安装应用程序的解决方案充其量只是半心半意

No, it's fundamentally limited by the nature of USB Mass Storage Mode, among other things. 不,它基本上受USB大容量存储模式的性质限制。 The long-term solution is to eliminate the division between internal and external storage, a process that is underway already in Honeycomb. 长期解决方案是消除内部和外部存储之间的划分,这是Honeycomb中正在进行的一个过程。

and users (normal people using phones that are not engineers) are left completely uneducated in the UI 用户(使用不是工程师的电话的普通人)在UI中完全没有受过教育

I will agree that something more could be done to help clue users in to why an app might not be movable to external storage. 我同意可以采取更多措施来帮助用户了解为什么应用程序可能无法移动到外部存储。

One wonders why the Android team has added the "move to sd card" option right there in the app settings since this does not really work for a great deal of the apps out there, but fuels an unreasonable remand for features that's not implementable on the platform 人们想知道为什么Android团队在应用程序设置中添加了“移动到SD卡”选项,因为这对于那里的大量应用程序并不真正起作用,但是对于那些无法实现的功能造成了不合理的还押。平台

It is mostly there for games, the major category of application that have substantial storage needs. 它主要用于游戏,这是具有大量存储需求的主要应用类别。 They also tend not to need the features for which apps-on-external-storage fails to work especially well. 他们也往往不需要外部存储应用程序无法正常工作的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM