• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Do something automatically when my stock Samsung keyboard is on-screen

last1left91

Lurker
Hi guys,
Well, I'm using Swapps in order to be able to open any app from any other app. This app is amazing but I don't want it to be active in all apps.
For example, when I open my keyboard(pretty big height), it interferes with Swapps because I placed the hotspot in the middle of the screen (invisible). Practically speaking, when I open my keyboard and trying to press on "1" digit, it touches Swapps hotspot by accident :)
Another app I don't want Swapps to be active is Camera.
As a solution I heard about a shell command which can detect whether the keyboard is shown(on-screen or foreground) but it doesn't work to me and I don't know why!
cat /proc/$(pgrep com.touchtype.swiftkey)/oom_adj
And instead of com.touchtype.swiftkey I have to introduce Samsung's keyboard package name which is: "com.sec.android.inputmethod" and can be find under Settins/ Application Manager/Running and then Processes and the name of the package is the one below the app's name.
So the command for me will be : cat /proc/$(pgrep com.sec.android.inputmethod)/oom_adj.
Then, I store the output in a variable %oom_adj and when I flash it, it always shows me "0".
Actually, I want this task to be triggered whenever my keyboard is in foreground but don't know how to approach this. I want to express something like : "If my keyboard is in foreground, which means if %oom_adj (the output in which I stored the output) =="1", then kill Swapps service".
And pushing it to maximum :))...when keyboard is no longer in foreground which means when %oom_adj >="2", open swapps(service...NOT app) and this assuming %oom_adj changes its value accordingly.
I find this almost impossbile :)) but said to try :)
Well, what I'm doing is to create this task and flash %oom_adj and I always get "0".
I could create a profile which will be triggered by %oom_adj's value but I don't have an if/else case because I always get "0".
The first task would be to do something when my keyboard is on-scren :)...hope someone will be able to help me :)..all the best :)...I accept all type of solutions: shell, java...everything :)
 
I managed to do something when every keyboard is on-screen with dumpsys method...Seemed to be the last resort...it does what is supposed to do.
The second part of the "impossible " thing would be to launch Swapps back...!
In the if case my task kills Swapps automatically when keyboard is shown. Well, in the else case I want to relaunch the Swapps app after it has been force closed....is it possible with some shell command? Thanks in advance :)
 
Back
Top Bottom