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!
Related
i know we have a few applications that allow us to use our phone's screen and keyboard to control our computer, and while it is cool, it's just not something that i have a use for currently. i was wondering if there were any apps that you know of that allow me to have a window on my comp that is my home screen on my phone and control things on the phone from the comp. i hate when i am working on my themes and i get 100 texts and i have to go from using the comp it using the phone and back and forth. WM had several apps like that and i loved them when i was running windows but now i run linux(ubuntu 8.10) and i would love to be able to type texts and run apps on my phone while using the computer keyboard.
i have looked through the market and can't seem to find anything on there and i was hoping someone could point me to one elsewhere or if i missed one on the market. thanks in advance
That would be cool. A VNC Server has already been ported to iPhone, so it's probably not too difficult for someone who knows what they're doing (i.e, not me =P)
It would definitely be great to be able to type text messages and whatnot using the computer's keyboard and screen instead of that tiny little G1 keyboard.
or if there are some commands i can run from adb shell that would work too, all i have been able to figure out how to do is play an mp3 on the phone by typing the command. cool but not what i would like.
alright, for those that care i have figured out how to start an app on the phone by using the adb shell commands, and i can even start to compose a text if i do it correctly
to start the messaging app you need to type in the adb shell(or android terminal but the point is to be able to do it from the comp
adb shell
am start -a android.intent.action.MAIN -n com.android.mms/com.android.mms.ui.ConversationList
the above line brings up the conversation list to allow you to choose a list, but i have yet to figure out how to atually pick a convo from that page
to bring up the compose message to start a new text type in the following
am start -a android.intent.action.MAIN -n com.android.mms/com.android.mms.ui.ComposeMessageActivity
from there i can input the number to send the message to but not what i want the text to say,
input text <string> #that inputs a single word and no more after the word text
so if i were to type
'input text hello android' my phone would act as if i had just typed hello, this also works on the home screen to search your contacts. i am working on in[utting more than one word and also choosing your conversation from the comp
Cool! nice progress. Maybe other Android intents can be used...
progress
i know i can start any app by knowing the commands for it now and typing it in. but for right now my main concern is getting a multi word string to appear in the text box. if i can get that then i just need to figure out how to attach "input keyevent 66" to it as well so it runs cleanly. key 66 is the enter key and i figured out several others along the way but i will list them later. i pulled the input file from the /system/bin directory and maybe someone else should have a look at it and figure out how to acheive multi word texts without placing "_" between all the words, cause right now that's where i'm at. i'm attaching the file for the guru's to take a look at. obviously it isn't saved as a .txt file on the phone but that's how i uploaded it to here.
CALLING THE ANDROID GURU'S TAKE A LOOK AT THIS
Cool. Once you figure out a bunch of commands, I could try making a user interface for it as a project...
just wanna drop this lines here, there is an app from motorola MPT Motorola Phone tools, and it does all that you want and more, the phone can be connected to the pc via USB or Bluetooth... you can send receive msg, phone calls, see and edit contacts, drop images, ringtones browse the files etc
juangil said:
just wanna drop this lines here, there is an app from motorola MPT Motorola Phone tools, and it does all that you want and more, the phone can be connected to the pc via USB or Bluetooth... you can send receive msg, phone calls, see and edit contacts, drop images, ringtones browse the files etc
Click to expand...
Click to collapse
Im not sure if you know that your posting in a forum dedicated to the G1/android but MPT supports, as the name would suggest, motorola phones only.
juangil said:
just wanna drop this lines here, there is an app from motorola MPT Motorola Phone tools, and it does all that you want and more, the phone can be connected to the pc via USB or Bluetooth... you can send receive msg, phone calls, see and edit contacts, drop images, ringtones browse the files etc
Click to expand...
Click to collapse
does said program work with the G1? i can't imagine moto being nice and making a program that works for everyone else's phone
kp126 said:
Im not sure if you know that your posting in a forum dedicated to the G1/android but MPT supports, as the name would suggest, motorola phones only.
Click to expand...
Click to collapse
yeah I know, my bad.. just wanted to put an example of an app (that of course is only for motorola) for any1 wanting to do something like it
i know there's several out there for different phones, but nothing for android. hell i'd be satisfied if i could just have the emulator read from my phone and let me control it that way. right now i don't like what i have to do to send a text
input text hello
input keyevent 62
input text android
input keyevent 66
that is a whole lot of typing for a simple text that says "hello android" and then sends it
would it be possible to write a program that takes what you type and breaks it into one word or one letter segments and runs the proper keyevent for each charecter there?
from what i remember of my programming in java and visual basic from years ago is that it would basically be set to read an input and use a case method to say if $input=="hello" then adb shell input text hello. it would be easier i would assume to just break it down into words and place "adb keyevent 62" between each word to input the spaces, and at the end of the line of input you would have to have the code "input keyevent 66"
i have the keyevent mapped out for each button and such on the phone if anyone is interested. i will see what i can come up with on my own though for now
Hope!
I would <3 who ever release's this in some form or another =)
I could really use an application that lets me use my phone from my computer. Preferably it'd show the desktop of the phone, and allow remote access to all the features.
I don't know if it's possible, but it sounds like some of you are progressing, so I hope for the best.
that is the goal, but right now i think i want to just get a java script written by the end of the week next week that reads the key i press on the computer and inputs it into the phone. so i have a lot of relearning to do since i haven't written javascript in 4 years and even then it was just simple stuff to be run in a console. if someone wants to take whatever i get done and run with it to make a FREE APP then by all means. if i find my work in a paid app then you better hope the US gov't can't find you cause i'll be at your door ready to kick your ass.
i'm not sure how one would go about coding the computer to display the phone desktop, but however it gets done i would prefer it to be written in java so all users of linux, mac, and windows can use it.
alright i have found a program that allows me to display the phone screen on the computer using java *hooray* but it does not switch to landscape when the phone does, and i can't control the phone from the app. it was written so that people could do presentations with the phone instead of using the emulator. the gist of it is described here
http://groups.google.com/group/cw-android/browse_thread/thread/d2dbcabee6bcba1a
i have already emailed the developer asking politely to see the code and for permission to try and run with it to make the ideal app. at this point the only thing i could come up with would be to make a javascript that had a case for each key on the keyboard and when a key is pressed it sends the corresponding command(adb shell input keyevent ##) to the phone. this would work fine to use the arrow keys to control the phone, and i am not sure how to code the mouse into it yet. i will be waiting for a response from the dev hopefully he will give his permission and blessing for us to use the app.
Tubaking182,
Perhaps I could offer some help. Brad Fitz has written a program that injects keys into the Linux input layer. Perhaps the source code to his project can help you. It appears to contain a key code map. Here is the link to his code:
http://github.com/bradfitz/android-misc/blob/master/type.pl
Also, here is a link to his live journal entry regarding his program.
http://brad.livejournal.com/2400054.html
All of this would be wonderful to have with my G1. I wish all involved the best of luck!
the developer of the program i posted gives his blessing but he claims what we are trying to do is impossible without certain firmware. he claims that android does not support remote control. i have already proven it can be done though but you have to use keyvalues instead of the mouse. i don't know much java, but i know i need a case switch that executes adb shell input keyevent when i press a key on the computer. if someone wants to tell me the proper syntax and java command to run a run a command then awesome i can write this up *hopfully* and start testing it.
would it work if i typed it as
int key = evt.getKeyCode();
switch (key){
case 65: run.exec(adb shell input keyevent 29);
break;
what would be the proper way to execute the adb command
tubaking182 said:
the developer of the program i posted gives his blessing but he claims what we are trying to do is impossible without certain firmware. he claims that android does not support remote control. i have already proven it can be done though but you have to use keyvalues instead of the mouse. i don't know much java, but i know i need a case switch that executes adb shell input keyevent when i press a key on the computer. if someone wants to tell me the proper syntax and java command to run a run a command then awesome i can write this up *hopfully* and start testing it.
would it work if i typed it as
int key = evt.getKeyCode();
switch (key){
case 65: run.exec(adb shell input keyevent 29);
break;
what would be the proper way to execute the adb command
Click to expand...
Click to collapse
I've been doing Java for about 4 or 5 years now, nothing to fancy, but anyway,
Code:
int key = evt.getKeyCode();
switch (key)
{
case 65:
Runtime.getRuntime().exec("adb shell input keyevent 29"); // I dont know if this is what you "run" variable is referring to. and you would need quotes around your command as it takes a String parameter.
break;
I like to whipe periodically for that fresh g1 feel and smoothness, only reason I hate doing it is that I have to manually punch in my WEP code for the wifi over and over again. It's an annoyance I would love to get rid of. I've tried a few backup apps, none do it though. Anyone know of a specific app that does, or a way I can do it through term/adb? Any way?
I'm sure there is a way to pull the wifi settings data from the system somehow but I've actually found a gscript which I edited a little that goes through and calls the settings screen, turns on wifi, clicks on the topmost network available (assuming youre near the one you want to connect) and enters the WEP key as defined in the gscript code.
You may be able to find it in the 'useful gscipt' thread that was around on xda but if not, I can post mine (edited of course) as soon as my g1 gets done flashing the latest CM rom. :]
EDIT: Here you go put this in gscript or make an empty txt document, paste the following, edit the bold type to reflect your WEP key, save as setupwifi.sh file and run through terminal "sh setupwifi.sh"
***Requires root / 'su' *** either way you run it.
setupwifi.sh said:
am start -a android.intent.action.MAIN -n com.android.settings/com.android.settings.Settings
sleep 1
input keyevent 20
input keyevent 23
sleep 1
input keyevent 23
input keyevent 20
input keyevent 23
input keyevent 20
input keyevent 20
input keyevent 23
sleep 1
input text CHANGE THIS TO WHATEVER YOUR WEP KEY IS
input keyevent 20
input keyevent 20
input keyevent 21
input keyevent 23
input keyevent 3
Click to expand...
Click to collapse
Just make sure your wifi is turned off for the purpose of this script, since first thing it does is go to settings, clicks wireles, turns on wifi. If you had the wifi on and ran this script, it'll turn off and script will sort of go haywire. No damage but just it wont do what its inteded to do.
It's actually fun to watch your phone do things on it's own and press keys and all that. If you want more details on what each of the keyevent's do, just find the GScript thread and its all in there.
Hello! Sorry for bringing this thread back up. But, before anyone gets angry at me, I'm sorry in advance... I did use the search (trust me, I'm in love with it) and didn't have any luck finding anything other than this.
Anyways, just had a small question: let's say I don't know the wep key because my admin at work put it in for me (they wont share it) but I don't want to ask him every time I flash a rom for it again and again. So I was wondering if the script below would make my device pull the inputted wep key from the device and memorize it after every flash or does it only work if the wep key is inserted?
Is there maybe an app that can just backup data (including wifi wep keys)? or another script that shows you the currently inputted wep key on my device that my admin types in it?
When I had my blackberry the desktop manager backup system would save the wifi wepkeys, don't know why Google wont synchronize settings, data, apps, and wep keys but I guess to each it's own.
I have a T-mobile USA G1
Thank you.
prash said:
I'm sure there is a way to pull the wifi settings data from the system somehow but I've actually found a gscript which I edited a little that goes through and calls the settings screen, turns on wifi, clicks on the topmost network available (assuming youre near the one you want to connect) and enters the WEP key as defined in the gscript code.
You may be able to find it in the 'useful gscipt' thread that was around on xda but if not, I can post mine (edited of course) as soon as my g1 gets done flashing the latest CM rom. :]
EDIT: Here you go put this in gscript or make an empty txt document, paste the following, edit the bold type to reflect your WEP key, save as setupwifi.sh file and run through terminal "sh setupwifi.sh"
***Requires root / 'su' *** either way you run it.
Just make sure your wifi is turned off for the purpose of this script, since first thing it does is go to settings, clicks wireles, turns on wifi. If you had the wifi on and ran this script, it'll turn off and script will sort of go haywire. No damage but just it wont do what its inteded to do.
It's actually fun to watch your phone do things on it's own and press keys and all that. If you want more details on what each of the keyevent's do, just find the GScript thread and its all in there.
Click to expand...
Click to collapse
Wifi settings are located here:
Code:
/data/misc/wifi/wpa_supplicant.conf
Copy the .conf file to a safe place before you wipe and install a new ROM and then push it back using ADB or place it on your sdcard and push it back using terminal.
With this method, there is no way to see what the key is, but then again, you don't have to because once you push the file back, all your data is remembered.
DirectMatrix said:
Wifi settings are located here:
Code:
/data/misc/wifi/wpa_supplicant.conf
Copy the .conf file to a safe place before you wipe and install a new ROM and then push it back using ADB or place it on your sdcard and push it back using terminal.
With this method, there is no way to see what the key is, but then again, you don't have to because once you push the file back, all your data is remembered.
Click to expand...
Click to collapse
Just open wpa_supplicant.conf with notepad on PC and whoops your wep key is there.
Write it on paper and make tatoo of it on your leg
Edit:
Solution(s) witouth PC
Or open it with TxTPad Lite (free on market) directly on phone and read it
Upload wpa_supplicant.conf to dropbox with droidbox free
Hello everybody,
I recently bought my RaspberryPi for a school project, but I have no experience with python or coding in general.
My guess this isn't too hard to develop, but with no knowledge I won't come far.. I really hope one off you would like too help me
I am setting op a 'Hall of Fame' in my school, but I want to make it more interactive, so I figured this;
My RaspberryPi connected to a flatscreen and a numberlockpad, to show people short video clips of people in this 'Hall of fame'.
The idea is this;
1. On the screen is a box that states; "Insert birthdate here and hit enter".
2. When people do that, a short clip, about 1 - 2 minutes and stored on the SD, will be shown.
3. When it's ended, the screen with "Insert birtdate here and hit enter" has to come back.
I hope this is will be possible, and that anyone would like to help me..
You will definately be credited!
I'd imagine you'd want to use PyGame for the interface and then pass a command to omxplayer. I'd love to help you out but life is a bit frantic at the moment.
Sent from my GT-S5830 using Tapatalk 2
---------- Post added at 10:37 PM ---------- Previous post was at 10:35 PM ----------
Check my python thread. It has links to some resources.
Sent from my GT-S5830 using Tapatalk 2
That is definitely possible and probably won't require much programming to get working. Making it pretty will be more challenging, but so long as you focus on the underlying script first you should be fine.
You should start by learning some Bash and/or Python.
Create a script that will prompt the user for birthday inputs (i.e. Enter Month of Birth).
Create another for script for launching the video in full screen (i.e. Enter Name of Video to Play).
Then you only need to tie these scripts together in another script such that when a user enters each input (year, month and day) it will funnel the strings into the video launching script. If your videos are named logically (i.e. with date codes as thier names) it will be trivial to set up.
I'm happy to help out in my free time when I can, but you have to make the effort yourself first. If you ask specific questions you'll be more likely to get help too. I doubt anyone here is willing to just code this for you. The whole point of the Raspberry Pi is that it is supposed to promote education and insprire people to learn how to code
m2xtreme said:
That is definitely possible and probably won't require much programming to get working. Making it pretty will be more challenging, but so long as you focus on the underlying script first you should be fine.
You should start by learning some Bash and/or Python.
Create a script that will prompt the user for birthday inputs (i.e. Enter Month of Birth).
Create another for script for launching the video in full screen (i.e. Enter Name of Video to Play).
Then you only need to tie these scripts together in another script such that when a user enters each input (year, month and day) it will funnel the strings into the video launching script. If your videos are named logically (i.e. with date codes as thier names) it will be trivial to set up.
I'm happy to help out in my free time when I can, but you have to make the effort yourself first. If you ask specific questions you'll be more likely to get help too. I doubt anyone here is willing to just code this for you. The whole point of the Raspberry Pi is that it is supposed to promote education and insprire people to learn how to code
Click to expand...
Click to collapse
Hi, Thanks for your reply, and you are completely right. I am going to do that!
Do you maybe know a way to start with python? Could this be a good starting point?
Great idea, to split the action in 2 seperate scripts, I guess, but I am going to try to make it work.
NathanBookham said:
I'd imagine you'd want to use PyGame for the interface and then pass a command to omxplayer. I'd love to help you out but life is a bit frantic at the moment.
Sent from my GT-S5830 using Tapatalk 2
---------- Post added at 10:37 PM ---------- Previous post was at 10:35 PM ----------
Check my python thread. It has links to some resources.
Sent from my GT-S5830 using Tapatalk 2
Click to expand...
Click to collapse
Thank you for your reply, I am going to learn some python basics and will definately check out your stuff, thanks!
-------------------------
(I don't have much spare time, but I'll update on my progress here )
(oh and I am dutch, so I am sorry for my englisch..)
I have heard of codecademy but never used it so I cannot comment on the quality of it.
First you should look into what version of Python you are using on your development computer. You can check this by running from terminal:
Code:
python --version
I learned Python the old fashioned way; by reading through the official documentation. The official documentation can be found here, just make sure you select the correct version since there are (mostly minor) discrepancies between versions:
http://docs.python.org/2/tutorial/
Also, check out Kahn Academy. They have video walkthroughs of some of the basics of Python that are very good. If you aren't into reading through loads of documentation I would say this is your best bet. Admittedly, the official documentation can be quite hard to read at times. Watching a video to learn supplemented with exercises seems easier to me.
https://www.khanacademy.org/science/computer-science
I believe all the computer science stuff on Kahn Academy is only Python and is in order so click on the first one even if it doesn't say "Python" in the title.
Best of luck! Let us know how it goes and if you have any more questions.
I am currently learning python, if you need some help let me know, id be glad to help where i can
[email protected]
Some questions..
Hello
I am trying to get my code together, learned the basics of the basics, but I have some questions, this is my code so far;
Code:
print "Hallo, en welkom in deze Hall of Fame!" #Hello and wecome in my hall of fame
print "Kies een van de personen uit waarover u meer zou willen weten te komen" #Choose one
print " "
print "Vul hieronder de geboortedatum van uw keuze in en druk op 'enter'" #Enter bithdate of your choice
print " "
y = " "
while y != "stop" :
x = str(raw_input("Geboortedatum: ")) #Geboortedatum = Birthdate
print " "
if x == "26-10-1994" or x == "26101994" or x == "26 10 1994":
print "De gekozen geboorte datum is 26 Oktober 1994, dit is de geboortedatum van Bjorn van Beek." #Chosen bithdate is the one from Bjorn etc..
elif x == "01-11-2003":
print "De gekozen geboorte datum is 1 November 2003"
else:
print "Oeps, waarschijnlijk heeft u een foutje gemaakt tijdens het typen." #Oops, You have probably entered something wrong
print "Probeer opnieuw.."
print " "
y = x
else : print "Finish"
- What is the command to execute a videofile? so when someone enters a birthdate the video starts instead of a line of text
- A clear command? refres of the windows?
thanks for the feedback so far!!
B-vb said:
- What is the command to execute a videofile? so when someone enters a birthdate the video starts instead of a line of text
- A clear command? refres of the windows?
thanks for the feedback so far!!
Click to expand...
Click to collapse
Happy to hear you have made some progress. There are many ways to play this video so you will have to decide yourself how you want to do it. First you must choose what videoplayer to use and install it. In this example I will use 'mplayer' as it is probably sufficient for your needs. I would probably so something like this:
Code:
import os
videoplayer = "mplayer"
options = "-fs" # Play in fullscreen
date = "26101994"
#
# Write code to match your input videofile string to the actual filename
#
# It should look like 'videofile' below...
#
videofile = "/path/to/file_26101994.ext"
# mplayer [options] [file]
# i.e. "mplayer -fs /path/to/file_26101994.ext"
os.system("%s %s %s" %(videoplayer, options, videofile))
print "Now playing your videofile. Enjoy!"
Make sure you put the 'import os' at the top of the script. I'm not sure what you are asking in the second question. Perhaps you can explain a bit more?
m2xtreme said:
Happy to hear you have made some progress. There are many ways to play this video so you will have to decide yourself how you want to do it. First you must choose what videoplayer to use and install it. In this example I will use 'mplayer' as it is probably sufficient for your needs. I would probably so something like this:
Code:
import os
videoplayer = "mplayer"
options = "-fs" # Play in fullscreen
date = "26101994"
#
# Write code to match your input videofile string to the actual filename
#
# It should look like 'videofile' below...
#
videofile = "/path/to/file_26101994.ext"
# mplayer [options] [file]
# i.e. "mplayer -fs /path/to/file_26101994.ext"
os.system("%s %s %s" %(videoplayer, options, videofile))
print "Now playing your videofile. Enjoy!"
Make sure you put the 'import os' at the top of the script. I'm not sure what you are asking in the second question. Perhaps you can explain a bit more?
Click to expand...
Click to collapse
Hi,
Thanks for your feedback!
First I had to start everything from my pi, but that's already the point where I get stuck..
I can't seem to figure out, how to start my script? double click does nothing, choosing a program to launch it with doesn't do anthing too.
Even making it executable by $ chmod +x myscript.py
And the first line is; #! /usr/bin/env python
So what am I doing wrong?
m2xtreme said:
I'm not sure what you are asking in the second question. Perhaps you can explain a bit more?
Click to expand...
Click to collapse
Well, someone has entered a birthdate and a video has been show, I would like the windows to be cleared (fresh window).
A restart or something, is there a command for that?
Thanks in advance!
B-vb said:
I can't seem to figure out, how to start my script? double click does nothing, choosing a program to launch it with doesn't do anthing too.
Even making it executable by $ chmod +x myscript.py
And the first line is; #! /usr/bin/env python
So what am I doing wrong?
Click to expand...
Click to collapse
You can try running it from the terminal, that might give you a hint as to what is happening:
Code:
python myscript.py
B-vb said:
Well, someone has entered a birthdate and a video has been show, I would like the windows to be cleared (fresh window).
A restart or something, is there a command for that?
Click to expand...
Click to collapse
what windows are you referring to? do you mean the terminal and the videoplayer? Perhaps you can describe what you are using more? What operating system are you running on your Pi?
This is probably simple for a programmer, but as a newb, I am getting stuck.
I have 2 variables and I want to check if the first is contained in the second
so, %event = Phone and %check = WorkPhoneReport
I have tried :
*%event* ~ %check
*%event* ~R %check
*%event\* ~ %check
And several other similar patterns. What to do to get this test working?
I am trying to read my calendar and not process the same event a second time. So, each item it reads is appended to another variable, then on its next loop, it compares the new event to the check variable to see if it was processed already. Don't know if I should be using an array instead of a variable, and if I can use an array in a if/then statement....
Any help is appreciated!!
Figured out a way.
Variable Search and Replace:
Variable %check Search %event store in %matches
then in the if statement just check if %matches is set.
If there's a simpler way, please let me know, this task is at 50 commands, never hurts to shorten it.
Code:
%check ~R .*%event.*
In Regex format, dot (.) can be any character including having no character there, and star (*) means repeat previous character as much as possible.
So .* means "look for no character or any number of any characters", and .*%event.* means "look for %event with something or nothing before it, and something or nothing after it"
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,"");
}