Simulating Keyboard Events in Android - android

I have a project and I am trying to fire Keyboard events. I am using the Instrumentation Class, and it is working perfectly on the emulator, but when I launch it on my device, the call doesn't work, is there any way to make it work?
Also, I searched on the web, and I found some posts about the IWindowManager and the internal APIs, I fully understand the risk of using them, but my project is a research and is not intended to be published, so I don't mind using those APIs in my porject if they can solve my problem, but the problem is that I can't find the JAR that contains these classes.
TLDR : I need a solution that helps me fire keyboard events on my Android device, any ideas are appreciated

Actually, there is an easier method, that I found
Using Activity class or WebView class. Both have the same function.
The code looks something like this:
webView.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_1));

In instrumentation, there is the api to send keycode:
getInstrumentation().sendCharacterSync(int keycode);
If you have root access to the device, you can check the code here:
https://code.google.com/p/androidscreencast/source/browse/AndroidScreencastClient/src/net/srcz/android/screencast/client/ClientHandler.java ;
to use IWindowManager. The IWindowManager is apart of android system, you can find the class in android.jar, the source code can be downloaded from android official website.

Related

Any way to see all the methods that don't work at once? Android Studio

I have to estimate the time it takes to update a specific application made for Android 4.4 to Android 10 and I need to see all the methods that are deprecated or not working. Is there any way to see the methods without going file by file? (I'm using Android Studio with Java)
When I build the application I only get one or two types of error at a time, when I correct them I get another one and so on.
Thanks and best regards.
P.S: How long does it take you to update something like that? I'm a junior and I'm a little lost doing this.
Here, go to Analyze -> Inspect code. After inspecting check maturity there you will have depreciated methods. (Don't forget to change minSdk)
After you will do that it give you method with a warning and you can filter it by having API not support warning

Android Things RC522 (Galarzaa90 library)

I can't seem to get Galarzaa's library to work.
Neither his example nor the code under "usage" on the front page compiles.
The following line (and every consecutive call on rc522 from the "usage" section) causes a problem:
boolean result = rc522.authenticateCard(Rc522.AUTH_A, block, key);
Does any one know a tutorial or any helpfull link?
Also, do I have to configure the GPIO Pins of my build when I create it from the Android Things console under Step 5 Edit hardware configurations? If so, where do I find all the neccessary information? Or can I completly ignore that part, as long as my RC522 reader is properly connected to the RPi
I did got it to work following the example. I don't recall anything wrong with the documentation, but I'll double check.
I think you are trying a very complicated method for deploying. You are supposed to use the console and the custom images when you are done developing and want to do distribution. While in development, you should use a default image and Deploy the apk using adb.

Add/Inject/Force <meta-data> line into manifest of every installed app

the problem is, i use OP5T, and none of any 8.0/8.1 stock custom rom does support 18:9 scaling feature like in OOS, this feature named as "Full Screen Apps" under app category.
after a few googling, i came up with these method:
1.) add/inject/force this into manifest file of every installed app. or maybe doing some workaround with the packagemanager
meta-data android:name="android.max_aspect" android:value="2.1"
2.) playing inside AOSP source code, parsePackage method.
frameworks/base/core/java/android/content/pm/PackageParser.java.
i know nothing of creating xposed module, but before starting my journey, is it possible to do the first method with xposed?
after seeing module like Xinstaller, App Settings, and XAspect. i thought it may be possible with xposed to approach this.
really appreciate every kind of help, thanks before
Xposed Framework can do this!
Xposed cannot edit manifest xml files directly, but it can indeed do the way 2.) you proposed:
Xposed Framework can "hook" any method to execute arbitray code before/after/replace that method. You are indeed on the right track, and PackageParser.java seems like the right class : I'm not so sure about the parsePackage() method though - a glance at AOSP seems to suggest that perhaps the method parseMetaData() might be a better candidate to hook?
Some background on Xposed -
You will need Java to create any Xposed modules. Android itself is based on (primarily) Java, so you will need Java knowledge to make Xposed modules.
As for Tutorials, Rovo89 (the creator of Xposed) has a simple tutorial here at https://github.com/rovo89/XposedBridge/wiki/Development-tutorial. This tutorial is almost completely upto-date, and you can use this to create your first module.
You will find another detailed tutorial here - https://forum.xda-developers.com/showthread.php?t=2709324. Keep in mind that this link is very old, so wherever there are any conflicts, go by Rovo89's tutorial.

Regarding Android studio, how do you display the built in class files?

I know there's some way to do this because i've done it by accident, I just don't know the proper terminology to use in a google/SO search, so my apologies. For instance: the View class, a built in Android class, how can I bring up the file inside Android Studio with all the methods etc to see how the class works? and yes I'm aware I can just go to android.developer.com and see everything, but thats not my question.
I think you're talking about going to the class declaration. On Mac you can hold down Command and click on the class you want to go to, for Windows and Linux you can hold Control and click on the class.
https://developer.android.com/studio/intro/keyboard-shortcuts.html

Mobclix ADs inside Unity3D

I have lost much time solving this problem, and looks like I'm back at the beginning.
I want to run the full screen ADs from the Mobclix inside my Unity3D game. I found many tutorials but I can't get any of them working.
As far as I know, there are 2 approaches:
1.) extending unity player
2.) make JAVA side method for showing the AD's and just call it from the unity(c#)
Most important for me is to make it work, but I would prefer 2. approach.
Can somebody suggest me something and maybe give some hints/examples what am I missing?
I tried both ways. I made an JAVA plugin but when I try to call a method nothing happens or I got an error from JNI something like: "can't find that method", my manifest is not configured correctly, or my app crashes.
If I'm making a plugin (not extending UnityPlayer) do I need to add something to the manifest to support my activity/make my class able to call inside unity? How would the manifest look like? Can it be done that way?
If I'm extending the UnityPlayer how would mthe anifest file looks like and how can I call my method for that will show ADs?
I tried to call java/android methods from the unity/c# and that worked, but when I try to call my own simple method from the plugin it won't work. Looks like I'm missing something in that part. (connecting the JAVA plugin and the unity3d)
I'm experienced in the C#, but my JAVA knowledge is really at the minimum. I'm sure this can work (there are people that are selling solutions) but looks like I'm not smart enough and keep missing something :)
I tried many things, I stopped counting and deleted most of them. Can somebody tell me the right way to do this? A working example would be really useful...
Thanks for taking the time to read all of this, I hope there will be some useful responses because I'm starting to get depressed :)
Unfortunately, it looks like the absolute easiest way is to purchase a plugin, made just for this. I found one here, which costs $50, and it specifically stated it supports fullscreen Mobclix ads.
There is a free one developed by the staff at Unity3D forums, however, it seems more complex, in that you must run it on the actual android device, and I am not sure if it supports full screen. You can find the discussion thread here.
Hope these links helped!
Edit: I found a much more affordable £6.00 Unity3D plugin, which you can get here. It did not explicitly state support for fullscreen, however.
Note: I found a tutorial from the very same website that offers the £6 plugin. This tutorial might be worth checking into, however it involves compiling your own Unity Android plugin. Because it is from the same website, it may be worth checking into. It is specifically a plugin to display Mobclix ads on a Unity3D for Android app.

Categories

Resources