public class TinyDialer extends Activity
{
/** Called when the activity is first created. */
private Button button;
private EditText phonenumber;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main); button = (Button)findViewById(R.id.button_id);
phonenumber = (EditText)findViewById(R.id.phonenumber_id);
button.setOnClickListener(new OnClickListener(){
public void onClick(View v){
String call = phonenumber.getText().toString();
if(PhoneNumberUtils.isGlobalPhoneNumber(call)){
Intent i = new Intent();
i.setAction(Intent.ACTION_CALL);
i.setData(Uri.parse(call));
startActivity(i);
}
else{
Toast.makeText(TinyDialer.this, R.string.correct_number, Toast.LENGTH_LONG).show();
}
}
});
这个程序是实现拨号的,程序本身没有错误,但是不能进行拨号功能,不知道还有什么地方有错误,帮忙帮我找出来下,
谢谢~~~
{
/** Called when the activity is first created. */
private Button button;
private EditText phonenumber;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main); button = (Button)findViewById(R.id.button_id);
phonenumber = (EditText)findViewById(R.id.phonenumber_id);
button.setOnClickListener(new OnClickListener(){
public void onClick(View v){
String call = phonenumber.getText().toString();
if(PhoneNumberUtils.isGlobalPhoneNumber(call)){
Intent i = new Intent();
i.setAction(Intent.ACTION_CALL);
i.setData(Uri.parse(call));
startActivity(i);
}
else{
Toast.makeText(TinyDialer.this, R.string.correct_number, Toast.LENGTH_LONG).show();
}
}
});
这个程序是实现拨号的,程序本身没有错误,但是不能进行拨号功能,不知道还有什么地方有错误,帮忙帮我找出来下,
谢谢~~~
i.setData(Uri.parse(call));;parse(tel"://"+call)书上是这么写的。。不知道哪个对,也是初学。。
call应当要权限的,你设置了吗?
好像是这样写吧:
i.setData(Uri.parse("tel://"+call));