enter image description hereenter image description hereSo I'm working on an app where when the user clicks a title in a list picker, another screen opens and the picture of the place is shown. I've been looking around and I can't figure out how to send the data from one screen to another along with the data of a picture. I've seen the use of Tinydb, but I'm honestly very confused about it. I'm using MIT App Inventor 2 btw. I've included images to help with my confusion
Asked
Active
Viewed 432 times
2 Answers
0
Using Static Variable :
- If the
title
data is static then you can define it as static so that way it will be the same copy for all the objects ofScreen1
. - Now you can access it from
Screen2
by saying Screen1.title
- If the
Using intents to communincate
- If the title is a data that can be passed via an
intent
that use to pass the title - For example if title is a string from Screen1
intent.putExtra("TITLE", title);
In Screen2 you can do the following
String newString; if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if(extras == null) { newString= null; } else { newString= extras.getString("TITLE"); } } else { newString=(String)savedInstanceState.getSerializable("TITLE"); }
- If the title is a data that can be passed via an
Using interfaces for callbacks:
- If the
title
is really that important you can pass an interface toScreen2
and letScreen1
class implement this interface - Have a reference to
Screen1
class interface - access the
title
by making a callback to this class ofScreen1
- If the
Having Direct reference to Screen1 class:
- Let
Screen2
have a direct reference to that particular object ofScreen1
class that contains the title - That way
Screen2
can access the attributes ofScreen1
class - Remember when having a direct reference you want the same object of
Screen1
to be passed you can do this by usingthis
keyword
- Let

Jai
- 3,211
- 2
- 17
- 26
0
Passing Data Through Intent()
is the Best way for passing data to another activity or fragment.and it is very easy to use.
Refer This Link

Normal1One
- 219
- 3
- 11
-
So I understand most of the actual code that is going on with the intent, but I'm utterly confused on how to put that into the block formation which is forced upon the user in App Inventor. If you could provide any other feedback, that would be great. – BaconAF Jan 11 '18 at 05:06