代码如下:
class buttonTelListen implements OnClickListener{
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:13545451111"));
startActivity(intent);
}
}
class buttonSMSListen implements OnClickListener{
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setAction(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:13545451111"));
intent.putExtra("sms_body", "Hello liukang");
startActivity(intent);
}
}
在AndroidManifest.xml中添加权限:
在application外层
</application>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>