Send data to multiple activities - Android Studio

Hello,
I am new to android studio and java in general. I was wondering If there is an easy way to send data from one activity to multiple activities.
On my first activity the user will enter some text. I want this text to be displayed on the second activity as well as on a summary page(my 6th activity).
I have figured out how to have the text go from activity 1 to the second activity. But I cannot figure out how to make it show up on the summary page as well. Anyone have any advise?
Thanks in advance!

NewtoStudio said:
Hello,
I am new to android studio and java in general. I was wondering If there is an easy way to send data from one activity to multiple activities.
On my first activity the user will enter some text. I want this text to be displayed on the second activity as well as on a summary page(my 6th activity).
I have figured out how to have the text go from activity 1 to the second activity. But I cannot figure out how to make it show up on the summary page as well. Anyone have any advise?
Thanks in advance!
Click to expand...
Click to collapse
You should use some permanent storage. In Android it's a lot ways to save the data: simple file, preferences, database, content providers and others.
I think for you case can be appropriate use the preferences. You need to write the preferences in one activity and read in another. Please see the following code example in Kotlin for details.
In order to write the preferences:
Code:
with(getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)) {
edit().putString(MY_MSG, "your message text").apply()
}
In order to Read preferences from destination activity:
Code:
with(getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)) {
mString = getString(MY_MSG,"");
}

Related

AnyCut / BetterCut

Well I have been searching around now for instructions on how to use this app.
Specifically the "Make Your own" Option on the app.
With all these shortcuts im about to show you Leave Type section blank.
here is what I found.
The app uses something called URI (Uniform Resource Identifier).
These are used to Choose what you want to do in the specific shortcut.
i.e Make the short cut a Direct Call. the URI I believe is this:
Code:
Action: android.intent.action.DIAL <--- URI
Data: content://contacts/people/#
# meaning the number defined to the specific contact. You can also use their Phone number as well if it gets too complicated.
What you typed into the Data portion is the what the URI is going to go into to make the shortcut work. In this case, It dials the specific number typed in where the # sign is.
To make a Direct Song shortcut you would have to do this:
Code:
Action: android.intent.action.PICK <--- This will choose and play the song you choose in the Data sections.
Data: content://media/external/audio/media/# <-- This specifies what song you want to be played.
# the same applies as with the direct call except that it can only be one number (i.e 1 for your first song, 2 for the second song, 3 for the third, etc etc)
Im not sure if combining numbers would work in this case but I doubt it.
--------------------------------------------------------------------------
If anyone finds anymore information, links, or w.e on it or more shortcuts that you guys have made, please post them and I will add them onto Here.
More Information/Links:
http://developer.android.com/referen...nt/Intent.html
If link is broken for you search this in google:
developer android referen Intent
and choose the very first option.

[Q] URI Scheme help?

I want to make a URI scheme favorite so that whenever you go to a YT video, you tap on the favourite and choose which app to open it with.
So far I've done this:
Code:
javascript:location.href="vnd.youtube:"
How do I code in Javascript so that it automatically copies the YouTube video ID and pastes it at the back of "vnd:youtube"?
I'm a noob at java sorry
Thanks
104082594999
I can't post links as I'm a new user, but google for "open with metrotube", it's already possible!
oh, and JavaScript isn't = Java.

[GUIDE][Difficulty: Intermediate] Read a Random Top Voted Thread from Reddit

I'm sure many users here have heard of or currently use Reddit, the link aggregation website. If you use the website for news, to find funny jokes, to find awesome tips, etc. then you'll be happy to know that Reddit offers the ability to read data from its subreddits in the form of a JSON feed, and using Tasker we can process this feed to get the data that we want, in this case the titles of each thread. In my setup, I'm taking a random title among the top 3 posts of the day from /r/quotes.
Instructions
Variables --> Variable Set. Name %subreddit to the name of a subreddit you would like to pull from.
Variables --> Variable Set. Name %numposts to whatever number of posts you want to pull before randomizing which one is picked.
Net --> HTTP Get. The Serverort you'll be grabbing is:
Code:
json.reddit.com/r/%subreddit/top/?sort=top&t=day
Code --> Javascriptlet. Here is the Javascriptlet you'll need to put under Code.
Code:
var arr = JSON.parse(global("HTTPD"));
var randomnumber = Math.floor((Math.random()*numposts)+1);
var selftext = arr.data.children[randomnumber].data.selftext
var title = arr.data.children[randomnumber].data.title
Variables --> Variable Clear. Set Name to %HTTPD* and check Pattern Matching.
Alert --> Say. For the text, you can say anything to preface what Tasker is about to put out. For instance, I've said it to "Your quote of the day is: %title." This should change depending on which subreddit you pull from.
That's it! Pretty simple to start with. You can change the Javascriptlet to pull N number of threads into an array and mess with that if you would like. Tasker's Javascriptlet user guide is a great resource for this.
Would you mind posting the xml file? Thanks!
Did exactly as you said and it doesn't work.
Edit : Darn this is a pretty old thread
Sent from my Honor 6X using XDA Labs

