I have the MediaRouteButton working successfully. However, since I am writing an app that always uses Chromecast, I would like change a couple of behaviors of this button:
1) On app startup, automatically select a device. If there is only one device discovered, automatically select it. If there are multiple, select the previous device selected by the user.
2) If the user manually disconnects using the MediaRouteButton. presses it again to connect and there is only one device on the network, automatically select that one. This is what the YouTube app is doing now - it never prompts me with a list of devices since I only have one Chromecast device on my network.
Any suggestions?
Create your own button for selecting the ChromeCast device. Look at the TicTacToe example which does not use the MediaRouteButton. You can create your own dialog for displaying the list of devices. The logic in the TicTacToe app can also be used to automatically connect to a ChromeCast device.
Related
I have a scenario where I want an app to open when it detects that it's connected to a USB device. I have used an approach similar to this (it is using a USB_DEVICE_ATTACHED intent-filter and I have the ID's defined in an xml) and it is working for the most part. The problem I'm having is that when the Android Tablet powers on, the tablet will already be connected to the USB device, so the app doesn't get the USB_DEVICE_ATTACHED event. This then requires me to start the app manually after power up, which leads to me getting this unwanted dialog screen each time:
Allow App to access USB?
[ ] Always open App when USB is connected
Cancel OK
It makes no difference if I check the "Always open" box. It still shows up each time. I have tried using a broadcast receiver to open the app when the app powers on, and I still get the dialog window.
So I'm wondering:
Is there is a way to see get a USB_DEVICE_ATTACHED event when I first power on?
Or is there a way to not display the unwanted dialog screen each time I open the app manually?
I would really appreciate any suggestions. Thanks!
I am working on an app that is supposed to run as the only app available on a tablet (running android 4.2) (the launcher app just launches my app). The user has to connect to WiFi (select and enter password) and the easiest way to let the user connect to WiFi is to launch the WiFi settings Activity. But the requirement is to keep the user inside my app. So what I need is a way to have the settings inside my app, but I am not sure if that is possible? I have tried to download the source code from https://github.com/aosp-mirror/platform_packages_apps_settings/tree/jb-release/src/com/android/settings/wifi but I am not sure if that is the way to go. It seems to be a lot of work, so before doing that I want to be sure if there is another way. Any suggestions?
I am new to Android development and I am trying to use the Android's Cast API. To start I have cloned and used the CastHelloText demo app. But there should be a cast button in the ActionBar/ToolBar which is for some reason not visible. I haven't registered any app to Cast Developer Console, I am just using the project as is, which means I am using the app id mentioned in their project. Does the chromecast device need to be powered on and plugged in and the android phone with the app be near/in front of the tv in order to make the button visible? I am a little confused as there is nothing mentioned anything like this in the documentation.
Your chromecast device should be powered on and on the same network as your phone (same wifi network on both). You do't need to be in front/near the TV as long as both devices are on the same wifi network but I presume you do want to be able to see the TV's screen to see if your app works or not, don't you?
I see this very confusing issue on GPE devices (Nexus, Moto G) with Android 5.0+ (still exists in Moto G with 5.1).
I`m working on android application that connects to a custom board via Bluetooth (RFCOMM). When I initiate connection Android frequently shows "Bluetooth pairing request" dialog and ask user click "pair" button. It is normal behaviour.
But with Google Play Edition devices like Nexus(5,6,9) and Moto G(may be with other GPE devices too). This messages do not appears to user. Instead android hides it in notification area. As result users do not understand that some user actions required. From user prospective app hangs up.
This dialog is not a part of the application. With Samsung Galaxy devices I do not see this issues.
Is there any workaround to show this dialog on top always?
I can think about two options:
You could start an Intent that would bypass the lock screen (if there is one) and display a msg to the user that an action is required (Android Lollipop - Bypass lock screen for popup activity).
You could add your own notification with a beep (using the MediaManager) and vibration to make sure the user is aware that he needs to approve the pairing. bear in mind that the user can configure the phone not to display notifications on any device running Android 5.x (in settings->sound and notifications) so It's won't always solve your problem.
Good luck!
I have been searching a lot for implementing screen cast(miracast) in android and got more confused. I have a HDMI wifi dongle. Now as i plug the dongle and open my app need to search for available devices and as user selects devices the mirroring should start and my screen need to reflect to the device which has plug the device. For now From settings we need to go to display and turn wireless display on and connect to them. As of now i tryed to do this by WifiP2pManager class and got a list of device and connected to my device. But it is not showing as connected on settings wireless display which need to be connected for screen casting. Now my question is can i start that casting from my app and how ?
there is no public API that allows you to manipulate directly the connection, but you can integrate an action that should do what you want, through the MediaRouteActionProvider
Using this, you can display a button inside your action bar. When the user will click on it, it will show the list of paired devices and do a quick scan. From there, the user will be able to directly initiate the connection to an available device.
It's working on most devices, simply not returning the action on those that don't have any paired devices or don't support Miracast (+some Samsung's that don't use the MediaRoute system for Miracast connection).
I need to have have a button that simply starts miracast(mirroring)
That's not possible through the Android SDK, sorry. Whether there is a way for an app running with superuser privileges on a rooted device to do it, I cannot say.