I am quite new to android programming (aswell as java in general) and have run into an issue that has me stumped. I am building a basic app (for practice) that accesses an already built website www.shodan.io . As far as i know there is no android app for this particular site yet and i quite enjoy it for my research. So I have an app that has 4 activities, all of which load beautifully (after much help from stack forums). They are: LoadingPage, MainActivity, SearchPage, and ExploitSearch. On my MainActivity, I have a webview to display the different pages, buttons to switch between, logos, etc. My search and exploit buttons each load the respective pages without issue. Now for my question/problem.
I would like to have the search and exploit activities take input (which is currently their only purpose), save said input into a string, which is then accessible from my MainActivty and used as the search query for my url.
My search thus far has turned up many forums telling how to take data from activity1 and have it readable by activity2 using "intent". However, I cant seem to find any resources for doing the reverse, or for saving it as a string (maybe in a temp file, and preferably something that can be recalled later... kinda like "input"+\n so its not overwritten)
Thank you for your time (ps. let me know any portions of code needed as i dont want to fill this thread with 4 activities and their respective layout files.)
Put the value in the intent
Then, to retrieve the value:
Source: Getting a Result from an Activity
From Activity1:
When you want to start Activity2:
This will be called when Activity2 is finished:
And Activity2, when you are done and want to send the string back:
We have used the RESULT_REQUEST to uniquely identify our own REQUEST, and you do need to check if the requestCode is the same with the one you have started the second activity.