Hi everyone, having a large amount of trouble with fragments in my first attempt at creating an Android app and am in dire need of some help. I'll post the code below immediately with an explanation. I have experience with Java
but am new to Android applications. Have been trying to build a mass e-mailing app to allow a user to email every politician in the country with one email. But, I'm having a ton of trouble with my email fragment. I had originally planned it to be an activity but as I need to use it twice (once for a guest and once for a registered user) I went with a fragment as I know they can be re-used. The problem I'm having is to do with Bundles/Intents. I have gotten intents to work correctly but through the videos and tutorials I've watched it seems like you can't use intents to pass data back to the activity from a fragment and have to use a bundle. if this is wrong please correct me. I'm attempting to store the user inputted e-mail and subject line. This is what I have so far. I'll post the fragment and the activity, if you need anything else please let me know
And the Activity (it's very bare bones, trying to get the fragment to work first)
This is currently giving me an illegal state exception due to, specifically, this ( java.lang.IllegalStateException: Could not find method storeEmail(View) in a parent or ancestor Context for android:onClick attribute defined on view class com.google.android.material.button.MaterialButton with id 'confirmFrag'). I searched online and the closest suggestion I found was to make the declared variables public but that didn't help at all. The same exception occured.
There is an extremely high possibility this is wrong because I've been doing the wrong thing. TBH, the different classes I've seen on fragments have made me extremely muddled due to using multiple different ways of doing the same thing. I don't know if I'm sending correctly. I had not written how to recieve it yet, I wanted to check if the bundle was carrying the messages in debug mode. But when I hit the confirmFrag button I get the crash.
If I've done the complete wrong thing, then please could someone tell me what I'm doing wrong. I'm very lost with this mistake, thought I had finally got it.