Android系统的组件的通信
2011-08-02 09:26
127 查看
intent类 主要包括component action data category extras flags
intentfilter 对象负责过滤掉无法响应和处理的intent 只将自己关心的intent 接受进来处理
一个intent想要被一个组件处理,必须通过三个环节检查: 检查action 检查data 检查category
下面是我应用的一个程序:
调用系统的拨号程序
java代码
package jm.out;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
//继承自Activity的子类
public class DialconnectActivity extends Activity {
Button btnDial;
@Override
public void onCreate(Bundle savedInstanceState) {//重写onCreate方法
super.onCreate(savedInstanceState);
setContentView(R.layout.main);//设置屏幕显示内容
btnDial = (Button)this.findViewById(R.id.btDial);//获得屏幕上按钮对象引用
btnDial.setOnClickListener(new Button.OnClickListener(){//为按钮添加点击事件的监听器
@Override
public void onClick(View v) {//重写onClick方法
Intent myIntent = new Intent(Intent.ACTION_DIAL);//创建Intent对象
DialconnectActivity.this.startActivity(myIntent);//启动Android内置的拨号程序
}
});
}
}
xml代码:
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/btDial"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="拨号" />
</LinearLayout>
运行的效果:
上面是调用的界面:
intentfilter 对象负责过滤掉无法响应和处理的intent 只将自己关心的intent 接受进来处理
一个intent想要被一个组件处理,必须通过三个环节检查: 检查action 检查data 检查category
下面是我应用的一个程序:
调用系统的拨号程序
java代码
package jm.out;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
//继承自Activity的子类
public class DialconnectActivity extends Activity {
Button btnDial;
@Override
public void onCreate(Bundle savedInstanceState) {//重写onCreate方法
super.onCreate(savedInstanceState);
setContentView(R.layout.main);//设置屏幕显示内容
btnDial = (Button)this.findViewById(R.id.btDial);//获得屏幕上按钮对象引用
btnDial.setOnClickListener(new Button.OnClickListener(){//为按钮添加点击事件的监听器
@Override
public void onClick(View v) {//重写onClick方法
Intent myIntent = new Intent(Intent.ACTION_DIAL);//创建Intent对象
DialconnectActivity.this.startActivity(myIntent);//启动Android内置的拨号程序
}
});
}
}
xml代码:
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/btDial"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="拨号" />
</LinearLayout>
运行的效果:
上面是调用的界面:
相关文章推荐
- android组件间的交互和进程间IPC 通信
- Android开发中遇到的系统组件bug
- Android-Activity之间显示和隐式跳转-Date 数据跳转-调用系统的的组件
- 在Android系统使用socket在Java层和native之间数据通信
- Android系统Binder机制中的四个组件Client、Server、Service Manager和Binder驱动程序的关系
- 使用Broadcast实现android组件之间的通信
- android组件间通信又一种方式
- Android A/B System OTA分析(三)主系统和bootloader的通信
- Android学习-----Android组件通信PendingIntent
- android系统中间件移植-3G4G通信模块适配
- 关于Android系统四大组件的理解分析
- Android组件间通信库EventBus学习
- Android组件间通信库EventBus学习
- Android组件间通信库EventBus学习观察者模式
- android系统service组件的线程关系
- Android零基础入门第2节:Android 系统架构和应用组件那些事
- Android 用Intent调用系统中经常被用到的组件
- Android 框架炼成 教你如何写组件间通信框架EventBus(三)
- android组件间通信
- android系统binder通信架构分析