How to enable app being moved to sdcard (and support android < 2.2 still)?

后端 未结 4 709
鱼传尺愫
鱼传尺愫 2021-02-13 15:03

How can i enable my app to be moved to the sdcard?

-edited the title in order to make question more relevant to the answers given.

4条回答
  •  隐瞒了意图╮
    2021-02-13 15:47

    You can also set the android:installLocation and still target to Android 1.6.

    In your AndroidManifest.xml you have to insert the min SDK Version like that

        
    

    This will make sure your application works only on Android 1.6 and higher. This will of course, cause an compiler error in your Eclipse project sapce. That's because the 1.6 SDK don't know about the android:installLocation. To fix this, right-click on your Project in the Eclipse Project space (assuming you're using Eclipse, don't know how it works in other IDEs or with Ant build) then go to the "Android" Option and select "Project Build Target" to Android 2.2.

    This will remove the error shown above and you can compiler/export your APK file. This way the APK will work on Android 1.6-2.1 as usual and on Android 2.2 it will enable you to use SD card to install/move the app too.

    However a Word of Warning: This can be a source of incompatibility, if you're not careful. So an increased testing phase is required, because you won't notice directly if you use an 2.x feature, because Eclipse wont show it as error, because it uses the Android 2.2 SDK as reference.

    So you basically have 2 choices: 1. Only do the steps above when you're exporting/signing your app (i.e. just before you're about to publish this new version) and then set it back or 2. Extensively test your Applications on 1.6 Device or Emulator and see if it crashes at any point, because the App uses a feature only available on newer OS' than 1.6.

    Depending on the compexity of your application, the first one is usually the safer one, however bears the risk that you forgot to do it once. This would have the consequence that for this one update the user won't have the possibility to install it on SD card. Choice 2 has the problem, that if you don't test everything well enough, you App may suddenly ForceClose when an Android 1.6 devices try to call features/functions only available in 2.x.

提交回复
热议问题