Android service tip!
来源:互联网 发布:淘宝账号被冻结支付宝 编辑:程序博客网 时间:2024/05/18 12:32
1. Service is running main application thread, same as the UI thread, startService or bindService will not create a new thread, so if there are some long time work in service, service should create a new thread for them.
2. The bindService() is a asynchronous, the return value doesn't mean that the service is connected successfully, so client should judge if the connection to service is successfully when onServiceConnected is called.
3. Context related:
If the client is an activity, there are two important steps to take to ensure that the binding survives a configuration change, like a screen rotation:
1) Instead of calling bindService() on the activity itself, call bindService() on the Application Context (obtained via getApplicationContext()).
2. Make sure the ServiceConnection gets from the old instance of the activity to the new one, probably via onRetainNonConfigurationInstance().
This allows the binding to persist between activity instances.
4.
- Android service tip!
- Android Baseline小tip
- Android Baseline小tip
- Android开发tip
- Web Service Tip: JSPs Calling Web Services
- android LoaderManger加载数据Tip
- Android Tip 之倒计时功能
- Android 开发 Tip 9 -- TouchDelegate
- Android 开发 Tip 13 -- generateViewId
- Android 开发 Tip 14 -- Singleton
- tip
- Tip
- tip
- Tip:
- TIP
- Tip
- tip
- Tip
- 数据备份技术的安全现状磁盘阵列技术未来存储市场的两点
- jquery ajax 方法及各参数详解
- Jack Dorsey:最好的技术要让用户浑然不觉
- 经纬度计算距离
- HDU 4230 Robot Navigation (记忆化广度优先搜索)
- Android service tip!
- IBM WebSphere Application Server
- 1、1、2、3、5、8、13、21、34...... 求第X位数是多少, 用递归算法实现。
- 设计模式的几种原则
- 主窗口最小化后其子窗口非模态对话框消失
- 网口也可以烧写程序?W7100!
- delete和truncate的区别
- 用C语言实现程序的多态性
- 日志分析软件awstats的安装使用简易指南