Forums - Back button from Allplay Speaker dialog

5 posts / 0 new
Last post
Back button from Allplay Speaker dialog
Pinball Wizard
Join Date: 14 Apr 15
Posts: 50
Posted: Fri, 2015-11-20 11:49

Have a problem where because I don't have a local device, there is a potential scenario where no devices are discovered, and the list of speaker selections is totally empty, including local devices.   The user can't select anything, and the Android back doesn't close down the dialog.


The app has to be forced closed.   Can't seem to work out how I can catch this back button press and close it down.

I do see this in the logs:

AllPlayDeviceDialog: onKeyDown
AllPlayDeviceDialog: onBackPressed()

But these are genrated by the SDK library.
  • Up0
  • Down0
daniel.tai Moderator
Join Date: 19 Oct 15
Location: San Jose
Posts: 32
Posted: Fri, 2015-11-20 14:11

Hi Pinball Wizard,

Are you initializiing with 

public void init(final String applicationName, final boolean haveLocalPlayer, final Context context)

If haveLocalPlayer is set to false, then no local device will be shown in the list adapter, and back press is disabled because for AllPlay Radio, we wanted the users to select an AllPlay player before continuing.  

I can only think of calling

public static AllPlayDeviceDialog getInstance(Context context), then call dismiss() or cancel().

This will return you the existing dialog, or a new dialog, but since you just want to dismiss and not show it, calling dismiss/cancel will trigger the internal onDismissListener to clear everything.

So,

AllPlayDeviceDialog dialog = AllPlayDeviceDialog.getInstance(getApplicationContext());

dialog.dismiss();

I hope this helps.

Thanks

Daniel

  • Up0
  • Down0
Pinball Wizard
Join Date: 14 Apr 15
Posts: 50
Posted: Fri, 2015-11-20 15:26

The problem is, if there is no local device (which in my case, there isn't), and there are no allplay speakers found either, the empty list means you are stuck there forever, with no path forward, nor no path backwards.

 

  • Up0
  • Down0
Pinball Wizard
Join Date: 14 Apr 15
Posts: 50
Posted: Sat, 2015-11-21 03:49
AllPlayDeviceDialog  cannot be accessed outside of package :-(
  • Up0
  • Down0
daniel.tai Moderator
Join Date: 19 Oct 15
Location: San Jose
Posts: 32
Posted: Sat, 2015-11-21 19:55

Hi Pinball Wizard,

I am sorry for making the wrong suggestion, obviously AllPlayDeviceDialog is not a public class :(

I just quickly tried AllPlay Radio and see how they handle this situation.  It seems they are listening to the callback

onAllPlayAvailabilityChanged(boolean available).  When this callback hits, and available == false, then SDK no longer detects any AllPlay players.  In this case, AllPlay Radio brings up a dialog asking users to check for their AllPlay players.  When AllPlay Radio app was designed, the decision was made to make sure user always selects an AllPlay player before/during using the app.  The SDK without local device flow was designed this way, and turned overloaded onBackPressed on the dialog to do nothing :(

This is obviously different in your app, as you may not need to force user to select an AllPlay player until it is necessary.  Until I can convince the team to always enable onBackPressed no matter what mode, I may have a possible solution, but it is not pretty :(

Have a reference to the public AllPlayButtonView object that gets created in your fragment or activity, and when onAllPlayAvailableChanged give available == false, you can either disable the AllPlayButtonView object to prevent users from pressing the button, or extends AllPlayButtonView so you can overload the onClick method to pop your own dialog to let users know they need an AllPlay player.  For dismissing the dialog, there is a private variable in AllPlayButtonView, and it is AllPlayDeviceDialog "mPlayersListDialog", if available == false, you can "access" the private variable via Reflection and dismiss the dialog for the user.  getNumberOfAvailableAllPlayPlayers() in AllPlayController may also be helpful to check.

http://stackoverflow.com/questions/11483647/how-to-access-private-method...

Please let me know if this solution may work.

Thanks

Daniel

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.