10.8 Android Input System _ Combat use Globalkey One-click Start Program

Source: Internet
Author: User

11. Use Globalkey one-click Start Program
Reference article:
Android two kinds of registration, send broadcast the difference
Http://www.jianshu.com/p/ea5e233d9f43

"Android" dynamically registering a broadcast receiver
http://blog.csdn.net/etzmico/article/details/7317528

Android Beginner-start activity in Broadcastreceiver
http://blog.csdn.net/cnmilan/article/details/50617802

A. For global key, the system sends a message to a component based on the Global_keys.xml
<key keycode= "Keycode_tv" component= "com.thisway.app_0001_leddemo/. Mybroadcastreceiver "/>

Modify/work/android-5.0.2/frameworks/base/core/res/res/xml/global_keys.xml

Compile:
Mmm frameworks/base/core/res
It generates framework-res.apk and copies it to a single board/system/framework/

B. The app should register the recipient of the broadcast message
B.1 writing Broadcastreceiver derived classes, implementing message handler functions

Mybroadcasereceiver.java

Import Android.content.BroadcastReciver;

Import Android.content.Context;

Import android.content.Intent;

Import Android.widget.Toast;

public class Mybroadcastreceiver extends broadcastreceiver{

public void OnReceive (Context context,intent Intent) {

Toast.maketext (Context, "Get Broadcastreceiver", Toast length_short). Show ();

}

}
B.2 registering derived classes: modifying Androidmanifest.xml
C. Then launch the app in the component


Source code Download method
First time:
git clone https://github.com/weidongshan/APP_0001_LEDDemo.git

Remove the V3 version and modify it on its basis
git checkout v3//Add button, checkbox's click Method


Experiment:
A. Hand-broadcasting
Am Broadcast-a android.intent.action.global_button-n com.thisway.app_0001_leddemo/. Mybroadcastreceiver

B. Trigger with a button
Modify/work/android-5.0.2/frameworks/base/core/res/res/xml/global_keys.xml
Add to:
<key keycode= "Keycode_tv" component= "com.thisway.app_0001_leddemo/. Mybroadcastreceiver "/>

Compile:
Mmm frameworks/base/core/res
It will generate framework-res.apk (out/target/product/tiny4412/system/framework/framework-res.apk)

Put the framework-res.apk on the veneer:
Remount/system first in RW mode before copying:
Su
Mount-o Remount,rw/system

Ifconfig eth0 192.168.1.100
BusyBox mount-t nfs-o nolock,vers=2 192.168.1.123:/work/nfs_root/data/nfs

CP framework-res.apk/system/framework/

Modify the KL file for the driver (the TV key is not required for the TV key Scancode 377)
Cp/system/usr/keylayout/generic.kl/data/system/devices/keylayout/inputemulatorfrom100ask_net.kl

Insmod Inputemulator.ko

Analog escalation Keys:
SENDEVENT/DEV/INPUT/EVENT5 1 377 1
SENDEVENT/DEV/INPUT/EVENT5 1 377 0
SENDEVENT/DEV/INPUT/EVENT5 0 0 0

You can also use the following command to simulate keys without using a driver:
Input KeyEvent TV


Source code Download method
First time:
git clone https://github.com/weidongshan/APP_0001_LEDDemo.git

Remove V9 Version
git checkout v9//Add broadcastreceiver to start itself

10.8 Android Input System _ Combat use Globalkey One-click Start Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.