我有一个广播接收器,从中调用intentservice.I想要将intentservice中接收到的数据发送到activity.String s = extras.getString(“Notice”)。我想将此收到的字符串发送到新活动将数据从意图服务传递到活动
4
A
回答
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);
}
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");
}
}
试试这个。我为我的误会道歉。
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);
}
}
相关问题
- 1. 使用意图将数据从活动传递到服务
- 2. 将数据从意图传递到片段到活动
- 3. 如何将数据动态地从活动传递到服务?
- 4. NullPointerException将数据从活动传递到意图
- 5. 从活动传递意图到服务失败
- 6. 无法将数据从活动传递到服务
- 7. Android:如何将数据从活动传递到服务?
- 8. 将数据从线程服务传递到活动
- 9. 如何将数据从服务传递到高频活动
- 10. 将数据从服务传递到活动
- 11. 将数据从服务传递到当前活动
- 12. 将数据从活动传递到服务
- 13. 将数据从服务传递到活动
- 14. 将数据从非活动类传递到活动时(通过意图)
- 15. 将数据传回活动从服务
- 16. 将数据从活动传递到类
- 17. 将数据从活动传递到类
- 18. 将数据从AccessibilityService传递到活动
- 19. 将数据传递到由服务启动的活动
- 20. 无法将位图从活动传递到AIDL服务
- 21. 从活动传递意图数据到类
- 22. 将活动A到服务B的数据传递到活动C
- 23. 通过意向将数据从服务传递到小部件
- 24. 从意图传递数据到其他使用Python服务器
- 25. 将数据从子活动传递到父活动
- 26. 将数据从一个活动传递到另一个活动
- 27. 将数据从新活动传递到旧活动?
- 28. 将数据从tabhost活动传递到其内部活动
- 29. 将数据从一个活动传递到另一个活动
- 30. 将意图传递给活动?
我想从intentservice从广播接收器 – user3790145 2014-09-19 07:49:54
将数据发送到一个activity.Not它给了一个错误,有些标志是缺少 – user3790145 2014-09-19 09:24:35
然后添加像'intent.addFlags该标志(Intent.FLAG_ACTIVITY_NEW_TASK) ;' – 2014-09-19 09:26:54