设置Android 1.6的安装位置?
我正在编写一个与 Android 1.6 兼容的应用程序,但我想为运行 Android 2.2 的用户提供将应用程序安装移动到 SD 卡的选项。
如何为 1.6 编译我的应用程序,但仍允许 2.2 用户将其安装到他们的 SD 上?
I'm writing an application that is compatible with Android 1.6, but I would like to give users running Android 2.2 the option of moving the application installation to their sd card.
How can I compile my application for 1.6, but still allow 2.2 users to install it to their sd?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在清单中:
中,添加“android:installLocation="preferExternal
”,uses-sdk
保留为“
"然后转到 Project > Properties > Android(左侧),将构建目标更改为 2.2,一切就完成了。
您的项目将使用 2.2 构建(但仍然只需要 1.6),但运行 1.6 的设备将简单地忽略清单中新的“installLocation”设置,请注意不要在实际代码中添加任何 2.2 引入的材料,因为编译器。将不再抓住它。
In your manifest:
<manifest>
, add "android:installLocation="preferExternal
"uses-sdk
as "<uses-sdk android:minSdkVersion="4">
"Then go to Project > Properties > Android (on the left), change the build target to 2.2, and you're all set.
Your project will build using 2.2 (but still only requires 1.6), but devices running 1.6 will simply ignore your new "installLocation" setting in the manifest. Just be careful not to add any 2.2-introduced material in your actual code, since the compiler will no longer catch it.
这并不像开发人员指南所建议的那么无缝。
首先,当清单中存在 installLocation 并且构建目标设置为 2.2 以外的任何值时,应用程序不会构建:
因此,为了通过将构建目标设置为 1.6 来测试向后兼容性,还必须编辑清单。
其次,一旦构建目标设置为 2.2,我就无法选择 API 级别较低的模拟器进行测试。不过,我仍然可以手动启动 1.6 模拟器并在其上运行应用程序,但我很好奇如果我的构建目标是 2.2(即使 minSdkVersion=4),我的应用程序是否会出现在 1.6 设备的 Android Market 上。我没有实际设备可以测试。有人可以确认这不会影响市场上的可用性吗?
最后,这个警告仍然存在:
This is not quite as seamless as the developer guide suggests.
First, the application does not build when the installLocation is present in the manifest and the build target is set to anything other than 2.2:
So in order to test backwards-compatibililty by setting the build target to 1.6, the manifest must be edited as well.
Second, once the build target is set to 2.2, I don't get to pick an emulator with a lower API level for testing. I can still manually start an 1.6 emulator and run the app on it, though, but I am curious if my app will appear on Android Market for 1.6 devices if my build target is 2.2 (even though minSdkVersion=4). I don't have an actual device to test. Can someone confirm that this does not affect the availability on the market?
Lastly, this warning remains: