-3

I have a small app for lawyers that is working fine. But now I want to implement some courthouse data integration (in Brazil).

Unfortunatelly our courthouses doesnt provide any kind of API, so I need to perform some page crawling to obtain the information.

For each State I need to develop a different library, and I wish to develop separate modules so the users need to install only the modules for the State they work in. Doing this way I can publish updates more easily if one courthouse changes the site layout, without affecting other users.

i.e. the user download the main program (same for all users). The user from "Rio de Janeiro" downloads the crawler for "Rio de Janeiro" only, so does the user from "Sao Paulo" downloading only the "Sao Paulo" crawler.

In a windows development platform I would develop some DLLs and the work is done, but I dont know exactly how to do this in Android. I understand that I will need to develop a differente "app" for each State, but how can I check which modules are installed and most important how to call the modules functions?

So I need some basic guidance on how to do a module development and integration with main app.

1 Answers1

3

For each State I need to develop a different library, and I wish to develop separate modules so the users need to install only the modules for the State they work in.

That seems like serious overkill for a handful of states, each of which requiring a handful of lines of dedicated code.

how can I check which modules are installed

Use PackageManager. For example, you could call getInstalledPackages() and iterate over them looking for ones whose package name matches some pre-defined pattern (e.g., com.klamarth.brcourt.state.*).

how to call the modules functions?

You don't. Your "modules" need to export some Android component (e.g., service), and your main app can then talk to that component. Which component (activity, service, content provider, or broadcast receiver) would be up to you, depending upon what the module is doing and how the user interacts with it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Cool, I am reading about content providers now and it seems to be the best choice. And the getInstalledPackages will solve my other issue. About the amount of code, it will not be a real issue, because the crawling in the page will be very simple, just traverse some "table" element and get two columns content. The other solution would be creating a server service that can do the work for all users. But the app is free and I am not planning to spend money for now. Thank you very much! Now I can continue developing :) – oleonardomachado Apr 07 '14 at 17:31
  • @klamarth: "because the crawling in the page will be very simple, just traverse some "table" element and get two columns content" -- my point is that going through all the work to set up this sort of plugin system is overkill for this. Just put this code in the main app. Brazil is unlikely to add states very frequently, and government Web sites do not tend to change very frequently, and so I'd reduce the complexity for you and your users by putting it all in the main app. – CommonsWare Apr 07 '14 at 17:40
  • You are right. Maybe I can put all States in the same apk. I want to make it apart from the main app because I cant wait to develop all courthouses to deploy. I want to develop a few first (the most important) and deploy. This way the users that dont want this feature will not be bothered to update the app several times. I need to develop at least 81 different crawlers to cover all country. About the changes, our gov sites dont like to provide information for Apps, some even add captchas to make it more difficult, so they sometimes change some parts of the design :) – oleonardomachado Apr 08 '14 at 01:42