In previous post i explained "how to back from child activity to fragment"
Here i will explain how to finish parent activity from child activity in Android..
Parent Activity
public class HomeScreen extends Activity
{
static HomeScreen firstActivity ; //Create one Activity variable"firstActivity "
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.newhome);
firstActivity= this;
}
public static HomeScreen getActivity()
//Declare one function "getActivity()"
{
return firstActivity ;
// Assign Activity "HomeScreen" to Activity Variable "firstActivity"
}
In Child activity call the getActivity() function to finish the child activity.HomeScreen.getActivity().finish();
// the fuction returns the Activity variable "firstActivity"
Happy Coding :)
Here i will explain how to finish parent activity from child activity in Android..
Parent Activity
public class HomeScreen extends Activity
{
static HomeScreen firstActivity ; //Create one Activity variable"firstActivity "
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.newhome);
firstActivity= this;
}
public static HomeScreen getActivity()
//Declare one function "getActivity()"
{
return firstActivity ;
// Assign Activity "HomeScreen" to Activity Variable "firstActivity"
}
}
In Child activity call the getActivity() function to finish the child activity.HomeScreen.getActivity().finish();
// the fuction returns the Activity variable "firstActivity"
Happy Coding :)
No comments:
Post a Comment