how to sent one intent to other navigate the page usig android app (android project work with source code)
how to sent one intent to other navigate the page usig android app
xml source code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".child">
<Button
android:id="@+id/button2"
android:layout_width="402dp"
android:layout_height="53dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="Back"
android:background="#47b04b"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.074"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.935"
tools:ignore="MissingConstraints" />
<Button
android:id="@+id/search"
android:layout_width="408dp"
android:layout_height="261dp"
android:layout_above="@+id/button2"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="371dp"
android:background="@drawable/search"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.121"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.278" />
<Button
android:id="@+id/sms"
android:layout_width="390dp"
android:layout_height="242dp"
android:layout_above="@+id/button2"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="176dp"
android:layout_marginEnd="21dp"
android:layout_marginRight="21dp"
android:layout_marginBottom="60dp"
android:background="@drawable/sms"
android:text=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
Main activity source codepackage sherazkhan801.blogspot.test;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)findViewById(R.id.btn1);
Button btn2=(Button)findViewById(R.id.button2);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(view.getContext(),child.class);
startActivity(intent);
}
});
}
}intent activitypackage sherazkhan801.blogspot.test;
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 java.security.AccessController;
public class child extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_child);
final Button serch=(Button)findViewById(R.id.search);
Button smsto=(Button)findViewById(R.id.sms);
Button btn2=(Button)findViewById(R.id.button2);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(view.getContext(),MainActivity.class);
startActivity(intent);
}
});
serch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri webpage=Uri.parse("https://www.google.com");
Intent search=new Intent(Intent.ACTION_VIEW,webpage);
if (search.resolveActivity(getPackageManager())!=null)
startActivity(search);
}
});
smsto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri smsto=Uri.parse("smsto:03472943510");
Intent sms=new Intent(Intent.ACTION_SENDTO,smsto);
sms.putExtra("sms_body","Hi this is me sheraz khan");
if (sms.resolveActivity(getPackageManager())!=null)
startActivity(sms);
}
});
}
}
Comments