Detecting Volume Key press on BlackBerry 10 Java Android Runtime - blackberry-10

I am trying to port my Android app to the BlackBerry 10, and the detection of the Volume Key press does not seem to work - the key press does not result in my code getting invoked. Here's my code snippet:
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
// We override the volume key to trigger a special event in our app
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
That code above works on an Android phone.
Is there another way for an Android app on BB10 to detect the Volume key press?

Apparently detecting the Volume Key press is not supported even for the Native BB10 platform - from the BlackBerry support forums

Related

Unity KeyCode for mute button for Fire TV remote

I have this problem when I'm looking at the amazon developer page for unity: https://developer.amazon.com/docs/fire-tv/controller-input-with-unity.html#controller-names
it shows the keycodes for all the buttons, except for the mute button on the remote.
My model is different; there's a volume button and a mute button. Neither of these are documented.
Thanks for your time!
Not a direct answer but you could maybe try to simply print it out using something like
public class Debug : MonoBehaviour
{
// Just print to a text so you can easily see the result on the screen
public Text text;
private void OnGUI()
{
var e = Event.current;
if (e.keyCode != KeyCode.None)
{
text.text = e.keyCode.ToString();
}
}
}
this way you could see which keycode responds to which pressed button/key etc.
According to the Fire TV Guidelines, volume +/- and mute are not to be mapped.
I heard that it's possible, but you will get rejected from the amazon appstore.
Source: https://developer.amazon.com/docs/fire-tv/remote-input.html
If you use the new input system, I released an asset on the assetstore which gives you access to all mappable buttons (Dpad, Select, Back, Menu, Rewind, Play/Pause, FastForward)
I'm not posting any links, but it's easy to find if you search for "Fire TV" on the asset store.

Virtual Keyboard not opening in Unity3D with Steam/MRTK

I'm developing with Unity using the MRTK (if that matters) and my project setup is using "PC,Mac &Linux Stand Alone", my player settings are set to enable VR.
I'm copying and pasting directly the code from Unity to open the keyboard, and that function is the first one I call when opening the scene, and yet I can't see it. Is there anything wrong/buggy with it?
I even tried it on a completely empty project. Nothing happens.
Directly from Microsoft:
public TouchScreenKeyboard keyboard;
private void Start()
{
OpenSystemKeyboard();
}
public void OpenSystemKeyboard()
{
keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, false, false);
}
No error message, no console message, just nothing....
The API in question I believe is only documented to work for the following platforms:
iOS
Android
Windows Store Apps (AKA UWP apps AKA Universal Windows Platform apps)
Since the build process is uses PC/Mac/Linux, it's not a WSA/UWP app, so I wouldn't expect that to show up given Unity's documentation here:
https://docs.unity3d.com/ScriptReference/TouchScreenKeyboard.html
The older version of the MRTK (HTK) had a keyboard prefab that could be used, though note that that branch is fairly old at this point:
https://github.com/microsoft/MixedRealityToolkit-Unity/blob/htk_release/Assets/HoloToolkit/UX/Prefabs/Keyboard.prefab

Close Unity Inside Android App

Actually I have an Android App in which I run my Unity3D game. Everything works well together. Now, when I launch Unity inside my app the game starts normally but if I try to go back to my AndroidApp intent I received a "SIGNAL 11 SIGSEGV" and Unity just close.
This happens when I'm drawing a Menu inside Unity and press "Exit" button to close Unity but if I do the same with the Android back buton Unity closes normally without problems.
I'm using plugins in Unity to achieve this behaviour.
My Function in Unity Side :
public void ExitGame()
{
#if UNITY_ANDROID
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
activity.Call ("ReturnToMainActivity", "Hello");
#endif
}
Function in Android Side :
public void ReturnToMainActivity (String someText)
{
Log.v("Unity", "Finish Unity from Android" );
this.mUnityPlayer.quit();
UnityPlayer.currentActivity.finish();
}
Again, this works normally if I press the Android Back Button inside Unity app but when I try to do the same with an Unity GUI.Button I received a "SIGNAL 11 SIGSEGV". In Both Cases logcat print the message "Finish Unity from Android" so I think Unity calls the function normally but in some Point just crashes.
Someone post faced the same problem but I can't figure out how he solve it.
SIGNAL 11 SIGSEGV crash Android
Ok, I just figure out how to do this.
In my function inside Android Side:
public void ReturnToMainActivity (String someText)
{
UnityPlayer.currentActivity.runOnUiThread(new Runnable(){
public void run()
{
Log.v("Unity", "Aplicacion de Unity terminada desde Android" );
ElJuegoActivity.this.mUnityPlayer.quit();
UnityPlayer.currentActivity.finish();
}
});
}
And that does the trick. No issues or problems.
NOTE: This is the "answer" the OP originally included at the end of his question. I've separated it into its own CW answer. If the OP returns and wants to post it himself, by all means ping me

Samsung Smart Tv Return Button

I created the app for the samsung smart tv. I tested my app using the Remote test system. All the functionalities are working properly except the return key. When i press the return button it is returning to the home screen but i want my app to return to the previous screen of my app. This is working correctly while i test this in the emulator.
I checked this by giving alers in the return key functionality. It is alerting that after it is returning to the homw screen.
Can anyone help me in this
RETURN and EXIT key are followed by default behavior to closing application and going back to smart hub or tv broadcast screen.
You should implement prevent default behavior, please look at this page: http://samsungdforum.com/Guide/ref00009/sfkey_preventdefault.html
In Samsung Smart TV, RETURN default action is return to Home, as you can see in SDK documentation:
http://www.samsungdforum.com/Guide/
You must to include this line in your code:
sf.key.preventDefault();
Before your code to customize RETURN button action.
For example (case from a Switch):
case tvKey.RETURN :
sf.key.preventDefault();
window.history.go(-1);
break;
I was facing the same problem for a basic Javascript project. I resolved it by adding event.preventDefault();, for example:
Main.keyDown = function()
{
var keyCode = event.keyCode;
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN: event.preventDefault();
}
For Apps Framework you can use this function:
sf.key.preventDefault();

Flex-Mobile: Should I use the menu-stuff provided or is it better not to because the iphone does not have a menu button?

I would not have asked the question if I owned an iphone, but so far I only have an android phone for development.
The question is: Should I use the View.viewMenuItems that are provided by flex mobile? Or should I better embed the functionality in another way? I don't know what possibilities might exist on iphone to open the menu, because it has no hardware button "menu".
By the way: How could I open the menu in the Flash-Builder mobile device emulator - there are no buttons, too....
Thanks!
you can detect the Menu Button through KeyBoardEvent in Android. In Iphone, the Home Button will exit out your application, so you should do some interface buttons to show your menu.
private function _onAddedToStage(event:FlexEvent):void
{
//removes listener
removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
}
private function _onKeyDown(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.MENU)
{
event.preventDefault();
_text.appendText("\nMenu Pressed");
}
}
The latest versions of Android's Honeycomb OS does not support the menu button. So if you do take advantage of Flex's ViewMenu feature beware that if you build using Flex 4.6 or newer there won't be a button on the latest Android Tablets and iOS devices.
In ADL you can choose Device > Menu to simulate clicking a hardware menu button.