Reputation: 31
In my Android app using Monodroid I have several activities. I noticed that the (physical) back button does not always make the app return to the previous activity as one would expect.
Also if the app crashes the current activity dissapears but the previous activity of the app is shown. From my experience of Android app development using Java this is not the behaviour I expect. So it might be a typical Monodroid thingy. Am I missing something here?
I have one main activity (splash), shown once. Navigating from activity to activity goes like this:
My main activity
[Activity(Label = "x", MainLauncher = true, NoHistory = true, Icon = "@drawable/zoeker2", Theme="@android:style/Theme.NoTitleBar")]
public class SplashActivity : Activity
{
private void showLogon()
{
System.Threading.Thread.Sleep(500);
RunOnUiThread(delegate
{
StartActivity(typeof(LogonActivity));
});
}
My logon activity
[Activity(Label = "x", Theme = "@android:style/Theme.NoTitleBar")]
public class LogonActivity : Activity
{
void LogonActivity_OnLogonSucceeded(object sender, EventArgs e)
{
Tools.Log("Logon Activity. Logon succeeded");
updateButtonStates();
var menuActivity = new Intent(this, typeof(MenuActivity));
StartActivity(menuActivity);
}
And finally the menu activity
[Activity(Label = "Menu", Theme="@android:style/Theme.NoTitleBar")]
public class MenuActivity : Activity, ILocationListener, ISensorEventListener
{
Nothing fancy here. Do I have to use other attributes? Any clue?
Upvotes: 0
Views: 2415
Reputation: 66882
With the exception of the SplashActivity which uses NoHistory = true
, then I would expect the Activities you have documented to work in "normal BackStack operation" within MonoDroid/Android
Your experience of Java/Android is what you should also see within Mono for Android too.
Can you try something like the ApiDemo - does that work in your current setup - https://github.com/xamarin/monodroid-samples/tree/master/ApiDemo
If you are still seeing problems, then maybe can you post a small sample project or can you report this as a bug/issue to http://bugzilla.xamarin.com/enter_bug.cgi
On:
Also if the app crashes the current activity dissapears but the previous activity of the app is shown
This sounds very unusual. You do sometimes see Android try to relaunch the previous app after a debug session finishes - maybe that's what you are seeing?
Upvotes: 1