当前位置:  编程技术>移动开发
本页文章导读:
    ▪Application Fundamentals-Broadcast receiver lifecycle(播音接收组件生命周期)        Application Fundamentals--Broadcast receiver lifecycle(广播接收组件生命周期) Broadcast receiver lifecycle---广播接收组件生命周期A broadcast receiver has single callback method:--翻译:广播接收组件只有唯一一个回.........
    ▪ 谷歌被甲骨文惹怒 不参加本年JavaOne大会        谷歌被甲骨文惹怒 不参加今年JavaOne大会 据国外媒体报道,谷歌周五宣布,由于甲骨文起诉谷歌侵犯Java知识产权,现决定放弃出席今年的JavaOne大会。   自2004年以来,谷歌每年都参加Jav.........
    ▪ Thinking Java 札记(一)       Thinking Java 笔记(一) 我在学校的时候就没有认真学习过Java,在开始学android的时候,也没有时间及时补上,现在有点时间,就觉得自己的基础太差了,所以开始把Thinking java的电子书拿出.........

[1]Application Fundamentals-Broadcast receiver lifecycle(播音接收组件生命周期)
    来源: 互联网  发布时间: 2014-02-18
Application Fundamentals--Broadcast receiver lifecycle(广播接收组件生命周期)
Broadcast receiver lifecycle---广播接收组件生命周期

A broadcast receiver has single callback method:--翻译:广播接收组件只有唯一一个回调方法:

void onReceive(Context curContext, Intent broadcastMsg)


   When a broadcast message arrives for the receiver, Android calls its onReceive()广播接收组件 method and passes it the Intent object containing the message. The broadcast receiver is considered to be active only while it is executing this method. When onReceive() returns, it is inactive.

当消息接受者接到广播消息,Android将立刻调用广播接收组件实例的 onReceive()方法,同时,消息封装在intent对象中以参数的方式传入该方法,该方法执行过程中,该广播接收组件实例的状态是活动状态。广播接收组件实例的onReceive()一旦执行完毕,广播接收组件实例的状态变为非活动状态。

   A process with an active broadcast receiver is protected from being killed. But a process with only inactive components can be killed by the system at any time, when the memory it consumes is needed by other processes.

翻译:活动状态的广播接收组件实例所属的进程是受系统保护的,不会被系统关闭的。但是对于非活动状态的广播接收组件实例所属的进程而言,一旦出现系统资源缺乏,为了腾出必要内存空间,系统随时可以杀死该进程。

   This presents a problem when the response to a broadcast message is time consuming and, therefore, something that should be done in a separate thread, away from the main thread where other components of the user interface run. If onReceive() spawns the thread and then returns, the entire process, including the new thread, is judged to be inactive (unless other application components are active in the process), putting it in jeopardy of being killed. The solution to this problem is for onReceive() to start a service and let the service do the job, so the system knows that there is still active work being done in the process.

翻译:需要注意的是,如果说对广播消息的响应是耗时操作的话(onReceive()方法中的代码),就需要考虑脱离主线程、以独立线程方式执行对消息的响应处理,这样可以避免阻塞现象的发生(寄宿在主线程之上的其他组件实例与用户交互过程被阻塞)。如果在onReceive()方法中在当前进程中创建一个独立的线程,该方法执行完毕后,当前进程可能被系统就认定为惰性进程(如果此时进程中的其他组件实例都处于惰性状态),当前进程是随时可能被系统关闭的。对这个问题的解决方式是:在onReceive()方法中以服务的方式来处理对消息的响应,这样可以使得系统认为当前进程依然是活动状态,避免被系统杀死。

The next section has more on the vulnerability of processes to being killed.

    
[2] 谷歌被甲骨文惹怒 不参加本年JavaOne大会
    来源: 互联网  发布时间: 2014-02-18
