Android - Loading data from next screen when going back to previous screen - android

I am building an application that has a screen that needs to be filled with data. At some point there's a button called "Add Category" which will redirect the app to another screen where the users will be able to add some custom categories and after selecting all the ones they will click on "save" and be redirected to the previous screen. The thing is that I want the screen to still have the data inserted previously and, mainly, the new categories that were just added.
I would like to ask you all what is the best way to do that? I want to have an general idea about the structure of the activities how can I do that and the things I would have to use. I know that when I go back without finishing an activity I will still have the fields filled, my main concern is about getting what was inserted.
If I use intent when he user presses the back button the data will be passed but how can I make the previous screen receive them without losing what was inserted previously?

Related

Runtime button creation in Android studio?

This isn't so much a question about my specific code as it is a question on what I need to use to accomplish my task.
I'm making a workout logging app for my class. The user needs to be able to create a workout routine, filled with various exercises of their choice.
On the home page, there is an "Add Workout" button. Clicking this should bring them to a screen where they name the workout and fill it in with said exercises. When they click save, I need to be able to create a new button on the home page with simply the name of their new workout. This new button when clicked will bring them to that workout, where they can start the workout and put in their reps, sets, weight, etc.
What do I need to be looking at to achieve this? Do I need to be saving the workouts to a database and using a function to go through the database and populate the home screen with respective buttons each time I enter the app / add a new workout? Or is there a different way to do this? I'm not sure that I'm even asking the right question or framing this problem the correct way.
Thanks!
you should put the button on the home page from the beginning but make it invisible at first.
yes you should put the workout information in a database and if there is a workout saved, make the button visible in the home page.
use android:visibility="gone" in XML and birthday.visibility = View.VISIBLE in the activity to modify the visibility

What's the best UX pattern for a search filter screen in android?

I have a list section in an Android app that includes a search functionality with filters (e.g. country, city, etc...), each filter takes you to a different activity that has a list of countries/cities/etc..., there are 2 buttons (Search and Clear All) other than the back button in the header and hardware back key.
My question is about the behavior of the buttons, when the user searches for a criteria and hits Search, the result in the list will be refreshed. When he goes back for a second search, the criteria he already picked will be selected. If he clicks Clear All but doesn't choose any new criteria and hits the back button, should the list be refreshed with the empty criteria like a reset or should that only happen when the user explicitly clicks on Search to confirm it?
I personally consider the back button as a cancel action, but others seem to think the opposite.
In your case, if the user doesn't select anything and presses back, then According to me it should not refresh with empty criteria. As far as I have seen in the mobile apps, the selections refresh the content as soon as they are selected.
For eg: If you have checkboxes, and the user checks any of them, it refreshes the content.. The user unchecks it, it refreshes the content again.
So there can be two ways to go about it.
Either do it dynamically as soon as the user selects a value, which I think is not the way you would prefer because you have to go a separate screen for results and switching between screens every time is very bad idea.
Use the apply button. If the Apply button is there, the user is sure that he has to tap on that to get updated results. After selecting the multiple criteria, he has to tap apply to make them work.
If you make the search possible on back button too (which won't harm if no criteria is selected), the user can get confused after selection like "heyy, last time it worked clicking on back, without selection, it should try with selections too".
So I think, it should be the Apply button that you should use.

How do I ensure that users always enter the app where they left off?

Through testing, I was fairly confident that clicking the launcher icon always took the user back to where they left off. However, I loaded my app after keeping it in the background for a long time and found myself on the home screen. When I pressed back, I was taken to the screen I had expected to return to. Things then got messy a I navigated up the activity backstack and found multiple instances of multiple screens. Did this happen because the "current" activity was destroyed by Android? If so, how do I handle that?
My activity hierarchy is similar to League > Division > Team > Player > Injury, so everything but Injury is a parent. I always want the user to be able to resume from any activity. Maybe I should use launchMode="singleInstance"? Should I use it on all activities?
In summary,
I currently declare launchMode="singleTop" for every activity that is a parent, as this initially seemed to cause the user to enter from where they left off.
How should I be handling my activities so that there is never more than one instance and so that the user always enters where they left off?
Try using sharedpreferences and check if it has value then go to a certain main-page.

How to switch between different activities like tabs in android?

I need to develop an application which contain these tabs shown in the image. Each tab contain a form which will be filled by the user.User can switch to any tab.
User click Activity1, Activity 1 gets displayed and user enters some data; then user press Activity 2, activity 2 gets displayed, user press Activity1 again, Activity 1 gets displayed with the data entered by the user(not the blank activity).
At the end when user click "Save" I need to get all the data from these activities and save it somewhere.
I have worked a lot in java but new to android, I am stuck in developing the UI for this scenario. However I have done this many times in iOS.
Anybody please share your experience of developing such UI.
Thanks,
Fragments will be more suitable for this scenario, the benefit are
They are light weight and faster
Managed automatically by the FragmentManager.
Data Sharing between Fragments is smoother and simpler than it is for Activities
They don't complicate the Architecture of the Application
You can have as many Fragments as you want in you Activity. Following two links can be useful for you.
A similar Thread
A Good Tutorial
Another good tutorial
If even after that you decide to use Activities, You need to think

Confirm and discard button in the android preferences activity

I'm working on the preference activity. The matter is about the possibility of add a button that allow to confirm, and eventually (that would be nice) a discard button in order to discard the changes applied at the preferences.
Let me explain better.
As far as I've seen it is possible using the common techniques that i've found in the tutorial to set different preferences using checkboxes and so on. The normal use case that involve preferences require that the user performs selections and after that click the BACK button in order to return to the old view.
However in the usability test i've done, it seems that this step is not always straightforward for all the users, and moreover a lot of them are not sure about the fact that the changes on the preferences are comfirmed.
Now we arrive at the question. is it possible somehow to have in the preference view selections (in particular one just composed by a group of checkboxes) to have an OK and eventually CANCEL button?
You have 4 options:
1) Design a layout and use a normal activity similar to the preferences screen where you give the user 2 buttons: Save and Discard.
2) Add a menu to the preferences activity with save/discard (and of course you will have to save the previous state and revert back to it if the user decided to discard).
3) Handle back button press on the preference activity where you popup a dialog asking if they want to save the changes
4) Add 2 "actions" to the preferences where 1 is save and 1 is discard and each goes to its own activity... Complicated and ugly in my opinion...
On a side note, I really believe users are familiar with Android's UI as 99% of the apps using preferences don't have this save button so it should be straightforward to the users that when they click on a checkbox - it is saved.

Categories

Resources