开发者

Android SDK - Other ways?

开发者 https://www.devze.com 2022-12-28 14:31 出处:网络
If I needed to build an android SDK that other developers can integrate into their android apps, is jarring my SDK the only way to go about it? As far as I have learnt, jarring has the following consi

If I needed to build an android SDK that other developers can integrate into their android apps, is jarring my SDK the only way to go about it? As far as I have learnt, jarring has the following considerations:

  1. If your app uses a layou开发者_开发知识库t, then you have to create it programmatically. Since jar files cant carry any resources.
  2. The jar will needs to be placed in the lib/assets folder and added to the build path (in Eclipse) -- Learnt here: Android - Invoke activity from within jar
  3. The main app will have to create an Intent object and specify the package and class name in the jar to start the activity.

Any one have other ideas of going about any of the above steps?

Thanks George


Creating a JAR is, in my opinion, a very bad decision. Android has specific features just for the kind of thing you're looking for. If your JAR:

  • provides some sort of (structured) data to be used in other applications, use a ContentProvider;
  • does some backround processing and makes that processing's results available to other applications, use a Service;
  • provides an Activity that gets some input from the user (or shows some information about something), eventually processes it and returns it to the calling Activity, just create that Activity and any application will be able to start your Activity as long as it's installed on the phone.

If you use one of the three solutions above, third party apps will be able to probe for whether your application is installed and, if not, prompt the user to install it. Only if your application does not fall into one of the three bullet points mentioned above should you use a JAR. Otherwise, using a ContentProvider, Service or Activity provides:

  • More standardized interaction between components
  • Better maintainability -- if you update your SDK you won't have to call everyone who uses it and tell them to upgrade.
  • No duplication -- if you were to provide a JAR and multiple applications that use it would be installed on a device, multiple copies of the JAR would be present on that device, thus using more memory than it has to. If you provide one of the three components mentioned above, one copy will satisfy all applications that need to use it.

Again, these components are specifically designed and provided by the Android OS for creating such SDKs. Please, only use a JAR if you really, really have to. Otherwise, provide a standardized ContentProvider, Service or Activity and document the way it's supposed to be used (i.e. how to use/query/integrate it).

0

精彩评论

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

关注公众号