我有一个广播接收器,我从中调用了intentservice。我想将在intentservice中收到的数据发送到activity.String s = extras.getString(" Notice")。我想发送这个收到新活动的字符串
答案 0 :(得分:1)
@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 :(得分:0)
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");
}
}
试试这个。很抱歉误会。
答案 2 :(得分:0)
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);
}
}