-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivity2.java
More file actions
45 lines (39 loc) · 1.42 KB
/
Activity2.java
File metadata and controls
45 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.mycaptain.fun;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.view.View;
import android.net.Uri;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Bundle;
public class Activity2 extends AppCompatActivity {
EditText call_et;
ImageButton call_bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
call_et = findViewById(R.id.call_func);
call_bt = findViewById(R.id.call_bt);
call_bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phone = call_et.getText().toString();
if(phone.isEmpty()) {
Toast.makeText(getApplicationContext(), "Please Enter Number !"
, Toast.LENGTH_SHORT).show();
}
else {
String s = "tel:" + phone;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(s));
startActivity(intent);
}
}
});
}
}