Android start casting to a device chosen from a custom Cast Dialog - google-cast

I have setup a custom Cast Dialog and added it using:
castButton.setDialogFactory(new DialogFactory());
My custom dialog retrieves available cast devices using the below code and display them as a list
MediaRouter.getInstance(getContext()).getRoutes();
How can I start casting to a CastDevice chosen from the above list?

Solved using:
MediaRouter.getInstance(context).selectRoute(route)
To disconnect I did:
MediaRouter.getInstance(context).unselect(MediaRouter.UNSELECT_REASON_DISCONNECTED)

Related

Cannot access Menu Bar Items via pywinauto

I'm automating the following program via Python: (Surfer)
http://www.goldensoftware.com/products/surfer
Some portions of it i cannot control using win32com.client (the program libraries do not support it). The part i need to get working can be done by using the programs menu bar. It's just 5 clicks i need to get done. So as an alternative i have been trying to use pywinauto (my first try with this). But this time i can not get the menu bar items. I tried analyzing the menus via swapy (https://github.com/pywinauto/SWAPY) but the MenuItems field show up empty (as an empty list []).
here is some test code:
from pywinauto.application import Application
app = Application(backend="uia").connect(process=2984) # tried "win32" as backend also
srf = app.window(process=2984)
srf.menu_select("Help")
I get the error:
"RuntimeError: There is no menu."
The menus I am trying to access are within:
Edit
Arrange
Geoprocessing
Any help will be appreciated.
I finally was able to get the menu controlled via pywinauto:
app_dialog.child_window(title="Menu Bar").set_focus()
From there is was a matter of controlling the keyboard with the SendKeys() module.
It's a workaround but it gets the job done.

How to get barcode number value using barcode plugins in Outsystems?

Question: How to get barcode number value in Barcode Plugins of Outsystems! Thank you!
From the Component page:
How to use this plugin?
Use ScanBarcode client action in order to open the camera and start
the scanning session. If a barcode/qr code is successfully scanned,
the result will be available on the Output Parameter ScanResult. The
usage of front or back camera can be defined through the Settings
parameter, setting Camera to either “front” or “back”. Flash can also
be enabled or disabled and if the sight line should be drawn on the
screen.
You can find more information here:
Supported Formats
Example

Stop casting/disconnect box is tiny on my Android Cast app

I'm familiarizing myself with the Google Cast SDK by building a small test application, following the Cast SDK for Android guide. I've created a standard ActionBarActivity-based app as the guide suggests (even though ActionBarActivity is deprecated... shrug) I've added all the library dependencies, added the necessary XML to AndroidManifest.xml and menu_main.xml and am using the MediaRouteActionProvider to handle device detection and to show/hide the Cast button in the action bar. All is working well, and the "Connect to device" box appears as it should when I tap the Cast Button.
However, when I tap the Cast button again to disconnect, the "Stop Casting" box appears but it is unusually small.
The box is supposed to be wide enough to show the volume bar -- in my super-small version, the volume slider does in fact show up but it is unusably small. Compare to what it is supposed to look like, for example as in the YouTube app shown below.
Any idea what could be going on here? I am using basically the exact code that the Cast SDK for Android guide uses (the only addition being some custom Buttons with onClick listeners to control the media playback and to start casting several different test streams (both audio and video.)
This is due to changes that were made into the Media Router Support library and will be fixed in future updates to that library. If absolutely needed, the current workaround is to override that dialog.

How can I change toolbar runtime in MFC Visual C++ 2010

I have two toolbars desgined of equal size and equal number of buttons.
Now based on some condition in code I want to change toolbars run time.
My prject is MDI application built in Visual C++2010 MFC.
Please help as early as possible.My application uses CMFCToolbar
If you are using CMFCToolbar you can just call: CMFCToolbar::GetCommandButtons (a static function). You get an Object array of all buttons in your system and you can change them accordingly (SetToolTip, SetImage ...)
The problem is that CMFCToolbar is variable and buttons can be inserted and dragged around. SO you need the access via GetCommandButons.
If you are using the classical CToolBar class the easiest way is just to add the button, so it always exists in the toolbar and in the bitmap.
If the button should not be visible at startup you just call DeleteButton with the index you receive from CommandToIndex.
To change the button you can just use SetButtonInfo.
If you need the button again, just call InsertButton, with the index where you want to have this button.You may save the previous index and used bitmap index before you delete it.

How does MonoTouch autogenerate XIB code behind?

I'm a C# programmer dabbling in a bit of iPhone development using MonoTouch.
I add a new View Interface Definition to my project and double click to open it up in Interface Builder. I add a UIButton. I save the file, and inspect the xib.designer.cs file, and I can see no reference to the new button.
I downloaded the code from http://monotouchexamples.com/ where I could see an example of autogenerated code behind :
[MonoTouch.Foundation.Connect("infoButton")]
private MonoTouch.UIKit.UIButton infoButton {
get {
return ((MonoTouch.UIKit.UIButton)(this.GetNativeField("infoButton")));
}
set {
this.SetNativeField("infoButton", value);
}
}
I opened up MainWindow.xib in interface builder. I notice a few differences. File's Owner is of type UIApplication instead of NSObject. What is the importance of this? There is an App Delegate object of type AppDelegate. I can't add an AppDelegate to my own view, or at least I can't find it in the Library. Do I need to add one? I can see that the existing controls on MainWindow.xib have Referencing Outlets to the App Delegate. I add a new button and I want to hook it up. When I click and drag a New Referencing Outlet to the App Delegate a context menu appears that lists the existing controls. How do I add a new element to this list, or where does this list come from?
I've been spoilt by the Visual Studio world where I just dump a button on a form and start writing code for the click event. Could someone provide some pointers about the steps needed to get this working on MonoTouch?
Thanks,
Patrick
Adding a button by itself is not enough. The button is not accessible outside the Interface Builder. You need add an Outlet, and connect the button with the outlet in Interface Builder.
Remember: Outlets are the members in your Controller class that get a reference to the controls, you can't just access the controls without them.
As Dave says, you need to add an outlet to your controller class, and connect your button to that outlet, before any auto-generated code will appear. This caught me out too initially.
You choose your controller class in the Interface Builder library window, choose 'outlets' in the bottom part of the library, and add an outlet there. You then need to select your button, choose the connections tab of the inspector window, and drag from the "New referencing outlet" circle over to your controller class. Interface Builder will then prompt you to choose an outlet to connect to. Then when you save, you should get the auto-generated code appear in the .xib.designer.cs file, and then you should be able to reference your button via that outlet variable in your .xib.cs file.
It sounds like the project I created is out of date - I remember there were quite a few changes around how the generated buttons are created in the designer file. I will update the project soon for you.
As Dave said, to get the code to be auto generated you need to add an outlet with Interface Builder. There should be an example on this video here - http://bit.ly/aWoItN but the server seems to be down at the moment.
Hope this helps,
ChrisNTR

Resources