Air Android - Back button not working if keyboard is active - android

If you press the Android back key when the keyboard is active, the keyboard will disappear. On the second press the application closes but it should fired the handleDeviceKeys function.
This is my code:
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleDeviceKeys, false, 0, true);
function handleDeviceKeys(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.BACK) {
trace("fired")
}
}
Is there a fix for this?
(I'm using Flash CS6, Air 3.6 and tested it on Android 2.2 and Android 4 devices)

Try listen stage: stage.addEventListener(KeyboardEvent.KEY_DOWN...
If it will not work and you using StageText, then you must listen an instance of StageText instead.

Related

Android Keyboard does not show when pressing input field in unity?

I have a simple scene in unity which has an input field in it. When I run my scene in my Android Device and press the input field, the android keyboard does not show. I am connecting via USB to my laptop using Unity Remote 5 app.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class InputNumber : MonoBehaviour {
public InputField input;
// Use this for initialization
void Start () {
if (input)
{
TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
}
input.keyboardType = TouchScreenKeyboardType.NumberPad;
}
// Update is called once per frame
void Update () {
}
}
No need to call TouchScreenKeyboard.Open() method. The native keyboard will not show up if you are running it in Unity Remote app. But it will show up on touching input field once you build and run the app from File > Build Settings > Build or File > Build and Run.
When using the InputField component, you do not need TouchScreenKeyboard.Open to open the keyboard manually. Once the InputField is clicked on, it will open itself. Remove the unnecessary TouchScreenKeyboard.Open code.
I am connecting via USB to my laptop using Unity Remote 5 app.
That's the problem.
The InputField component will only open the keyboard when you build and run the program on the device. Unity Remote 5 is only used to detect touch on the screen and read the sensors such as the GPS and accelerometer sensors while programming on the Editor. For features supported with Unity Remote 5 see this post.
Also, TouchScreenKeyboard.Open will not work in the Editor too. You have to build and run it on the mobile device for it to work but TouchScreenKeyboard.Open is not needed here. Just build the game and deploy it to your device and the keyboard should open when you click on the InputField.
you need the Cross-Platform-Input asset from the Unity standard asset pack in the asset store. this is free, and once imported into your project will work on its own with the text field. just import it and try you phone again
then you wont need:
if (input)
{
TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
}
input.keyboardType = TouchScreenKeyboardType.NumberPad;
Unitys mobile class will just open the keyboard when you tap the field. no extra coding needed.

Unity3d, when I touch an InputField, the keyboard doesn't show

When I tap on an inputfield on android device, i get a little text area and an ok button. But I have to touch the input field to get the keyboard to pop up.
Any ideas?
All I'm doing code wise is:
if (!wasFocused && TouchScreenKeyboard.visible && createAccountPanel.activeSelf)
{
wasFocused = true;
btnMat.color = validC;
}else if (wasFocused && !TouchScreenKeyboard.visible && createAccountPanel.activeSelf) {
wasFocused = false;
btnMat.color = invalidC;
//messageMNG.CreateMessage("Checking name: " + usernameChangeInput.text, true);
dbMNG.CheckName(usernamePreview.text);
}
When I do a check, it says that touchscreenkeyboard is visible.
**EDIT
I just created a new scene and added an input field and a text mesh pro input field and I get the exact same thing.
The keyboard does not pop up if you are running the app on Unity Remote app. Keyboard will automatically show up once you build and run your unity app on device.
I was having a similar problem today, but found the reason no keyboard was showing was due to building and launching onto a locked phone. When I made sure the phone was unlocked when I clicked the input, the keyboard showed up below that box/ok portion.

How to minimize adobe air android app with as3?

I have 2 buttons in my app ( my app published by flash cs6 for android ). one button for exit app and one button for minimize app (send app to background and show homepage).what is code for 2nd button in as3?
b1.addEventListener(MOUSE_UP,exitapp);
b2.addEventListener(MOUSE_UP,minimizeapp);
function exitapp(e:mouseevent)
{
nativeapplication.nativeapplication.exit();
}
function minimizeapp(e:mouseevent)
{
//...what code I should write here?
}
NativeApplication has a property called activeWindow which is an instance of NativeWindow which has a minimize method:
function minimizeapp(e:mouseevent)
{
nativeapplication.activeWindow.minimize();
}
Finally I find this solution:
https://forums.adobe.com/message/5714697#5714697

Trigger enter event on Android keyboard Phonegap Application

I'm new to Android Phonegap. I'm using Phonegap cordova 3.3.0 to develop phonegap application. But I don't know how to trigger "enter" event on Android keyboard.
For example: when I touch on Input field, the keyboard appear, and I want to submit the form when press "Enter/go" button. Please tell me how to do it, or give me the reference link?
Thanks very much!
Try this
$(document).keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
}
});

Phonegap Android back button override

In my Phonegap app, created in a single html file using div as pages, I override the Back button to exit the app, only if the div that acts as the Home page is visible, otherwise to hide the others and show the home div. I use jQuery to attach the event handlers.
It works well at first app launch, but if the app is in the History list, the override is not working, the Back button exits the app without checking which div is visible. After deleting the app from the History list it works as expected again.
Tested on Nexus 4 with Android 4.2.
Here is the code:
$(document).on('backbutton', function (ev) {
ev.preventDefault();
if (!$('#divHomeScreen').is(':visible')) {
$('.screen').hide();
$('#divHomeScreen').show();
return false;
} else {
navigator.app.exitApp();
}
});
Thanks for your help.
What I have done is dynamically add and remove the backbutton handler as needed. For example...
function showScreen()
{
$("#divHomeScreen").hide();
$(".screen").show();
$(document).on("backbutton", onBackButton);
}
function hideScreen()
{
$(".screen").hide();
$("#divHomeScreen").show();
$(document).off("backbutton", onBackButton);
}
function onBackButton()
{
hideScreen();
}
This was tested on Galaxy S3 Android 4.3 and PhoneGap 3.3.0

Categories

Resources