I want to make an android service that would let me simulate keypress to fill fields on a web page when receiving an intent. Is this possible in any way or maybe through a different process (Not by simulation keypress?).
For example an example of what I would want to be able to do.
The user is on his tablet and has selected a field on a web page. For any bluetooth device discovered, fill the field with that id.
IS there a way to do it by calling an intent of the web browser or something like that?
Thanks
EDIT : figured my example was pretty bad.
Here is what I really want to do
When a nfc tag is detected on the phone,
read the nfc tag ID,
simulate keypress events of the id tag on whatever the focus is at the moment on the phone
Example : I'm on google focused on the search field and I put a nfc tag on the phone, the phone types the Nfc tag id on the google search field and voila
if you really want to simulate keyevents, you can use system calls:
input keyevent <keycode>
I would advice you to use BroadCast receiver. You have to create a Custom intent class after that, register the receiver when the user select a field. For interaction with web page, its better to use javascript to call native android method.
When you detect a device send your broadcast, if you are registered, you will handle the event.
Related
I am creating an Android app that communicates with a NFC Reader using HCE feature.
The scenario is, when app receives a command, the processCommandApdu method will be called and will start an activity. In that activity there is an EditText and a button. User can enter some text, then clicks the button and the text will be sent to the NFC Reader.
I can start activity from the service, but what I don't understand is how I can return back the entered text to HostApduService to send it to the NFC Reader.
Is there any good way to do this? for example, saving the entered text in an application variable (or database) in the activity, finishing activity, then read the variable in the service and return it to the NFC Reader. Do I need some waiting techniques in the service if using this way? Or is there any better solution?Thanks.
It seems like that you want to do something with publish and subscribe pattern.
EventBus is a library that can help you to post data between classes when it's ready for use.
You may also want to read about this tutorial first to see if that meet your needs.
I have a question.
I have to make link/button in html which will contain number. If user clicked on this button/link he should be redirected to panel/views where we type the phone number.
Do you know how to do this?
You need to have a Protocol Handler. Lets say something like
Pawel:// or any other. The URL should be triggered when you click the Button on
the web page in the mobile device.
In the AndroidManifest of your app you have to register this
protocol handler. This tells android that your app is capable of
handling that protocol handler. If your is the only app installed
at the user that can handle this protocol handler, then clicking
of the button will open the app(your desired activity)
automatically. Otherwise it will ask user to choose amongst the
available option.
Along with this custom protocol handler, you can attach a parameter
containing the number. This parameter can be parsed in the app(inside onCreate, when
it receives this url in the activity with the intent.
After parsing you can set it in TextView.
You might want to check Android / iOS - Custom URI / Protocol Handling if still working on it.
Is there an intent for sending data for the keyboard to "type"?
This is more theoretical than practical, but is it possible to broadcast an intent that is received by the keyboard. The intent would contain a string which is then "typed" into the active input field. Alternative the intent could include a target field, which the keyboard could use to either select the right field in the view or prevent the data from being output to the wrong field.
Why?
I'm imaging this could useful for data collection applications.
Example 1: Bluetooth scale
Say you have an application for tracking your weight. Every morning you launch the app, weigh yourself, type in your weight. If the scale were paired with an application agnostic service on your phone you could just select the weight field and step up on the scale. The value would be sent to your phone and passed to the default keyboard using this intent.
Example 2: NFC id tags
A service form application requires a 16-digit machine serial number. There is an NFC tag on the machine which contains the serial number. Instead of typing it out manually, the NFC read intent is caught by a service which passes the value to the default keyboard via intent.
Criticisms:
The app could/should integrate with the scale directly.
Counter argument: Does not work with a web app and you are reliant on an app supporting (and maintaining support for) your particular solution (e.g. Bluetooth device).
Replace the input field with a button that launches an intent for result.
Counter argument: Same as above, plus it requires more user interaction; Clicks and time are premium commodities.
If it doesn't exist, would it be the worst idea for keyboards to implement such an intent receiver? Or would it just open the door to bad application design? Security-wise?
Is there an intent for sending data for the keyboard to "type"?
Fortunately, no, for obvious security reasons. One app cannot force input into another app outside of very select situations (e.g., JUnit test apps).
The app could/should integrate with the scale directly.
Correct.
Does not work with a web app
Then write a native app.
you are reliant on an app supporting (and maintaining support for) your particular solution (e.g. Bluetooth device)
You need that anyway, as it is impossible to speak arbitrary Bluetooth and get input suitable for an arbitrary text field in an arbitrary native app or Web app. Otherwise, your proposed soft keyboard will try to grab data from your Bluetooth headset and type it into Twitter, and your music is probably longer than 140 characters.
would it be the worst idea for keyboards to implement such an intent receiver?
That depends on your definition of "worst". I would hope that the implementer of such an input method editor has a very large legal defense fund for the inevitable lawsuits that will result from such a gaping security hole.
Is it possible to detect incoming call before default phone application, and prevent to active default phone application in Android?
Looks like it may not exactly be possible according to this -> Create a custom call handling Application.
Anyway more research may be required on your side to check if it can be. Multiple posts on Phone broadcast receiver can be used as reference.
I am planning to write a service to enable Android users to listen to any text is currently displayed (be an email, an ebook, a web page, a note, an SMS, etc...), upon request.
Do you think it is feasible?
Do you know if it has been done, already?
How could I bind (a button? a gesture? something else?) a user input to the service activation?
I know these are quite generic questions, but I'm really on a pre-alpha stage for my project, I want to understand if it's feasible, to start with... :-)
For example you can use google translate service for doing your own tts, you need to do a httpConnection with the text that you need to listen