Skip to main content

How to transfer from one activity to another in android

How to transfer from one activity to another in android







In android, if you want to transfer the user from your source activity ie, the main activity or the activity you are currently working on to another activity we can simply use the intent property of the android.

Syntax:-
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
startActivity(intent);


In this example:-
  • MainActivity:- This can be defined as the source activity or the activity on which you are currently working. In other words, it can also be defined as the activity from where you want to redirect the user to another activity of your application.

  • SecondActivity:- This can be defined as the destination activity. In other words, it is the activity where the user is redirected after the button click from the first activity ie, the MainActivity .
Note:- The first activity that is passed is always passed as the context ie, Name.this.
The Second activity that is passed will always be passed as the .class file because this activity not even compiled by the android studio.First, this activity is needed to be compiled after that the SDK will have the reference of this class and execute this activity further.

Types of Intent

There are two types of Intent found in the android. These are listed below:-
  • Implicit Intent:- These are intents that are called by the android itself and need not be called by the user. 
    • Examples of these intents are Send and many more.
  • Explicit Intent:-  These are the intents that need to be called by the user explicitly and the user can pass the custom source and destination in the parameter in the argument. 


Comments

Popular posts from this blog

C++ Program Finding The Absolute Value

#include<iostream> using namespace std; int main() { cout<<" enter any number"; cin>>num; if(num>0) { cout<<"The absolute value of number is:"<< num; } else { cout<<"The absolute value of number is :"<< -(num); } return 0; } OUTPUT Enter Any number: 2 The absolute value of number is 2

Threat wandering on Amazon Rainforest

Threat wandering on Amazon Rain forest Amazon Rain forest is the world's largest rain forest in the world and situated in Brazil and extended to Columbia Peru and other South American countries , famed for its biodiversity. Its crisscrossed by thousands of rivers,including the powerful Amazon. The area in which the Amazon Rain forest is spread is about 5.5 million square km. Amazon rain forest is said to be the lungs of the planet earth which produces about 20% of the earth total oxygen that is consumed on the planet earth.  Since last few days there is huge threat wandering on lungs of the planet IE the Amazon rain forest. The forest is covered with the intense and huge fire and burning continuously from days. Fire is so huge that it can turn the rain forest into the Savannah in few more days which will be the huge loss to the planet earth as it will not able to fulfill the amount of required oxygen by the people residing on it. The city of Roraim...