博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android基础
阅读量:5079 次
发布时间:2019-06-12

本文共 3949 字,大约阅读时间需要 13 分钟。

1.broadcast receivers can be either declared in the manifest or created dynamically in code (as objects) and registered with the system by calling.

2.Building an Intent-Component name:

When starting a , you shouldalways specify the component name. Otherwise, you cannot be certain what service will respond to the intent, and the user cannot see which service starts.

3.implicit intent:

It's possible that a user won't have anyapps that handle the implicit intent you send to . If that happens, the call will fail and your app will crash. To verify that an activity will receive the intent, call on your object. If the result is non-null, then there is at least one app that can handle the intent and it's safe to call. If the result is null, you should not use the intent and, if possible, you should disable the feature that issues the intent.

4.intent filters- :

In order to receive implicit intents, you  must include the  category in the intent filter. The methods  and  treat all intents  as if they declared the category.  If you do not declare this category in your intent filter, no implicit intents will resolve to  your activity.

tip: To avoid inadvertently running a different app's, always use an explicit intent to start your own service and do not declare intent filters for your service.

 5.Shutting Down an Activity-,:

Note: In most cases, you should not explicitly finish an activity using these methods.The Android system manages the life of an activity for you, so you do not need to finish your own activities. Calling these methods could adversely affect the expected user experience and should only be used when you absolutely do not want the user to return to this instance of the activity.

6.You should use to write crucial persistent data (such as user edits) to storage. However, you should be selective about what information must be retained during , because any blocking procedures in this method block the transition to the next activity and slow the user experience.

7.The system calls before making the activity vulnerable to destruction. The system passes this method a in which you can save  state information about the activity as name-value pairs, using methods such as and . Then, if the system kills your application process and the user navigates back to your activity, the system recreates the activity and passes the to both and . Using either of these methods, you can extract your saved state from the and restore the activity state. If there is no state information to restore, then the passed to you is null (which is the case when the activity is created for the first time).

8.Activity-Fragment-Transaction-commit():

You can commit a transaction using  only prior to the activity  (when the user leaves the activity). If you attempt to commit after that point, an exception will be thrown. This is because the state after the commit can be lost if the activity needs to be restored. For situations in which its okay that you lose the commit, use .

9.The most significant difference in lifecycle between an activity and a fragment is how one is stored in its respective back stack. An activity is placed into a back stack of activities that's managed by the system when it's stopped, by default (so that the user can navigate back to it with the Back button, as discussed in ). However, a fragment is placed into a back stack managed by the host activity only when you explicitly request that the instance be saved by calling  during a transaction that removes the fragment.

10.Loader tip:

the given  implementation is associated with the loader, and will be called when the loader state changes. If at the point of this call the caller is in its started state, and the requested loader already exists and has generated its data, then the system calls  immediately (during ), so you must be prepared for this to happen. See  for more discussion of this callback

11.

转载于:https://www.cnblogs.com/sorouyun/p/3591667.html

你可能感兴趣的文章
JS对象的几种创建方式
查看>>
001 centos7中的安装
查看>>
091实战 Nginx配置(日志服务器中关于日志的产生)
查看>>
详解python2 和 python3的区别[附实例]
查看>>
cracer教程3----信息收集
查看>>
冒泡排序
查看>>
Java里子类调用父类构造方法问题
查看>>
linux环境jdk+tomcat搭建
查看>>
iOS文字自适应 浅谈
查看>>
初学java之异常类
查看>>
Git安装与配置
查看>>
Android面试收集录 网络与加密
查看>>
Android软件开发-AutoCompleteTextView、MultiAutoCompleteTextView
查看>>
uva 10780
查看>>
php代码如何加域名授权?开源php项目如何保护版权 商业授权?
查看>>
埃氏筛法——素数的快速筛选
查看>>
PBN飞越转弯Flyover衔接DF航段保护区组图
查看>>
小程序将名片信息存入手机系统通讯录
查看>>
软件项目团队建设的“三个中心”
查看>>
Leetcode 366: Find Leaves of Binary Tree
查看>>