您的位置:首页 > 移动开发 > Android开发

android自动拨打电话

2014-10-27 16:19 281 查看
1. Create Android Application Project

2. In MainActivity.java, add the below:

package com.example.testandroid1;

import android.app.Activity;

import android.content.Intent;

class MainActivity extends Activity {

.....

public void onButtonClick(View v)

{

Intent intent =new Intent(Intent.ACTION_CALL,Uri.parse("tel:110"));

MainActivity.this.startActivity(intent);

}

}

3. In AndroidManifest.xml, add the below. Its level is same as <uses-sdk>

<uses-permission android:name="android.permission.CALL_PHONE" />

4. Right click the project and choose Run as -> Android Device Chooser ->Choose device



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: