开发者

Make Call - it call over and over and can´t be closed or end by button hang up

today I tried to use following code in app and it make problem. When I call activity with this code, phone start calling (which is ok), but than it keep calling and calling and even if I try hang up with red button as always it end it and than it start calling again. It is like some kind of loop, but I never set any. Any idea, what is wrong?

@Override
public void onCreate(Bundle savedInstanceState) 
{
s开发者_如何学Cuper.onCreate(savedInstanceState);

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);

finish();
}//protected void on...


That makes perfect sense.

When you press the red button, you come back to the previous page, which in your case is this activity. It goes into the onCreate() again, and calls again.

Try to either:

  1. place the call in the previous activity, not in the onCreate.

  2. place the call in the action method of some button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