我有一个广播接收器正在呼叫intentservice,我想将intentservice中接收到的数据发送到一个activity.String s=extras.getString(“通知”).I想将接收到的字符串发送到一个新的活动
发布于 2014-09-19 09:29:01
@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);
} 发布于 2014-09-19 07:45:26
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");
}
}尝尝这个。抱歉误会了。
发布于 2014-09-19 08:00:27
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);
}
}https://stackoverflow.com/questions/25928804
复制相似问题