-1

i Want to Pass String value Of One Activity And Value Can Get In Any activity

i have Three Activity in First Activity...Have Some String Value

in Second Activity..Have Some String Value

In Third Activity ...I want To get String Value Of 1st and Second's String Value

how to pass that's String Value In Any Activity

please Tell Me How to pass thank u in advance

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
  • Please ask your question in SO formate and regulations, also put your tried code here – Kirtikumar A. Sep 09 '14 at 10:41
  • Change the string value of first and second activity to a static variable and on your third activity get it by using FirstActivity.yourstring. Simplest way to help you since you didn't provide much information. – Pedro Oliveira Sep 09 '14 at 10:43

2 Answers2

0

You can use broadcast intent and putExtra string

Broadcast:

    Intent broadcast = new Intent();
    broadcastLocation.setAction(ACTION);
    broadcastLocation.putExtra(EXTRA, location);
    sendBroadcast(broadcast);

In activity you want to get the string you register broadcast receiver onResume() and unregister it onPause():

    private class LocationApprovedListener extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction() != null && intent.getAction().equals(LocationService.ACTION)) {

            String location = (String) intent
                .getParcelableExtra(LocationService.EXTRA);


        }
    }
}
SpyZip
  • 5,511
  • 4
  • 32
  • 53
0

I suggest to use SharedPreferences It is really easy to use and you can fetch data in any activities

here is a good explanation of it

Hope it helps you

Hamid Reza
  • 624
  • 7
  • 23