1. 一键启动的过程

1.1 对于global key, 系统会根据global_keys.xml发送消息给某个组件

<key keyCode="KEYCODE_TV" component="com.thisway.app_0001_leddemo/.MyBroadcastReceiver" />

1.2 APP应该注册广播消息的接收者

1.2.1 编写BroadcastReceiver派生类, 实现消息处理函数
package com.thisway.app_0001_leddemo;//注意包名,可以是自己的报名,但是后面的实验当中的操作需要根据包名修改import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.widget.Toast;/*** Created by alienware on 2017/5/12.*/public class MyBroadcastReceiver extends BroadcastReceiver{    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "myReceiver receive", Toast.LENGTH_SHORT).show();

        Intent intentNewTask=new Intent(context,MainActivity.class);
        intentNewTask.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intentNewTask);

    }
}
1.2.2 注册派生类: 修改 AndroidManifest.xml,添加下列代码,实现静态注册
<receiver android:name=".MyBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.GLOBAL_BUTTON"/>
    </intent-filter></receiver>

1.3 然后在该组件中启动app

延伸阅读

学习是年轻人改变自己的最好方式-Java培训,做最负责任的教育,学习改变命运,软件学习,再就业,大学生如何就业,帮大学生找到好工作,lphotoshop培训,电脑培训,电脑维修培训,移动软件开发培训,网站设计培训,网站建设培训学习是年轻人改变自己的最好方式