Screenshots don't always save

Hello.
I have a tasker profile that's not quite working as I want it to, trying to get a screenshot method working because the buttons on my phone aren't reliable
(Task) 1: Run shell ~ Command screencap -p /sdcard/screenshots/screengrab-%DATE-%TIME.png
Use root (ticked)
2: Flash "Saved!"
It works, but I have to wait awhile before screenshotting again. If I want to take two screenshots in a row, the first one will save, the other won't. Seems like it's affected by what minute it is.... if it's 5:16 on the first screenshot, and 5:16 on the second, the second won't save. But if it's 5:16 on the first screenshot, and 5:17 on the second, it works. Is there something I need to add after %TIME so I'm not limited, or is this not a fixable issue?
This may not seem like a big deal for many people but sometimes I take screenshots of important emails, payment receipts, etc, sometimes they're too big to fit all on one screen and need 2 or 3 screenshots.
May or may not be relevant, but my phone is on 6.0 and stock ROM.
Bump
Found someone else with the problem I was having, adding %TIMES seems to have solved it.
Cinderbunny said:
Found someone else with the problem I was having, adding %TIMES seems to have solved it.
Click to expand...
Click to collapse
Hi,
Glad that you solved it. Just a friendly tip: to be able to save multiple (999, to be exact) screenshots per second, you could add %TIMEMS instead of %TIMES.
Additionally, if you want the actual, human-readable time in the filename, you could use the following task:
Code --> Java Function
Class Or Object: Date
Function: new {Date} (long)
Param (long): %TIMEMS
Return {Date}: date
Code --> Java Function
Class Or Object: SimpleDateFormat
Function: new {SimpleDateFormat} (String)
Param (String): yyyyMMdd-HHmmssSSS
Return {SimpleDateFormat}: formatter
Code --> Java Function
Class Or Object: formatter
Function: format {String} (Date)
Param (Date): date
Return {String}: %datetime
Code --> Run Shell
Command: screencap -p /sdcard/screenshots/screengrab-%datetime.png
Use Root: ticked
I hope this is of use to you, or anyone!

How do I rename spreadsheet columns and alter app to suit?

I have built an app from a tutorial but I am having problems adapting it to my needs. I need to rename the spreadsheet columns but when I do (and match the names in the app) if fails to get the data.
I'm not sure what spreadsheet you are referring to, but just going off my excel & VBA knowledge, can you check that auto calc is turned on? and/or hit F9 to recalc. How about the name manager section in the tool ribbon in excel? Say for example the column you want is called "variables" and it was originally defined as $A:$A (i.e., all of column A) but you did something and now it's been altered so that it's $A:$B (i.e., is all of columns A & B) then that could cause problems. Similar thing if it the area was smaller, like $A$2:$A$6. If you added a row to cell A7, the name manager is not looking past A6 in this example so your new info won't get a hit.
Hope that helps
I am using a google sheet to hold data for the app, one entry per row. I have tried with the code I have that builds the basic app. The tutorial app has first_name, last_name, email as column headers. I need them to be gridref, fallname, w3w. I have to name the data fields (?) within the app but if I use GridRef it fails but gridref works. can string names not have/be capitalised?
Also if I create a new project called WF the code I'm using works but if I name it waterfalls it fails.
I can rename them in the spreadsheet, there are no calculation fields etc. just simply text in a cell, typed in to be passed over to the app in JSON format.
I can add a new line which displays in tha app as a new entry which is what I want. I will need to add columns at some stage but I'll be happy to get this working first.
I have managed to rename 3 of the four columns but it fails when i change the name of the 4th That may not be a problem but changing last_name to aw3w causes an issue. In the app I think they are called 'holders', are some names reserved by the system?
I have figured this one out.

Categories

Resources