谷歌被甲骨文惹怒 不参加今年JavaOne大会
据国外媒体报道,谷歌周五宣布,由于甲骨文起诉谷歌侵犯Java知识产权,现决定放弃出席今年的JavaOne大会。

  自2004年以来,谷歌每年都参加JavaOne大会。今年的JavaOne大会将于9月中旬在旧金山召开,但谷歌表示,由于遭到甲骨文起诉,将不再参加今年的JavaOne大会。

  甲骨文本月12日起诉谷歌,称谷歌Android操作系统侵犯了甲骨文基于Java平台的几项知识产权,要求谷歌禁止使用甲骨文专利技术,并希望得到合理的赔偿。

  对此,谷歌Google开源项目办公室工程师约书亚·布洛赫(Joshua Bloch)在博客中称:“每年,我们都会参加一些有关开源软件的大会。我们认为,这是谷歌服务于开源社区,与业界共享经验的最佳机会。”

  “但今天,我们很遗憾地宣布,我们将不会参加今年的JavaOne。我们很希望参加此次大会,但甲骨文的诉讼使得我们不可能在此次大会上对Java和开源软件的未来发表看法。”

  此外,布洛赫还表示,甲骨文起诉的不仅仅是谷歌,而是针对整个开源界。对于甲骨文的诉讼,谷歌发言人亚伦·扎莫斯特(Aaron Zamost)当时就表示:“谷歌对甲骨文选择同时攻击谷歌和Java社区深表失望,这样的起诉是毫无依据的。”

    
[3] Thinking Java 札记(一)
    来源: 互联网  发布时间: 2014-02-18
Thinking Java 笔记(一)
我在学校的时候就没有认真学习过Java,在开始学android的时候,也没有时间及时补上,现在有点时间,就觉得自己的基础太差了,所以开始把Thinking java的电子书拿出来读一读。因为英语不好,所以读得很慢。我读的是英文版的。我觉得不要因为自己的英语不好,就老读中文版的,其实先进IT技术都是从国外先发明的,所以你想要领略地道的东西还是读读英文的好。
我决定把在读的过程中觉得需要记住的地方摘录下来,方便以后复习。嘿嘿!

1, Everything is an object.

2,Manipulate objects with references

3,Each object keeps its own storage for its fields; the fields are not shared among objects.

4,Scope of objects
Java objects do not have the same lifetimes as primitives. When you
create a Java object using new, it hangs around past the end of the scope.
Thus if you use:
{
String s = new String("a string");
} // End of scope
the reference s vanishes at the end of the scope. However, the String
object that s was pointing to is still occupying memory. In this bit of code, there is no way to access the object because the only reference to it is out of scope.


5,Default values for primitive members
Note carefully that the default values are what Java guarantees when the variable is used as a member of a class. This ensures that member
variables of primitive types will always be initialized (something C++
doesn’t do), reducing a source of bugs. However, this initial value may not be correct or even legal for the program you are writing. It’s best to always explicitly initialize your variables.
This guarantee doesn’t apply to “local” variables—those that are not fields of a class. Thus, if within a method definition you have:
int x;
Then x will get some arbitrary value (as in C and C++); it will not
automatically be initialized to zero.


6,Return keyword
You can also see the use of the return keyword, which does two things.
First, it means “leave the method, I’m done.” Second, if the method
produces a value, that value is placed right after the return statement.


7,Name visibility
A problem in any programming language is the control of names.how do you distinguish one name from another and prevent the two names from “clashing?” To solve this problem, C++ introduced
namespaces using additional keywords In fact, the Java creators want you to use your Internet domain name in reverse since those are guaranteed to be unique.
After your reversed domain name, the dots are intended to represent subdirectories
so now the entire package name is lowercase.

8,Using other components
This is accomplished by telling the Java compiler exactly what classes you want
using the import keyword. import tells the compiler to bring in a
package, which is a library of classes. (In other languages, a library could
Chapter 2: Everything is an Object 101
consist of functions and data as well as classes, but remember that all
code in Java must be written inside a class.)

9,The static keyword
One is if you want to have only one piece of storage for a particular piece of data, regardless of how many objects are created, or even if no objects are created. The other is if you need a method that isn’t associated with any particular object of this class. That is, you need a method that you can call even if no objects are created. You can achieve both of these effects with
the static keyword. When you say something is static, it means that data or method is not tied to any particular object instance of that class. So even if you’ve never created an object of that class you can call a static method or access a piece of static data. With ordinary, non-static data and methods you must create an object and use that object to access the data or method, since non-static data and methods must know the particular object they are working with. Of course, since static methods don’t need any objects to be created before they are used, they cannot directly access non-static members or methods by simply calling those other members without referring to a named object (since non-static members and methods must be tied to a particular object).



10,The name of the class is the same as the name of the file. When you’re creating a stand-alone program such as this one, one of the classes in the file must have the same name as the file. (The compiler complains if you don’t do this.)

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
NOSQL iis7站长之家
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3