-4

I've been working in infoSec for almost a decade and now I'm trying to pivot into Android development. I'm completely new in the field of Android. This question has probably been answered before, but I didn't find anyone using pictures. So here we go:

I want to grasp this thing with Fragments and activities. Activities and fragments image

Basically I want to do a simple thing; get the result from GameFragment, pass it to GameActivity, pass it to ResultActivity, and then show it in the result fragment. (Or if there is another way to communicate with fragments in different activities)

3 Answers3

1

Yes there is many way below i mention :

  1. you can use shared preferences.

  2. you can use sqlite.

  3. you can pass data using intent.

Links will provide brief knowledge about this topics.

0

You can access the parent Activity of a Fragment by using getActivity() method. To pass data between activities you can use Intent s.

Salih Erikci
  • 5,076
  • 12
  • 39
  • 69
0

The simplest solution would be use of static variable in any common Class or in secondActivity. If you use in second receive that value using

variable = getActivity().getIntent().getExtras().getInt("key");

Then use "variable" value. Or declare in a common Class as like

public static int variable;

Assign value

CommonClassName.variable = 1;

Then use it.

Exigente05
  • 2,161
  • 3
  • 22
  • 42