On Thu, Oct 14, 2010 at 8:38 AM, MobDev <[email protected]> wrote: > An Activity (let's call it main) and a Service... > The Activiy get's started right away, after which it couples to the > Service. I'd liek the Service to be able to send broadcasts so that my > Main (but other activities as well) can capture anything the Service > has to say ;) > Now I noticed though, that my Main activity cannot both include > > <activity android:name=".nowPlayingGUI" > android:label="@string/app_name" > android:screenOrientation="portrait" > android:theme="@android:style/ > Theme.NoTitleBar.Fullscreen" > android:launchMode="singleTask"> > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category > android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > <receiver android:name=".nowPlayingGUI"> > <intent-filter> > <action > android:name="development.android.service.musicServiceUpdate"></ > action> > </intent-filter> > </receiver> > > thus it cannot start up as the MAIN activity AND be a receiver for a > broadcast...
Correct. > Is this correct, and how should I approach this problem to be able to > accomplish what I have described at the beginning of the post ? Use a BroadcastReceiver. Register it using registerReceiver() from your Activity, supplying a suitable IntentFilter. Unregister it via unregisterReceiver(). Here is a sample project demonstrating this: http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/ -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://skillsmatter.com/go/os-mobile-server -- 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

