Android系统的组件的通信

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>
运行的效果:

上面是调用的界面:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值