I am writing an app for a custom android device that includs a barcode scanner. Inside my app is a WebView.
Out of the box, the scanner populates html fields inside the webview without calling any library methods.
I can see the text in Android Studio's profiler. I have attached pictures of the event. For testing, I created a barcode encoded with the text "Your Text".
My problem is, I need to capture this event or replicate it, but I don't know what type of event it is. I originally thought the text was part of the Key Event, but the String is not there. It seems like it is another key press event. Is there a way to capture or replicate this mysterious event?
it might be the key-code assigned to the scanner's trigger button (just press and hold it for a second)... when the duration of the key-event changes, this should be proven. KEYCODE_BUTTON_R1 is 103:
On a game controller, the R1 button should be either the button labeled R1 (or R) or the top right trigger button.
there might be configuration bar-codes available, to enable/disable/change that key-code.
Related
I have been searching high and low for an answer on this and I am completly dumbfounded.
I am implementing simple click and page tracking in my Android app using GA, running this through GTM. All my "Screens" are visible in realtime in GA but I can't get "Events" to appear at all.
Well actually I can but the behaviour seems very bizarre. If I do not include a "Label" and a "Value" I can see the events appear. However if I add them (either as just a constant or a data layer variable) all events stop. I have confirmed the variables I want in "Label" and "Value" are coming through as I made a container with those values as "Category" and "Action" and could see them as expected in real time.
This leads me to think the app side implementation is perfectly fine but there is an issue with my tag in GTM. (Obviously not the Trigger as that too works when expected).
Ideally I would like to do something like this (the variables are data layer variables):
But this doesn't work. I see no Events.
The Event Value should be a number, not a string. Shuffle the fields, for example - Action - Click on: {{GTM - Click Target}}, Label - {{GTM - Click Value}}, and leave the value empty, this will fix your problem.
Make sure, you have correctly setted up Click listener.
Enable when defines when is listener available and where is applied to the all DOM elements.
Fire ON defines conditions, so in your case it could be {{event}} equals gtm.click or {{event}} equals gtm.linkClick .
This is the most common pitfall when setting listeners
I'm a beginner at App Inventor and I don't know what I'm doing wrong with the listpicker.
I am trying to create and app to reproduce the music I have stored in my server but when i display the listpicker I can't click any of the options and also I can't go back to the first screen. Here I put my code:
Image 1
Image 2
I tried to remove the line that says call listpicker.open but it only made appear a totally black screen.
The result of the code I just posted is exactly what I spect a list with the name and the link of the 2 songs I already upload to my server but when I click them it didn't do anything.
Thanks for your help.
The Web component works asynchronously, which means, it takes a little bit, until the result is available. The result you will get in the Web.GotText event.
Therefore it does not make sense to call the updateListpicker procedure in the Listpicker.BeforePicking event, because the result still is not available and you get displayed an empty listpicker. The listpicker will be opened, before you have received the result!
Set the listpicker to visible=false and use a button.click event to call the updateListpicker procedure. Then as you already do it in the Web.GotText event, assign the received list to the listpicker and open it.
I'm attempting to make a way for a user to input text into a TextView from an EditText. However, if the user enters something, and wants to fix it, I want them to be able to press space on an empty EditText to get the last thing they wrote back. The first problem is, if they type in "hello", hit enter to add it to the TextView (which clears it from the EditText), then hit space, the EditText then has " hello". Not what I want, and I can't figure out why.
My code to place the entered text into a holding string:
b1 = ti.getText().toString();
Then, if the user hits the space key, I believe they should get b1 in the EditText. Instead, I get: " " + b1. Why is this added space in there?
if((event.getAction()==KeyEvent.ACTION_DOWN)&&(key == KeyEvent.KEYCODE_SPACE)){
if(ti.getText().toString().equals("")){
ti.setText(b1);
}
My second, bigger problem is that the above code only works on a hardware keyboard. What is the key event for a software keyboard pressing space?
This is all in an onKeyListener.
An easy way to solve the extra space problem is to just remove the space from the String before you put it into the EditText
b1 = b1.substring(1); //<--- cut out the first character, which is the " " in your case.
ti.setText(b1);
p.s. I strongly recommend more descriptive variable names. Your programs are likely to be confusing to work on if you use names like ti and b1. Perhaps these choices make more sense in the context of your program. But from what you've shown here it is not easy to tell what these names refer to.
For your first problem I suspect you need to return true from your onKey method in the onKeyListener when your 'if' condition is met, to indicate that the event is consumed, otherwise you get the default onKeyListener adding the space to the EditText. i.e.:
if((event.getAction()==KeyEvent.ACTION_DOWN)&&(key == KeyEvent.KEYCODE_SPACE)){
if(ti.getText().toString().equals("")){
ti.setText(b1);
return true;
}
}
This extract from the KeyEvent API docs should help with problem 2:
"As soft input methods can use multiple and inventive ways of inputting text, there is no guarantee that any key press on a soft keyboard will generate a key event: this is left to the IME's discretion, and in fact sending such events is discouraged. You should never rely on receiving KeyEvents for any key on a soft input method. In particular, the default software keyboard will never send any key event to any application targetting Jelly Bean or later, and will only send events for some presses of the delete and return keys to applications targetting Ice Cream Sandwich or earlier. Be aware that other software input methods may never send key events regardless of the version. Consider using editor actions like IME_ACTION_DONE if you need specific interaction with the software keyboard, as it gives more visibility to the user as to how your application will react to key presses."
I'm creating a spades app with 1 human player and 3 computer players.
The problem that I am having is, the play must happen sequentially (clockwise) and I need my program to wait on the player input. I can't use wait() and notify(). I have tried while loops to check whether the user has selected a card but those stop the program from running. I've tried recursive methods that won't return anything until the player has chosen a card. That too does not work. So what do I do? I'm stuck.
My method goes like this (leaving out the non-pertinent code)
private void game(){
while(there are more tricks to be played)
while(each player has not played){
if(human turn)
get input from player
else
computer plays
}
}
Maybe you should change a little bit your game controller. Instead of waiting for anything, have your program continuously paint the screen. If user inputs nothing, same screen is paint all the time.
Once he presses a key (or clicks a card or whatever events you have), simply modify the paint method's argument (the screen to be painted). Thus you will separate painting the screen and input handling. It's a common technique called MVC model.
Maybe this will help (it's my game creating blog, and the links inside it are also helpful):
http://m3ph1st0s.blogspot.ro/2012/12/create-games-with-libgdx-library-in.html
You don't need to adapt all your game to the game described there, only the technique of separating input from painting. As a general technique, you should NOT have input determine painting.
Hope it helps. Don't hesitate to request further help.
You can try to add Event Handlers. It will try triger a event every time the user selects a card.
Try this.
Create one thread and in that threat call sleep(1000);
Is it possible to have the barcode scanner (zxing for example) called instead of the keyboard in a webview? So, just to be clear, when I tap in a text box inside my webview I'd like to override the keyboard call and have the barcode scanner open instead as an input to the text field. Is this feasible?
Yes its possible , i implemented this softkeyboard which does the job.
'Long press' shift key and you can scan a code which adds to the text field
which has focus.
http://www.androidbroadcast.com/en/softkeyboard/index.html
Barcodescanner Keyboard lets you do exactly this. It is definitely possible.
it possible go to http://www.tec-it.com/en/software/android/barcode-keyboard/barcodekeyboard-overview/Default.aspx
download barcode keyboard demo version and enjoy....
Not in any kind of standard fashion: you could plug a custom JavaScript handler that listened for focus messages from the specific text input (identified perhaps by id?) and then use the InputMethodManager to hide the input method and launch your barcode reader. When the barcode reader returns with content you could then use the same JavaScript handler to insert the result into the text input field.
This isn't exactly what you are asking for but might work: You could modify the ZXing bar code scanning library to dispatch key events for each character in the scanned bar code. I assume these key events would be interpreted by the text field. You can program the bar code scanner to append a carriage return or whatever to accept the data into the text field as if someone had hit the enter key. You could put a border around your layout and turn it red or something to indicate to the user that it will accept typed in data or a bar code scan.
It is not possible -- at least, there's nothing in Android or ZXing that lets you do this directly. But you can certainly write your own Input Method that does such a thing, if you're willing to put in the work. ZXing is open source and there have been some topics about it in the discussion group.