Passing String between classes

0

I have my main class where I have

... String ola="Hello little friends";

And I have my other class:

public class NotificacaoDiaria extends BroadcastReceiver {
    @Override
    public void onReceive(Context arg0, Intent arg1) {
        Toast.makeText(arg0, "Funciona!!!", Toast.LENGTH_LONG).show();
        Toast t = Toast.makeText(this, ola, Toast.LENGTH_SHORT).show();
    }
}

I want this string to be interpreted here, not for this function, but for me to control it in that class.

    
asked by anonymous 13.09.2014 / 06:00

1 answer

1

I'm not sure if that's what you're looking for:

In the class you call BroadcastReceiver

Intent intent .....
intent.putExtra("label", String);
sendBroadcast(intent);

No BroadcastReceiver

public void onReceive(Context arg0, Intent arg1) {
   String teste = arg1.getStringExtra("teste"); 
   Toast.makeText(arg0, teste, Toast.LENGTH_LONG).show();
}
  

author-generated change

    
13.09.2014 / 07:45