zoukankan      html  css  js  c++  java
  • android service基础

    service基础知识点总结


    service启动方式分为两种

    • startService(Intent intent) onCreate-->onStartCommand,其中onStartCommand一定会被执行。stopService()关闭service
    • bindService(Intent service,ServiceConnection conn,int flags) onCreate-->onBind,其中onBind方法只被调用一次,通过unBindService()关闭service

    start一个service后,service运行在独立的线程中,不再和原来的组件有任何关联。bind一个service后,service给组件提供了一个接口,可以互相交互。

    在写service的demo时遇到异常:java.lang.IllegalArgumentException: Service Intent must be explicit: Intent。服务意图必须是显示声明的。

    解决方法:

    Intent intent = new Intent();  
    intent.setAction("com.yulore.recognize.android");  
    intent.setPackage(context.getPackageName());    //兼容Android 5.0  
    context.startService(intent);  
    

    or

    Intent intent = new Intent(com.yulore.test.AppService.class);  
    context.startService(intent);  
    
  • 相关阅读:
    bloom filter
    【转】单实例
    Log Structured Merge Trees(LSM) 原理
    【转】南网成立始末
    变电站综合自动化系统
    bsp tree
    Private Bytes,Working Set,Virtual Size的区别
    kdtree
    asp.net下载文件几种方式
    C# FTP操作
  • 原文地址:https://www.cnblogs.com/lxstudy/p/14709982.html
Copyright © 2011-2022 走看看