pr18 MAD
pr18 MAD
pr18_1;
<LinearLayout import android.annotation.SuppressLint;
import android.content.Intent;
xmlns:android="http://schemas.android.com/apk/res/and import android.net.Uri;
roid" import android.os.Bundle;
android:layout_width="match_parent" import android.view.View;
android:layout_height="match_parent" import android.widget.Button;
android:layout_weight="1" import android.widget.EditText;
android:orientation="vertical"> import
androidx.appcompat.app.AppCompatActivity;
<EditText public class MainActivity extends AppCompatActivity
android:id="@+id/et1" {
android:layout_width="match_parent" EditText et1;
android:layout_height="50dp" /> Button btn;
@SuppressLint("MissingInflatedId")
<Button @Override
android:id="@+id/btn" protected void onCreate(Bundle
android:layout_width="match_parent" savedInstanceState) {
android:layout_height="50dp" super.onCreate(savedInstanceState);
android:text="Submit" /> setContentView(R.layout.activity_main);
</LinearLayout> et1=findViewById(R.id.et1);
btn=findViewById(R.id.btn);
btn.setOnClickListener(v->
{
String url=et1.getText().toString();
Intent intent=new
Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
});
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/an xmlns:android="http://schemas.android.com/apk/res
droid" /android"
xmlns:app="http://schemas.android.com/apk/res- xmlns:app="http://schemas.android.com/apk/res-
auto" auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<!-- Button to trigger dialing --> <!-- Button to trigger dialing -->
<Button <Button
android:id="@+id/btn" android:id="@+id/btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Dial Number" android:text="Dial Number"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/
>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout
>