I'm trying to open an already activity with animation open.
It will run it only first time which activity starts and then it will not work again
Here is the code :
var intent = new Intent(this, typeof(TableItemsMain))
.SetFlags(ActivityFlags.ReorderToFront);
StartActivity(intent);
OverridePendingTransition(Resource.Layout.trans_left_in, Resource.Layout.trans_left_out);
Related
So i got two activities, a main then a secondary, we'll call them activity_A (main) and activity B( the second ).
So my activity_A is getting some data, then sending it to activity_B with this code :
Intent i = new Intent(this,activity_B.class);
i.putExtra("Charge_Batterie", bat);
startActivity(i);
activity_B receive it correctly with this code :
String bat = getIntent().getStringExtra("Charge_Batterie");
My problem is that my activity_A is refreashing it's value "bat", so when i send it with intent it doesn't refreash in activity_B.
So i'm wondering, is my activity_A sleeping ? If yes how can i make it stay alive ?
I´m doing the same thing and it works for a long time - activity A runs a timer and launches activity B with extras.
When I want to refresh activity B with "new extras", I´m doing this:
// check if activity B is created and running:
if (intent == null) {
System.out.println("Creating Activity - Intent is null");
intent = new Intent(context, ActivityB.class);
intent.putExtras(ImagedownloaderActivityBundle);
startActivity(intent);
}else {
System.out.println("Reloading Activity - Intent exists");
finish();
intent = new Intent(context, ActivityB.class);
intent.removeExtra("playlistsList");
intent.putExtras(ImagedownloaderActivityBundle);
startActivity(intent);
}
As far as I know, this isn´t the best way to achieve the background task - it should be running on a service, perhaps doing the same when one needs to refresh.
I want to restart my Android app, but I want it to go to a specific activity after the app restart.
I am currently using this code to re launch my app, but it starts back to the first activity. I need it to go to another specific activity.
I made a settings page in my application where users can choose their own app colors. After choosing a color, i need to restart all activities to apply the new theme that the user chose.
code I am using to restart app to first activity:
Intent startActivity = new Intent();
startActivity.setClass(ProfileSettingsActivity.this,ProfileSettingsActivity.class);
startActivity(startActivity);
finish();
easy
Intent intent = new Intent(this, ANOTHER_SPECIFIC_ACTIVITY.class);
this.startActivity(intent);
finish();
In the onCreate() of your first activity, check for whatever conditions you want, and then based on those conditions launch the intent for your specific activity before the setContentView() is called in the first activity.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(CONDITION_1) {
startActivity(new Intent(this, ActivityA.class));
} else if(CONDITION_2) {
startActivity(new Intent(this, ActivityB.class));
}
setContentView(R.layout.activity_first);
}
Have you tried clearing all activities and launch the new one with Flags?
Intent intent = new Intent(this, NEW_ACTIVITY.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Doing this, you are clearing all activities previously created and launch NEW_ACTIVITY.class with the new configuration.
I have 3 Activities:
A: Parent Activity
B: first Child Activity
C: second Child Activity
In A Activity open B Activity when button is clicked
Intent i = new Intent(this, ActivityB.class);
startActivityForResult(i, 1);
In A Activity there is a Runnable object that in some condition open C Activity
Intent i = new Intent(this, Activityc.class);
startActivityForResult(i, 2);
All work and on device i see C Activity over B Activity over A Activity but when i close C Activity with this.finish(); in A Activity onActivityResult() event is not fired. It'll be fired only if i close the B Activity too.
How can i know in A Activity when C Activity is closed and let B Activity opened?
Whenever you wish to exit all open activities, you should press a button which loads the first Activity that runs when your application starts then clear all the other activities, then have the last remaining activity finish. to do so apply the following code in ur project
Intent intent = new Intent(getApplicationContext(), FirstActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
The above code finishes all the activities except for FirstActivity. Then we need to finish the FirstActivity's Enter the below code in Firstactivity's oncreate
if (getIntent().getBooleanExtra("EXIT", false)) {
finish();
}
Please See this
I have an app that I'm writing that starts with an initial Login/Create New Account splash screen. In onCreate it checks my SharedPreferences to see if user credentials are stored. If they are the activity launches an intent to the main activity skipping the login/create process.
if (haveCredentials()) {
Intent i = new Intent(this, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
I don't want the user to be able to go back to the splash screen. As you can see I'm trying the CLEAR_TOP Intent flag as suggested by this but it doesn't seem to be working. Not sure what I'm missing.
Current State of the Activity Stack
SplashActivity->MainActivity
Desired State of the Stack
MainActivity
Have you tried finishing the current activity?
if (haveCredentials()) {
Intent i = new Intent(this, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish(); //add this!
}
Just use finish() after startActivity(), so that when back button is pressed the previous activity will not be shown.
I got two activities, one active and other paused and I want to close/finish all the two activities and start another intent. I tried this inside the active activity:
finish();
Intent intent = new Intent(getApplicationContext(), Init.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
then I tried to close the program inside Init class and it appeared me the previous paused activity. How can I solve this problem ?
Try calling not calling finish() before you launch the newest intent and use these flags
Intent intent = new Intent(getApplicationContext(), Init.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);