java


How do we get and set same Toggle value while navigating from one screen(activity) to another activity?


My question is like in my activity 2 i have the screen like below.
I am toggling two or more toggle button (activity 2) and going back(arrow) to activity 1.
Now My question is how to save those value when navigating from activity 1 to activity 2 again for the second time with two or more toggle off.
This is a very general Scenario in Android UI flow:
One way could be saving toggle state in Shared preferences as explained here:
You can save the toggle state in onPause() of Activity in Shared preferences and restore the saved values in onResume() of the Activity
you can transfer infomation from activity1 to activity2 by using intent and bundle
-------------------Activity1---------------click
Intent intent = new Intent(this, Activity2.class);
intent.putExtra("Text", mText);
intent.putExtra("TextColor", mTextColor);
intent.putExtra("TextSize", mTextSize);
intent.putExtra("TextBold", mTextBold);
startActivity(intent);
-----------------------------Activity2--------------oncreate
Bundle extras = getIntent().getExtras();
mText = extras.getString("Text");
mTextColor = extras.getInt("TextColor");
mTextSize = extras.getFloat("TextSize");
mTextBold = extras.getBoolean("TextBold");
in your app, getBoolean is ok

Related Links

java having trouble with multiple classes
Evaluate Infix arithmetic expression using two stacks
No enclosing instance of the type TObjectHash<T> is accessible in scope. Spigot plugin
What is the equivalent of Oracle's ANYINTERACT+TOUCH spatial operator for Vividsolution's Geometry class?
Calling wait() nulls a variable i've just written
Running Selenium Tests using TestNG in parallel causes errors
How to use criteria query builders with dynamic constructor in select?
Compare the ArrayList values and HashMap values
Android: Error when i try to add view while “setContentView()” not specified
Handle click for layout inside preference fragment
How to make a feature to share content in social media?
Spring data elasticsearch GeoPoint with spring mvc
Exception handling request to /customer/upload/: org.jboss.resteasy.spi.UnhandledException: java.lang.VerifyError: Bad type on operand stack
Pixelating a Picture's remaining pixels
Beginner Java : Coding a method to display mode of an array returns default value
Restarting app server using AWS API

Categories

HOME
cakephp
yii2
atom-editor
image-processing
plone
comparison
appx
stock
read-eval-print-loop
android-4.4-kitkat
at-command
filtering
google-oauth
maven-3
jgroups
facebook-messenger-bot
awesome-wm
primary-key
gorm
vault
collectd
apache-cayenne
try-catch
text-rendering
alpine
web-sql
sylius
excel-2007
chromium-embedded
dxf
status
brunch
web-api-testing
ping
windowbuilder
kendo-datasource
unboundid
bosh
galsim
uisplitview
stringtemplate
uiswipegesturerecognizer
web-mining
space-complexity
swift3.0.2
streamsets
optix
sfdc
texmaker
nand2tetris
auto-update
logfiles
avconv
outlook-2013
termination
revapi
winscp-net
tizen-native-app
lowpass-filter
elgg
composite-key
knpmenubundle
capacity
lync-client-sdk
django-scheduler
google-cdn
word-vba-mac
underscore.js-templating
hill-climbing
javax.sound.midi
r-tree
thredds
embedded-code
splash
appfabric-cache
geonetwork
cctv
asp.net-web-api-odata
code-access-security
tld
phpthumb
valuechangelistener
meteor-velocity
cloud-connect
monomac
xsockets.net
web2py-modules
dotnetnuke-5
random-seed
android-screen-support
path-separator
trusted
punbb
nsdatecomponents
infobox
psi
oncheckedchanged
sproutcore-2
bespin
nintendo-ds
brewmp
anti-piracy
mdac
rtml

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App