Android Question Odd Behavior Moving Between Activities

Nostrildumbass

Member
Licensed User
Longtime User
I'm somewhat lost as to why this is behaving this way.

To attempt to keep things simple, I'll just say I have 4 activities: "1" "2" "3" "4" and a layout for each (assume matching names). This may be a bit hard to follow.

Activity 1 loads layout 1, which has two buttons. One button logs the user in and starts activity 3. The other button starts activity 2 which lets the user sign up, and once signed up, starts activity 3 (essentially logging the user in automatically once the signup is successful).

Activity 3 then loads layout 3, which has a TabHost. Each tab has some different content (not important, working fine). One tab has a button that starts activity 4 (which loads layout 4). This layout has a spinner and an EditText for the user to choose an item and type some info. Then it has a Submit button. This submit button sends the info to my database and creates a record (working fine). A message box opens letting the user know that the info was received. The Job is released once the user hits OK, and I call Activity.Finish (there's no reason to do anything else on activity 4). I am correctly brought back to activity 3.

If I hit the back key, I'm correctly taken back to Activity 1 as I intend (login screen). If I hit the login button (which should start activity 3), it instead starts activity 4 (why is this happening? Not only did I kill activity 4, but this login button is explicitly programmed to start activity 3, not 4). Hitting back key again takes me back to the activity 1 login screen, but hitting login yet again starts activity 4.

I already tried removing the "Activity.Finish" from activity 4. This then requires the user to hit the back key after pressing OK on the message box confirming that their submission was received. I don't want this to be this way, but regardless it isn't solving the problem. The login button from Activity 1 is still starting Activity 4 for some reason. The log even shows such (it is starting activity 4 instead of 3). I'm not using any custom Sub for the back key; it is behaving is it does natively.
 
Last edited:

Nostrildumbass

Member
Licensed User
Longtime User
Now this is odd, and maybe you can shed some light on it.

I was using DBRequestManager to handle communications with jTDS + SQL Server. I was using a single DBRequestManager object (reqManager, just like in your example). In your example you had noted "Usually you will only need a single DBRequestManager object." I may have either read that out of context, or it's simply that in my case I need multiple objects. I was using a single DBRequestManager object (declared and initialized in my Main activity) between all my activities. I now have a separate one in each Activity and the problem is solved. So... is it "wrong" or somehow unadvised to have multiple DBRequestManagers?

On another note: if I hit back while my Google Map is establishing location (it immediately does so when the activity starts and I have the camera being positioned on the user's location) I am taken back to my Main activity (that's fine) but it keeps wanting to jump forward into the map again. If I wait for the camera to zoom in on my location and hit back once it's done, it doesn't jump to the map again. Fixed with gps1.Stop. Sorry for the few times I've posted a question that I was able to resolve myself after some more troubleshooting.
 
Last edited:
Upvote 0
Top