Mark,

Your subject says "synchronous" - afaik, only content providers are synchronous. Service startup / binding is asynchronous, binder requires a service (although I could be wrong on this one), and so is asynchronous as well. Intents are of course asynchronous too.

A content provider doesn't have to be backed by SQL, or to really implement data storage - you could pass various commands encoded in the URI, returning results in your own Cursor implementation.

If you are keen on using intents, though - your code is pretty close, but you need to use startActivityForResult rather than startActivity, so that you can retrieve the result (set with setResult) later. This can't be used from a Service, only from an Activity, though.

-- Kostya

17.09.2010 20:02, Mark Wyszomierski пишет:
Hi,

I've got an application, and I'd like to publish a way for third-party
services to get data from it. Ideally I could expose this  through
intents, as in the following pseudocode:

    // third party apps
    class ThirdPartyService extends Service {
        @Override
        public void onCreate() {
            Intent i = new Intent(this, "com.me.test.MyAppIntent");
            Intent result = startActivity(i);
        }
     }

     // part of my app
     class MyAppIntent extends Activity {
        @Override
        public void onCreate() {
            Intent i = new Intent();
            i.putExtra("result", "hi there");
            setResult(i);
            finish();
        }
     }

The above won't work of course - I have some work done on this, just
wondering if anyone has any recommendations or best practices?

Thanks



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to