views:

47

answers:

1

I've been trying to create an android-application the last couple of weeks, and mostly everything has worked out great, but there is one thing that I was wondering about, and that is pluginability trough the use of intents.

What I'm trying to create is basically a comic-reader. As of the version I use now, I open the application and get a list of commics that are my favourites, then I enter one to get a detailed view, and finally I enter a page. This is managed trough 3 activities. List, Details and Page. However, as of now the application can only read comics of one source (a specialiced xml-feed comming from my server), and I was hoping to be able to expand this a litle (also, the page-activity and some other stuff needs to be cleaned up in, so I'm thinking about remaking from scratch, and just take the first go as a learning-round). And I came up with an idea which I think sounds great, but I don't know if it's possible, but this is what I'm thinking about:

  1. The user enters the application and get an (first time empty) list of comics.
  2. The user hits a button to find comics, this launces an intent that says something like "find comic" or something like that. This should cause the system to display all matching activities. This would make it possible to provide different comic-providers trough different applications.
  3. Another activity kicks in and might displays some options to the user (for instance a file-browser), or might not (in the example of an xml-feed, which should just load).
  4. The list is returned to the first activity and displayed to the user. The second (find) activity is closed.
  5. The user picks a comic from the list. This should open some details-activity. The details-activity should receive a key which corresponds to the comic selected. This should be unique amongst the comic-providers. The details-view should get it's data trough some cind of content-provider, or an activity (whichever is most suited, if one of them is).
  6. The user can select a page. This should be the same routine as step 5.

My question is, is this possible in the android system, and if it is, is it a bad idea? And also, is there any better way to achieve more or less the same thing?

A: 

You can specify Intents to achieve some of this behavior. An Intent is an Identifier connected to some kind of service. For example if you want your user to be able to share something from your app you could use an ACTION_SEND intent. This would cause the OS to look through all apps and see if they defined an activity that handles this intent and displays them as a list to the user. If you build two applications the comic manager and the comic downloader you could define the Intent and publish all the needed data on your applications website and everybody who wants to build another comic download can just use this intent. Your comic manager then could use a startActivityForResult call and if the downloader was build correct and returns a defined key or a path to the comic on the SD Card the programs would be able to be integrated in a nice and smooth way.

This is a cool behavior and a main advantage of android to connect apps this way. But this also requires the user to download the comic downloading app and the reader app to use your app. Maybe you would be able to integrate a simple downloader and then listen for the same public Intent as all other possible downloads this would result in the user only needing one app but also enables the "mesh up" of apps(I have no information if this works but you could quickly test it).

Janusz
Can you use startActivityForResult on an activity and make that activity only display a progressdialog?
Alxandr
the activity can choose itself what to display. Maybe it displays a whole comic sale progress with the possibility to enter credit card number etc. or it displays only an progress bar but you can't force something on the activity that was started
Janusz