copy string from activity to another Android

KariiO

at begining i want to say sorry for my bad english i hope u understand me. I want to copy one string to another activity so i create :

package com.example.kliker;

import android.app.Application;


public class GlobalClass extends Application{

    private String name;
    private String email;


    public String getName() {

        return name;
    }

    public void setName(String aName) {

       name = aName;

    }

    public String getEmail() {

        return email;
    }

    public void setEmail(String aEmail) {

      email = aEmail;
    }

}

and in activity to set i use:

final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
globalVariable.setEmail("1");
globalVariable.setName("1");

and when i want get:

final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
a = globalVariable.getEmail();
b = globalVariable.getName();
mTextView.setText(a);

But it doesn't work ? I should refresh activity or something like that ?

http://speedy.sh/dvt94/Desktop.rar Manifest,activity from i get and set, activity set, activity get

I would like to make one activity outstay data about category and food also i want to make another activity when we are in it and when we click on food it send informations about itself category and chosen food, main activity download that information and by means of them it build graphic sentence

Kanak Sony

Use Bundle API - http://developer.android.com/reference/android/os/Bundle.html.

In your A Activity -

Intent intent = new Intent(A.this, B.class);
Bundle bundle = new Bundle();
bundle.putString("value", "String Value");
intent.putExtras(bundle);
startActivity(intent);

And, in B Activity -

Intent i = getIntent();
Bundle extras = i.getExtras();
String value = extras.getString("value");

You would be interested in this http://hmkcode.com/android-passing-data-to-another-activities/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Copy Android Activity from one app to another

From Dev

Copy Android Activity from one app to another

From Dev

How to pass an origin object(NOT COPY) from one activity to another on Android

From Dev

Transfer a string from list view on one activity to another in android

From Dev

how to transfer more then one string from one activity to another in android

From Dev

Start an Activity from another Activity on Xamarin Android

From Dev

Android - Pass String from activity to library activity

From Dev

Pass String[] from one activity to another

From Dev

How to send string from one activity to another?

From Dev

Pass String[] from one activity to another

From Dev

transferring data from string arrays into another activity

From Dev

Passing a string from one activity to another

From Dev

Get text from EditText into string to another activity

From Dev

how to return string from AsyncTask to another activity

From Dev

Return a String from AsyncTask to use in another Activity?

From Dev

How to pass an edittext string from an activity to a method in another activity?

From Dev

captured image in android is not fetched from another activity

From Dev

Android _ redirect from a service class to another Activity?

From Dev

passing a HashMap from one activity to another, android

From Dev

Android Start Activity from another class

From Dev

Android: switching from one layout activity to another

From Dev

Android changing the TextView from another activity

From Dev

Android : access to thread from another activity

From Dev

Android: switching from one layout activity to another

From Dev

Finish android activity from another with Kotlin

From Dev

without moving next activity Send data from another activity in android

From Dev

Android, how to detect that the activity is back from another activity?

From Dev

How to send and receive an ArrayList from one activity to another activity in Android?

From Dev

Android: How to access from activity to update private variable of another activity

Related Related

  1. 1

    Copy Android Activity from one app to another

  2. 2

    Copy Android Activity from one app to another

  3. 3

    How to pass an origin object(NOT COPY) from one activity to another on Android

  4. 4

    Transfer a string from list view on one activity to another in android

  5. 5

    how to transfer more then one string from one activity to another in android

  6. 6

    Start an Activity from another Activity on Xamarin Android

  7. 7

    Android - Pass String from activity to library activity

  8. 8

    Pass String[] from one activity to another

  9. 9

    How to send string from one activity to another?

  10. 10

    Pass String[] from one activity to another

  11. 11

    transferring data from string arrays into another activity

  12. 12

    Passing a string from one activity to another

  13. 13

    Get text from EditText into string to another activity

  14. 14

    how to return string from AsyncTask to another activity

  15. 15

    Return a String from AsyncTask to use in another Activity?

  16. 16

    How to pass an edittext string from an activity to a method in another activity?

  17. 17

    captured image in android is not fetched from another activity

  18. 18

    Android _ redirect from a service class to another Activity?

  19. 19

    passing a HashMap from one activity to another, android

  20. 20

    Android Start Activity from another class

  21. 21

    Android: switching from one layout activity to another

  22. 22

    Android changing the TextView from another activity

  23. 23

    Android : access to thread from another activity

  24. 24

    Android: switching from one layout activity to another

  25. 25

    Finish android activity from another with Kotlin

  26. 26

    without moving next activity Send data from another activity in android

  27. 27

    Android, how to detect that the activity is back from another activity?

  28. 28

    How to send and receive an ArrayList from one activity to another activity in Android?

  29. 29

    Android: How to access from activity to update private variable of another activity

HotTag

Archive