Android调用系统的打电话和发短信界面(1.将消息内容带过去2.实现群发)

package com.example.myapi.sms;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.myapi.R;

public class SMSActivity extends Activity implements OnClickListener{
    private Button btn_sms;
    private Button btn_phone;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sms);
        btn_sms = (Button)findViewById(R.id.sms_btn_sms);
        btn_phone = (Button)findViewById(R.id.sms_btn_phone);
        btn_sms.setOnClickListener(this);
        btn_phone.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch(v.getId()){
        case R.id.sms_btn_sms://调用系统的发短息界面
            //系统默认的action,用来打开默认的短信界面
            intent.setAction(Intent.ACTION_SENDTO);
            //需要发短息的号码,电话号码之间用“;”隔开
            intent.setData(Uri.parse("smsto:"+10086+";"+10002+";"+10003));
            intent.putExtra("sms_body", "别紧张,这仅仅是是一个测试!OY");
            startActivity(intent);
            break;
        case R.id.sms_btn_phone://调用系统的打电话界面
            //系统默认的action,用来打开默认的电话界面
            intent.setAction(Intent.ACTION_CALL);
            //需要拨打的号码
            intent.setData(Uri.parse("tel:"+10086));
            startActivity(intent);
            break;
        }
    }

}

 

posted on 2013-08-15 14:52  飘杨......  阅读(2623)  评论(0编辑  收藏  举报