Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.baruberbagi.callphone;
- import androidx.appcompat.app.AppCompatActivity;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- Button permanencall,manualCall;
- EditText edtManual;
- String noTLP = "tel:1234567";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- permanencall = findViewById(R.id.btnPermanenCall);
- manualCall = findViewById(R.id.btnManualCall);
- edtManual = findViewById(R.id.edtManual);
- permanencall.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_DIAL);
- intent.setData(Uri.parse(noTLP));
- startActivity(intent);
- }
- });
- manualCall.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String nomor = edtManual.getText().toString();
- if (nomor.equals("")){
- edtManual.setError("Harus di isi");
- }else {
- Intent i = new Intent(Intent.ACTION_DIAL);
- i.setData(Uri.parse("tel:"+nomor));
- startActivity(i);
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement