开发者

Sharing Android code (Is there really no way to do this?)

I have a particular collection of code along with some XML files that I need to share with every application I will make.

At the moment I can't because as far as I am aware there is no way to do this. This seems like a massive oversight by the development team.

If开发者_运维知识库 the code needs changing, I have to change it in every app that I create - and will create in the future.

Are there any ways to share code in android yet?

I am using Eclipse for development.


You can create an Android library project. The TicTacToeMain sample project in the SDK shows how to reference your created library project.


You can reference a third party JAR like you would any Java project. Or are you talking about something else?

As for sharing XML files, I think you may have to just copy them to each project, but I'm not certain about that.


You can reuse particular Activity classes in applications other than the one they were installed with. Is that sufficient?

To do that, you need to set android:exported="true" in the Activity's declaration in AndroidManifest.xml. http://developer.android.com/guide/topics/manifest/activity-element.html has more details.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