番号をダイヤルするには、次のコードがあります
package com.example.callapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
makecall(); }
public void makecall()
{
Intent call = new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:90324567"));
startActivity(call);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
このアプリを実行すると、ダイヤラーが表示され、番号がダイヤルされます。ダイヤラーを非表示にして、アプリで通話アクティビティを表示したい - たとえば、この番号をダイヤルしています - XXXX
また、特定の時間後に通話を終了するにはどうすればよいですか? 時間とともにアプリ画面にメッセージを表示しますか?