Question: I didn't program android for a while and i see the firebase messaging service got deprecated.
I implemented the new `FirebaseMessagingService` class and i have overridden the onNewToken in order to get the token, but the method is not even being called, as the documentation said this method should be ran automaticlly. but now i got confused, why the token is not generated? here is what i implemented 

```
public class FireBsaeTest extends FirebaseMessagingService {
    public FireBsaeTest(){
    }
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        if (remoteMessage.getData().size() > 0) {

            } else {

            }

        }

        if (remoteMessage.getNotification() != null) {
        }

    }
    @Override
    public void onNewToken(String token) {
        System.out.println(token);

    }}

```

and here is the manifest 

```
 <service android:name=".FireBsaeTest">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

```

did i miss something ?

**UPDATE**

i tried to call it manually from my activity it thorw new Illegal exception firebaseNotInilized

```
 FirebaseApp.initializeApp(this);
        FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
            @Override
            public void onSuccess(InstanceIdResult instanceIdResult) {
                System.out.println(instanceIdResult.getToken());
            }
        });

```

Answer: 
It seems you want to send a value from One Activity to Another, Just use Bundle for this problem.

**MainActivity.java**

```
 String MyString = editText.getText().toString();

Intent intent = new Intent(this, MainActivity.class);
   Bundle bundle = new Bundle();
 bundle.putString("MyValue", MyString);  //MyValue name is your referrence name
 intent.putExtras(bundle);
  startActivity(intent);  

```

**SecondActivity.java**

```
Bundle bundle = getIntent().getExtras();
String text = bundle.getString("MyValue"); //have you see that MyValue from MainActivity and SecondActivity must be the same
 textView.setText(text);

```

[More About Bundle](https://stackoverflow.com/questions/4999991/what-is-a-bundle-in-an-android-application)

**OR You can Use this Method**

**MainActivity.java**

```
 String MyString = editText.getText().toString();
Intent in = new Intent(MainActivity.this, SecondActivity.class)
                            .putExtra("MyValue", MyString);
                    startActivity(in);
                    finish();

```

**SecondActivity.class**

```
String text = getIntent().getStringExtra("MyValue"); //Make sure to get the type of value you want to use (getStringExtra)
textview.setText(text);

```
You have to use `Intent` class to achieve this behaviour.

Do something like this:

1. `MainActivity.class`

```
Intent intent = new Intent(MainActivity.this,second.class());
intent.putExtra("text", yourText);

```
2. `second.class`, in your `onCreate()` method  

```
String text = getIntent().getStringExtra("text");
textView.setText("text");

```