Save states of multiple activities - Android Application - java

I have read many posts about how to save a state of an activity using ViewModel and onSaveInstanceState(), however, I couldn't find something that explains the possibility of saving multiple activities states to get back to them using an "Edit" button (to edit some application information). Is this doable? Can someone enlighten me?
Thanks

Related

android Java Multiple classes update activity UI (how to share data)

I know this question has been asked several times, but I cannot seems to find a suitable answer or there is multiple solutions. I am just trying to find were to look and the best possible solution.
I have an app that has several activities such as Main, Settings, User profile etc and I have different source for information coming into the app such as pulling data from a server, BLE comms, back ground timer etc. The plan would be to have these calling comms functions in separate classes i.e. servercomms, BLEStack, timer etc
The question what is the best way to share the data from these classes to the activity UI? There seems to be different methods such as Intent, Async, Runable but not sure which one should be used? When I look at one it seems create performance issues and will stop running if the device is short on memory.
For example if there is a Timer running in the background, which will update a picture, text on the Main Activity how can I call a function or update the UI from the timer class? I thought run a function in the MainActvity code, but not sure if that is correct as I read it might affect the mobile app performance?
Sorry, I know this question has been answered and I have followed each thread but just cannot work out the best way to make it all work with sharing data and updating the activity UI.
I'd suggest having look at EventBus as per their description:
Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
OR
Have a look at the official android documentation Communicating with fragments which shows how to use ViewModels to share data between activities and fragments and fragment to fragment.

Setting background to all activities on click

I have an app that allows users to change the background. I have an activity in which users get to pick the background that they want from a list of images shown. My only problem is that i don't know how to set the image that they pick as the background for all of the other activities and also how i can save the information so when they get out of the app and come back in to the app, they would still see the image that they set as the background. any help or advice will be appreciated a lot.
Assuming your main problem is how to persist the background image setting and share it across different activities then Shared Preferences may be the best solution. Essentially, it allows you to save simple key value pairs (perhaps the name of the image file in your case?) which is shared across activities and persisted across instances of your application.

How to manage multiple activities with the same name inside an app

I am currently writing an Android app to work as an activity launcher.
The main activity works as launcher and will let users launches a new activity from the main activity(here I create this new activity using FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_MULTIPLE_TASKS).
So that I can hold multiple these activities with the same name but different content in the background.
But I still need a method to manage them, which means I can offer a UI for user to choose to restart one and kill one.
Can someone give me a good solution?
I appreciate your help very much!
And you can also view a similar question asked by me yesterday: set unique identifier for RunningTaskInfo
You need to get the list of Activity instances which are running in your application. List of all of the activities in our application that are running on the device gives an answer how to do this.

Browse pictures on Android and move them to specific directory

So I'm building an android application, I want the users to be able to press a button that opens a window/activity. I need the activity to allow the user to browse the pictures saved on the phone and be able to select those that they want. Once they select the pictures and press "ok" the pictures need to be copied to a directory for my application to access them from. So basically does anyone know of any code or help to do this and where would i be able to save user data for my app specifically on the android device. Thanks and let me know if you need any clarification!
It looks like you are expecting someone to complete your task. Instead of giving solution I would like to suggest you a way to do this, there on you can go and search and find a solution which will make you learn lot of things. Here are some articles where you can have some reading to start with.
Searching files on the android system.
Create a view where he can invoke search and select files
Storing files on internal storage
Now you need to do some homework and start hitting the keyboard, I'm sure you can do this easily

I have got my HelloListView app working from android.com what is the best way to add information

I wanted to make an app that you can select a country and it comes up with information about the country. I don't know that much about Java i'm hoping that this will help me learn more about java.
I would like this to be an android app
please help me
thanks
CS
edit: I am new to java so can you help me out and give me pointers on how to do this please.
Example: Lets say we have a listview that has the United States, Germany, and the UK
I already have the list view set up. How would i go about making a second view that would let me select the us and give basic information about it?
Unfortunately I am still a little unclear as to what you are asking but as far as I am aware the list view you create should be able handle clicks on it, so if you check out the ListView class in the android SDK there you will need to look for the onClick event you are after. Overload it and put in the code to create (I think you are asking for this) a second activity, to then show your selection. However that might be a bit complex so try and handle the click event first by perhaps a toast message. Then work your way up.
The second activity you could use to show information, or just create a dialog, or another full screen view to show the info.
I commend you for getting ListView to work without knowing Java. I would suggest you learn the language first before jumping into Android apps because the development resources assume that you have a good knowledge of the Java. There are lots of resources on the web for learning Java and you can do it all in the Eclipse environment if you wish.
Good luck!

Categories