stefanoa Active Member Licensed User Longtime User Oct 24, 2012 #1 i've a music player app using MediaBrowser... YouMediaPlayer i need to create a widget with which to control some functions such as play / pause / stop / etc. if i play a song from my app and then minimize the app, the song continue playing.. how can i STOP or pause the song from widget?the problem is that they are 2 separate apps (widget and app) and cannot interact some ideas?
i've a music player app using MediaBrowser... YouMediaPlayer i need to create a widget with which to control some functions such as play / pause / stop / etc. if i play a song from my app and then minimize the app, the song continue playing.. how can i STOP or pause the song from widget?the problem is that they are 2 separate apps (widget and app) and cannot interact some ideas?
thedesolatesoul Expert Licensed User Longtime User Oct 24, 2012 #2 Use an intent to send the player app an intent which pauses/plays/skips the media. You will need to build in intent filters to your player to receive the intent, and generate intents in the widget. Upvote 0
Use an intent to send the player app an intent which pauses/plays/skips the media. You will need to build in intent filters to your player to receive the intent, and generate intents in the widget.
stefanoa Active Member Licensed User Longtime User Oct 26, 2012 #3 can you post a little example? thnks Upvote 0
thedesolatesoul Expert Licensed User Longtime User Oct 26, 2012 #4 Adapting warwounds example here: http://www.b4x.com/forum/basic4andr...-any-way-execute-command-inside-variable.html When clicking on the widget to send an intent: Code: Dim Intent1 As Intent Intent1.Initialize(Intent1.ACTION_MAIN, "") Intent1.SetComponent("your.application.package.name.here/.youractivity") Intent1.PutExtra("Var1", Var1) Intent1.PutExtra("Var2", Var2) StartActivity(Intent1) so in Var1 you can put State = Playing, Paused etc ORIf setcomponent does not work then you can try making an action like: Code: AddActivityText(youractivity, <intent-filter> <action android:name="com.packagename.myaction" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>) To receive the intent in your main application: Code: Sub Activity_Resume Dim Intent1 As Intent Intent1=Activity.GetStartingIntent If Intent1.HasExtra("Var1") AND Intent1.HasExtra("Var2") Then Dim Var1 As String=intent1.GetExtra("Var1") Dim Var2 As String=intent1.GetExtra("Var2") Else ' handle the activity being started with an Intent that doesn't contain the required values End If End Sub Upvote 0
Adapting warwounds example here: http://www.b4x.com/forum/basic4andr...-any-way-execute-command-inside-variable.html When clicking on the widget to send an intent: Code: Dim Intent1 As Intent Intent1.Initialize(Intent1.ACTION_MAIN, "") Intent1.SetComponent("your.application.package.name.here/.youractivity") Intent1.PutExtra("Var1", Var1) Intent1.PutExtra("Var2", Var2) StartActivity(Intent1) so in Var1 you can put State = Playing, Paused etc ORIf setcomponent does not work then you can try making an action like: Code: AddActivityText(youractivity, <intent-filter> <action android:name="com.packagename.myaction" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>) To receive the intent in your main application: Code: Sub Activity_Resume Dim Intent1 As Intent Intent1=Activity.GetStartingIntent If Intent1.HasExtra("Var1") AND Intent1.HasExtra("Var2") Then Dim Var1 As String=intent1.GetExtra("Var1") Dim Var2 As String=intent1.GetExtra("Var2") Else ' handle the activity being started with an Intent that doesn't contain the required values End If End Sub