zoukankan      html  css  js  c++  java
  • android activity pass data to accessibilityservice 数据传递

    不同类型的 service 传递数据的方式不同,accessibilityservice 运行在独立进程,且被系统接管,比较特别

    在 AccessibilityService 的 onCreate 内加一个 BroadcastReceiver

    val broadcast = object:BroadcastReceiver(){
            override fun onReceive(context: Context?, intent: Intent?) {
                val what = intent?.getStringExtra("hello",  "dlrow")!!
            }
    }
    registerReceiver(broadcast, IntentFilter("hangj.cnblogs.com"))
    

    onUnbind 里

    unregisterReceiver(broadcast)
    

    在 Activity 内 sendBroadcast

    sendBroadcast(Intent().apply {
        action="hangj.cnblogs.com"
        putExtra("hello", "world")
    })
    

    还可以用 socket

  • 相关阅读:
    高级查询及分页总结
    SQL编程
    线程同步
    创建和启动线程
    错题集04
    错题集03
    错题集02
    错题集
    新闻发布系统
    九大内置对象
  • 原文地址:https://www.cnblogs.com/hangj/p/13744210.html
Copyright © 2011-2022 走看看