本篇介绍Android开机自动启动应用的开发过程。

1:添加自启动权限

在AndroidManifest.xml添加权限

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

2:添加自启动接收,决定用哪个BroadcastReceiver作为应用入口

在AndroidManifest.xml添加入口

<receiver android:name="com.zpd.scanadapter.BootUp" ><intent-filter>    <action android:name="android.intent.action.BOOT_COMPLETED" />    <category android:name="android.intent.category.LAUNCHER" />intent-filter>receiver>

BootUp的实现

public class BootUp extends BroadcastReceiver {  @Override    public void onReceive(Context context, Intent intent) {        //在此启动应用    }}

 3:应用退出限制

A:监听BACK返回键

    @Override    public boolean onKeyDown(int keycode, KeyEvent e) {        if (keycode == KEYCODE_BACK) {            return true;        }        return super.onKeyDown(keycode, e);    }    @Override    public boolean onKeyUp(int keycode ,KeyEvent e) {        if (keycode == KeyEvent.KEYCODE_BACK) {            return true;        }        return super.onKeyUp(keycode,e);    }

B:禁止HOME键

此项功能需要调用到我司CapipadSDK.jar包里的CapipadInterfaceManager的setHomekeyandStatusbarState()方法。

详细可参看我司的接口说明书:http://www.cnblogs.com/ouyanghy/p/8479128.html  

调用如下:

{
  boolean state;//true key home enable,false disable
  CapipadInterfaceManager intf= new CapipadInterfaceManager(getContext());
  intf.setHomekeyandStatusbarState(state);}

 

转载于:https://www.cnblogs.com/ouyanghy/p/9007221.html

更多相关文章

  1. Android(安卓)ContentProvider简介
  2. [Android(安卓)Pro] service中显示一个dialog 或者通过windowman
  3. Android(安卓)10动态申请读写权限
  4. Android(安卓)SD卡中压缩包解压(ZIP文件)
  5. android短信开发
  6. Android(安卓)向桌面添加删除快捷方式
  7. Android开发之实现锁屏功能
  8. 【android】 Unable to open content: file:///sdcard/hello.3gp
  9. android开机自动唤醒屏幕、打开锁屏页并启动app

随机推荐

  1. Android7.0适配教程与心得
  2. android集成百度地图SDK 自定义keystore
  3. Android开发资料视频教程(光盘6.2G)
  4. 【转】 Android转屏时禁止调用onCreate
  5. Android app内部下载安装
  6. android init 进程分析
  7. Android(安卓)TabActivity的嵌套
  8. 在低版本Android上使用Material Design
  9. Android环境SDK搭建问题
  10. Android简易计算器(破烂Alpha版,后续更新)