Transferring Data from Intent to Action

I have a broadcast receiver from which I call intentservice.I want to send the data received in the intentservice to activity.String s = extras.getString ("Notice"). I want to send this received string to a new activity

+4
source share
3 answers
@Override
protected void onHandleIntent(Intent arg0) {
   Intent dialogIntent = new Intent(getBaseContext(), myActivity.class);
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     dialogIntent.putExtra("value", extras.getString("Notice"));
     getApplication().startActivity(dialogIntent);
}   
+1
source
public class YourIntentService extends IntentService {

    @Override
    protected void onHandleIntent(Intent arg0) {
        // TODO Auto-generated method stub
        Intent intent = new Intent(this, YourNewActivity.class);
        intent.putExtra("YourStringKey", "yourString");
        startActivity(intent);
    }

    public YourIntentService() {
        super("YourIntentService");
    }

}

Try it. Sorry for misunderstanding.

0
source
public class MyIntentService extends IntentService {

public  MyIntentService() {
    super(" MyIntentService");

}

@Override
protected void onHandleIntent(Intent arg0) {
        String s=arg0.getExtras.getString("Notice")
        Intent i = new Intent(this, yourActivity.class);
        i.putExtra("Notice",s);
        getApplication().startActivity(i);
}   

}
0
source

All Articles