user3266062 user3266062 - 25 days ago 4
Android Question

How Send message from fragment to activity and received and use in activity?

Please please don't minus my question i confused when googling.
I used Android Tab Layout with Swipeable Views in my code for when user pressed setting button on an activity.

now I need send message from that extends from fragment to the activity that call the mainActivity of "Android Tab Layout with Swipeable Views".


Here's the solution:

Step 1 : From your fragment.

Intent i = new Intent(getActivity(), YourActivity.class);
        i.putExtra("key", "Your value1");
        i.putExtra("key2", "Your value2");
        i.putExtra("key3", "Your value3");

Step 2 : In your Activity where you want the result

Intent getResults = getIntent();
        String firstValue = getResults.getStringExtra("key1");
        String secondValue = getResults.getStringExtra("key2");
        String thirdValue = getResults.getStringExtra("key3");

Use those values your needs are.

Hope this helps.. :)