I've got new mobile from ebay, Blackview bv6000, which has 3 special physical buttons
Camera
Sos
Ptt
Then i need to assign those buttons to run my app and some functions
I got stock rom from Blackview forum, after i extract system.img file and found
\usr\keylayout\Generic.kl
which contains list of key function that i need
key 212 CAMERA
...
#[AGOLD][2015.04.08]Fengjun merge
key 249 FUNC1
key 250 FUNC2
#[AGOLD]End
The question is how can i assign that key to run my app or function in my app?
Edit
More info:
I want to catch button event in home screen or in other app or even the screen is off
Look into KeyEvent which is shown in an functioning example in this answer. For the specific keys, check out https://developer.android.com/reference/android/view/KeyEvent.html
For example, KEYCODE_CAMERA for the camera button.
In my company we have been searching for this for a while and finally I have an answer.
We have recently contacted with the BV6000 main provider and they told me that those buttons can only be overrided by customizing the hardware specifically for your app and that they require a 500+ phones commercial order to start the procediment of customizing something.
They won't move a finger neither give any documentation for less than that :-/
Related
I'm a junior software developer and I need to develop an app for wear OS with the following key feature; to detect a long press of physical button on a smartwatch while the app is running in background. Is this even possible? If yes, I would truly appreciate for any links to samples and documentation.
thank you
As far as I know this is not possible. The multifunctional buttons can be mapped to custom actions, but only when an application is running in the foreground. Otherwise they are controlled by the system (to e.g. act as a shortcut to Google Pay).
Even if it was possible, your app would only work on some devices since not all models have a multifunctional button. The only button that is guaranteed to exist on all devices is the power button, and this one you can definitely not get any events from in your app.
You've probably seen this already but I'm attaching it in case it's helpful to someone:
Design guidelines plus recommended use cases and behavior can be found here
Implementation reference for the multifunctional buttons is here
The MediaPad M3 does not log anything related to the app I am developing (compared to other Android devices). I understand that the log level usually can be set on Huawei devices via a hidden menu.
I came across these instructions many times while searching for the solution: https://gist.github.com/Shallong11/8403487
However, this is a tabled and it doesn't have GSM support and a Dialer / Phone application. So I fail at step one: dial ##2846579##.
Update #1: I've tried everything listed here: https://android.stackexchange.com/questions/59259/typing-dialer-secret-codes-in-devices-other-than-phones
Nothing works. The only reaction I've gotten: startActivity call with Intent.ACTION_DIAL is handled by Contacts app. Quite strange that there's a Contacts app but no Dialer...
It's probably meaningful to add that debug logs are displayed but stack traces of app crashes are not.
Update #2: I've also tried with some of these secret codes; nothing works: http://mobilespecs.net/phone/codes/Huawei/Huawei_MediaPad_M2.html
Because there is no dialer on the tablet, open calculator in landscape mode and enter
"()()2846579()()=" and the hidden menu should appear.
Here's a video demonstration.
Also please note that you'd need to restart the device afterwards in order for the changes to be applied.
I have an customer project where I have to make single task android device. Customer isn't able to escape the application which my company have developed. Also customer isn't able to start any other application and our application is started when the device is booted. Overall all the customer is able to do with the device is run our application.
Is there any other way to make this work than rooting the device, disabling all system buttons and making our application the launcher. I have something like 400 devices for this purpose so rooting all those would cost lot of time.
I also read Google's tutorial about COSU devices but found it very confucing https://developer.android.com/work/cosu.html#testing-plan
Androids own screen pinning is not good enough because customer can escape the app. Some may suggest to use some kiosk application like SureLock but my company's goal is to find clear solution for this without using any third party apps. Also running our app via some kiosk application is not our goal.
I found some posts on the Stack Overflow with similar question, but not the answer I'm looking for.
If someone has some tips for this question I would be very grateful.
Single purpose devices built on top of Android can get difficult to implement. There are a few different options, but each have trade-offs.
As you mentioned, rooting devices will functionally get you what you want - however it will be time consuming with hundreds of devices to root, difficult to maintain, and you will (potentially) introduce security issues to your devices and app.
Another option is using Google's Lock Task Mode for COSU devices[1]. The link there has a nice graphic showing the features of lock task mode:
1 app pinned to the home screen
only apps white-listed by the DPC (device policy controller) can be locked
Home and Recent buttons hidden
exit by calling stopLockTask()
There are some downsides to using Google's solution for this. First Google recommends creating (and therefor maintaining) an entirely separate DPC app to run as a device owner and set policies[2]. You'll also be dependent on Google Play to manage application updates and be required to have Play accounts associated with each device which "are used to identify a single device that is not tied to a single user for simplified, per-device app distribution rules in COSU-style scenarios"[3]. To automatically get your DPC app on devices your "DPC must be publicly availble on Google Play, and the end user can install the DPC from the device setup wizard by entering the DPC-specific identifier."[3] You'll also need to upload the user application to Google Play[4], which may be an issue for some who don't want their apps on Play. Going this route gives you features you need, but can be complicated and also ties you and your customer pretty tightly with Google/Play services and their workflow.
You can also look at enterprise mobile deployment platforms like Mason[5]. In your case, you can create a custom Android OS in a few minutes with your app locked in kiosk mode (+ other features like disable camera/sms, remove apps and hide settings, etc.) and then deploy it to all of your devices remotely. Mason also supports OS and app updates controlled by you if your requirements change.
DISCLAIMER: I work for Mason
[1] https://developer.android.com/work/cosu.html
[2] https://developer.android.com/work/cosu.html#create-dpc
[3] https://developers.google.com/android/work/requirements/cosu
[4] https://developers.google.com/android/work/play/emm-api/samples#push_install_an_app_on_a_device
[5] https://bymason.com/
I went to the same problem before. I spent at least 3 days doing research. I tried to find many solutions but I found zero.
How I solve is
1. Up To JellyBean
- Use System Alert Dialog (And make it transparent and small size like 2 * 2 And display in some corner(User can't see it)). User can't press home button If there is system Alert dialog
2. After JellyBean, This method doesn't work. The user can press the home button even though there is System Alert Dialog.
so what I did is, start the service on stop and start the same activity again and again(within sec). So user can't see any difference.Don't forget to make activity as single task so that even though you start same activity from service, again and again, new activity will not create (So Ugly way )
- You can simple make screen full screen. make sure in kiosk mode try to check if the screen is in full-screen mode. if not make it full-screen mode(its not hard to do)
- other way is to make launcher app but when ever you pressed home button it always asked to choose launcher app. if user mistakenly choose default/ other launcher app, this solution doesnt work
Good luck
Make your application as a launcher application by defining in manifest file.
After that go to setting of your mobile device and change default launcher application to your application.
I am planning to build an app which needs a screenshot. My requirement is to launch the app when the designated key presses are executed. (i.e. like volume up+lock key for taking screen shot in windows phone). My app will then launch automatically for further processing of that image. Is it possible to build or is there any work around for that?
Thanks in advance.
There is no way to build such app for Windows Phone.
Even if an app is running it can't get access to hardware keys except BackKey.
App can't run in the backgroud. After user leaves app it goes suspend and only couple of BackgroundTask can be launched to run in background at that moment.
EDIT
To be clear your app on Windows Phone 8.1 can be done but it'll work like following:
User takes screenshot, goes to gallery and choosing to share it.
Your app must declare that it can receive image (https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh871367.aspx)
User see your app in share list, choose it and than your app gets screenshot and may start to work with it.
Adding on what #khamitimur has posted. You will be able to only list down the third party apps installed within your Windows Phone device programmatically but not to launch them using any hardware parts of the device.
P.s : The developers have not yet been given any access or API to hardware parts in order to trigger events from those.
I am currently working on an app that simulates the d-pad (up, down, left, and right). The problem is that I can't figure out how to send those key presses to other applications.
Currently, I am using Instrumentation and it works perfectly fine in the activity of my app.
Here is the snippet of the arrow key left code:
new Thread(new Runnable() {
#Override
public void run() {
new Instrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_LEFT);
}
}).start();
The problem with this implementation is that due to an android security feature, I cannot send key presses to other applications.
After searching up different ways to injecting key presses, I came across this article. However, after trying the example code, it doesn't seem to work. I poked around and found out that android doesn't seem to have an input device for the keyboard. When I scan for different input devices, I get stuff such as orientation sensor and etc. Here is a pic of all the input devices on my phone (T-959 Galaxy S).
As you can see, none of these devices is a keyboard. I have a feeling that this is because my phone does not have a physical keyboard. (cypress is the capacitive keys, aries is the volume buttons, and mxt224 is the touchscreen controller)
After a bit more of research, I found that the accessibility api in android has limit capabilities for injecting events, but those are only very basic things such as switching view focus and etc (AccessibilityNodeInfo). However, I have a feeling that I might be able to extend it to support arrow key presses.
So currently, I am very confused on where to go. Has anyone ever done anything like this before? It seems that the simple injection of arrow keys (nothing else) is very frustrating due to the security features in Android. All suggestions are welcomed.
EDIT: I might not have been very clear, but I am fine with building this for rooted phones only. Only requirement is that this app has to run standalone on the phone without being hooked up to any external keyboards via otg or the computer via adb.
I wanted to simulate DPAD key press events few days back and I did find a solution which has its own limitation.
Arrow key press can be simulated using adb commandinput keyevent <keycode>.
So if you want to simulate a DPAD LEFT key press then use the adb commandadb input keyevent 21.
To reuse this bit of code and scale it forward, I created a standalone swing application where i select the device to which i need to send the key events and I can use the existing keyboard of my computer to type in the keys.[I map the keyboard key codes to android key codes].
I am further scaling the application by including remote and game pad buttons, once done, i'll upload the project on git.
Hope this helps.
IF you intention is to create an application that works on non rooted phones perhaps your best bet is to implement a new InputMethod using http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html