当前位置: 编程技术>移动开发
本页文章导读:
▪Binder机制分析【1】-简介 Binder机制分析【一】-简介
Binder,英文意思是别针,回形针。在Android中,它是用于完成进程间通信(IPC),在它的官方网站上是这样定义的。binder是一个分布式的组件架构,它类似于COM和C.........
▪ 让背景模糊不清的效果 让背景模糊的效果
设置透明度(这是窗体本身的透明度,非背景)
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=0.3f;
getWindow().setAttributes(lp);
alpha.........
▪ RadioBox单选框施用 RadioBox单选框应用
一、RadioBox单选框的使用
public RadioGroup mRadioGroup1;
public RadioButton mRadio1, mRadio2;
public Button button1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle saved.........
[1]Binder机制分析【1】-简介
来源: 互联网 发布时间: 2014-02-18
Binder机制分析【一】-简介
Binder,英文意思是别针,回形针。在Android中,它是用于完成进程间通信(IPC),在它的官方网站上是这样定义的。binder是一个分布式的组件架构,它类似于COM和CORBA。
binder 通信是一种client-server 的通信结构,
1. 从表面上来看,是client 通过获得一个server 的代理接口,对server 进行直接调用;
2. 实际上,代理接口中定义的方法与server 中定义的方法是一一对应的;
3.client 调用某个代理接口中的方法时,代理接口的方法会将client 传递的参数打包成为Parcel 对象;
4. 代理接口将该Parcel 发送给内核中的binder driver.
5.server 会读取binder driver 中的请求数据,如果是发送给自己的,解包Parcel 对象,处理并将结果返回;
6. 整个的调用过程是一个同步过程,在server 处理的时候,client 会block 住。
Binder是一种架构,这种架构提供了服务器端接口,Binder驱动,客户端接口三个模块。
Binder服务器:
Binder服务器实际上是一个Binder对象,该对象一旦创建,就启动了一个隐藏线程,该线程不断的接受Binder驱动所发回的消息,收到消息后,执行Binder对象中的onTransact()
方法。因此,要实现一个Binder服务器,就必须重载onTransact()方法。
Binder驱动:
Binder服务器端的Binder对象创建时,就会在Binder驱动中创建一个mRemote对象,该对象也是Binder类。客户端要访问Binder服务器时,都需要见过该mRemote对象.
Binder客户端:
Binder客户端要想访问服务器,必须先获取mRemote对象,然后通过mRemote对象的transact()方法调用。Binder驱动重载了该方法,重载的内容有:
1.以线程间消息通信的模式,像服务器端发送客户端传过来的参数。
2.挂起当前线程(客户端线程),等待服务器端执行完后的通知(notify)。
3.接收服务器端的通知,然后继续执行客户端线程,并返回到客户端代码区。
由此可见,客户端要调用服务器端的binder,必须通过binder驱动进行中转,即存在两个Binder对象,一个服务器端的Binder对象,一个驱动中的Binder对象,不同的是驱动中的Binder对象不会再额外产生一个线程。
下一章介绍下Binder服务器的实现
Binder,英文意思是别针,回形针。在Android中,它是用于完成进程间通信(IPC),在它的官方网站上是这样定义的。binder是一个分布式的组件架构,它类似于COM和CORBA。
binder 通信是一种client-server 的通信结构,
1. 从表面上来看,是client 通过获得一个server 的代理接口,对server 进行直接调用;
2. 实际上,代理接口中定义的方法与server 中定义的方法是一一对应的;
3.client 调用某个代理接口中的方法时,代理接口的方法会将client 传递的参数打包成为Parcel 对象;
4. 代理接口将该Parcel 发送给内核中的binder driver.
5.server 会读取binder driver 中的请求数据,如果是发送给自己的,解包Parcel 对象,处理并将结果返回;
6. 整个的调用过程是一个同步过程,在server 处理的时候,client 会block 住。
Binder是一种架构,这种架构提供了服务器端接口,Binder驱动,客户端接口三个模块。
Binder服务器:
Binder服务器实际上是一个Binder对象,该对象一旦创建,就启动了一个隐藏线程,该线程不断的接受Binder驱动所发回的消息,收到消息后,执行Binder对象中的onTransact()
方法。因此,要实现一个Binder服务器,就必须重载onTransact()方法。
Binder驱动:
Binder服务器端的Binder对象创建时,就会在Binder驱动中创建一个mRemote对象,该对象也是Binder类。客户端要访问Binder服务器时,都需要见过该mRemote对象.
Binder客户端:
Binder客户端要想访问服务器,必须先获取mRemote对象,然后通过mRemote对象的transact()方法调用。Binder驱动重载了该方法,重载的内容有:
1.以线程间消息通信的模式,像服务器端发送客户端传过来的参数。
2.挂起当前线程(客户端线程),等待服务器端执行完后的通知(notify)。
3.接收服务器端的通知,然后继续执行客户端线程,并返回到客户端代码区。
由此可见,客户端要调用服务器端的binder,必须通过binder驱动进行中转,即存在两个Binder对象,一个服务器端的Binder对象,一个驱动中的Binder对象,不同的是驱动中的Binder对象不会再额外产生一个线程。
下一章介绍下Binder服务器的实现
[2] 让背景模糊不清的效果
来源: 互联网 发布时间: 2014-02-18
让背景模糊的效果
设置透明度(这是窗体本身的透明度,非背景)
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=0.3f;
getWindow().setAttributes(lp);
alpha在0.0f到1.0f之间。1.0完全不透明,0.0f完全透明
设置黑暗度
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.dimAmount=0.5f;
getWindow().setAttributes(lp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dimAmount在0.0f和1.0f之间,0.0f完全不暗,1.0f全暗
设置背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
[3] RadioBox单选框施用
来源: 互联网 发布时间: 2014-02-18
RadioBox单选框应用
一、RadioBox单选框的使用
public RadioGroup mRadioGroup1;
public RadioButton mRadio1, mRadio2;
public Button button1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.radio);
button1 = (Button) findViewById(R.id.button1);
mRadioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1);
mRadio1 = (RadioButton) findViewById(R.id.radio1);
mRadio2 = (RadioButton) findViewById(R.id.radio2);
/* RadioGroup用OnCheckedChangeListener来执行 */
mRadioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if (checkedId == mRadio1.getId()) {
/* 把mRadio1的内容传到mTextView1 */
toast(mRadio1.getText().toString());
} else if (checkedId == mRadio2.getId()) {
/* 把mRadio2的内容传到mTextView1 */
toast(mRadio2.getText().toString());
}
}
});
button1.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
mRadioGroup1.clearCheck();
}
});
}
public void toast(String str) {
Toast.makeText(RadioBoxNew.this, str, Toast.LENGTH_LONG).show();
}
最新技术文章: