Android App Development for Beginners – 28 – Communicating with Main Activity

Share it with your friends Like

Thanks! Share it with your friends!

Close

Visit my website at https://www.thenewboston.com/ for all of my videos and tutorials!
Have questions or looking for source code? Check out the forum at https://www.thenewboston.com/forum/category.php?id=10

My Profile – https://www.thenewboston.com/profile.php?user=2
Facebook – http://www.facebook.com/pages/TheNewBoston/464114846956315
Google+ – https://plus.google.com/+BuckyRoberts/posts
Twitter – http://twitter.com/#!/bucky_roberts
Donate – https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5K9RJVCAKWZKS

Comments

Rohan Saxena says:

How can an interface have an object? Isn't an interface an abstract collection of code by definition, which cannot be instantiated?

Cuiqing Li says:

Can you tell me where the codes are in your video? I cannot find your codes in your website, can you give me a link? Thank you!

Harith Rathish says:

"Don't give up halfway through. At the end it's gonna make sense."

–   Christopher Nolan

Burbank51 says:

This was a difficult one to follow. I wonder how much it would have helped if I was more familiar with Java. Should I watch the Java series before continuing with this one?

warkidtee says:

Wow, first time after some years I really understood how an interface works :o

Mendel Lowy says:

One thing you may wonder, how can we direct cast the activity object passed in the onAttach method which is the complex android Activity class into our bland TopSectionListener interface, because by the time the onAttach is running that particular Activity implements our interface, therefore it applies the standard programming rule that you can direct cast any object that implements all the interfaces of the source object.

anon9180 says:

For those having trouble understanding:
1. The onAttach(Activity activity) method passes a reference to the activity the fragment will be attached to.
2. Bucky stores this activity into the activityCommander variable to be used later.

—————- So now the fragment has access to the MainActivity and its functions ————

3. When the button in the fragment is clicked, he calls activityCommander.createMeme() which is just him calling the MainActivity's createMeme() function (which he will write the code for in the next video).

Seamus O Connor says:

Thanks Bucky…..This is my 3rd playlist with you and I can honestly say you are excellent……..

This video is the 1st one I have come across that was a little difficult to follow compared to previous ones but just requires a little thinking on the viewers part…………

For people whining that it's confusing I have done a course on android development from Coursera and really didn't understand it………. Bucky's tutorials are so much better and he speaks plain English………..

Anamay Sarkar says:

onAttach (activity) is deprecated,
please modify the code accordingly!!!

skyz3ra says:

I give up halfway trough even tho you said not to.
#rebel #badass
jk, great tutorial as usual

yearn lp says:

this is so great

Risk Romer says:

I get so fucking lost with all that stuff. Java is so very verbose. In the end I feel I'm just retyping your code but I don't get why it has to be written like that. I need a fucking beer now, or maybe 10 hahaha

11m0 says:

If you're having trouble understanding, be sure to take a look at SlideNerd's channel which has android tutorials

Gaurav Sharma says:

Is there any java tutorial which specifically aim to teach java with android in focus???

Ren Likai says:

I think this tutorial is not in details somehow. We don't know why we have to write like this way. Anyway, don't give up in halfway.

Gerwin Intemann says:

How exactely do I find the source code in the forum?

MoeMixLOL says:

Can you not just create an instance of TopSectionFragment in the BottomPictureFragment class and get the variables topTextInput and bottomTextInput from the instance you just created? Hm.. I'll try this. And I'll update this post once I see the result.

Cloud Man says:

I feel like i'm just going through the motions when it comes to the java half. 🙁 anyone have any tips?

Simon Gomes says:

Can anyone explain why we are using static and final variable here?

roi shaul says:

hi. i dont understand why you need line #18 in TopSectionFragment class?
can you explain it please.

Ebrahim Salehi says:

Thanks dude for the great tutorial. I am a java developer but newbie in android, in 3 days I have learned a lot here.
For those who find this tutorial difficult to understand, looking at these topics in Java would help a lot:
Interfaces
Inner Classes
And especially: Anonymous Inner Classes
You might find it helpful to have a look at couple of examples in "java swing" , especially on event handling.

les paul says:

After this point I believe you need an intermediate Java knowledge. So far it was kinda beginner deal.

Jullix993 says:

Man this was hard. :/

Ahmed Balfaqih says:

I agree with Jose. Of all the video tutorials you gave, including for other programming languages, this the most difficult to understand. I gave up in the middle of this video. There has to be an easier way to do all this. The result wasn't worth the confusion.



José Muñoz says:

This was the most difficult tutorial to follow in the series, so far.  I think a picture describing the relationships between the fragments, the activity and createMeme would have helped a great deal.

Write a comment