开发者

Set install location for Android 1.6?

开发者 https://www.devze.com 2023-01-08 05:16 出处:网络
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.

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?


In your manifest:

  • In <manifest>, add "android:installLocation="preferExternal"
  • Keep your current 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.


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:

error: No resource identifier found for attribute 'installLocation' in 
package 'android'

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:

Attribute minSdkVersion (4) is lower than the project target API level (8)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号