android拨打电话

package com.hanqi.test;
package com.hanqi.test;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
     EditText editText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       editText = (EditText)findViewById(R.id.ph1);
    }
    public void bt_1(View v){
       if( editText.getText().toString()==null){
           return;}
        else{
           Intent intent= new Intent(Intent.ACTION_DIAL);

           Uri uri=Uri.parse("tel:"+(editText.getText().toString()));
           intent.setData(uri);
           startActivity(intent);

       }
View Code

 


posted @ 2016-05-14 09:51  lizhe313  阅读(124)  评论(0编辑  收藏  举报