Android 将附加项传递给FragmentActivity,其为空
im将数据从一个类发送到FragmentActivity,如下所示:Android 将附加项传递给FragmentActivity,其为空,android,android-fragments,Android,Android Fragments,im将数据从一个类发送到FragmentActivity,如下所示: public class OpenReportAction extends Action { private WorkActivity listener; public OpenReportAction(Activity listener) throws BadListenerException { if (!(listener instanceof WorkActivity)) {
public class OpenReportAction extends Action {
private WorkActivity listener;
public OpenReportAction(Activity listener) throws BadListenerException {
if (!(listener instanceof WorkActivity)) {
throw new BadListenerException("Listener must be context of WorkActivity");
}
this.listener = (WorkActivity) listener;
}
@Override
public void execute(List<Report> reports, Questions question) {
Intent replyIntent = new Intent(listener, ReplyActivity.class);
replyIntent.putExtra("id", listener.getWork().getID());
replyIntent.putExtra("questions", question);
replyIntent.putParcelableArrayListExtra("reports", (ArrayList<Report>) reports);
listener.openReportOk(question);
listener.startActivity(replyIntent);
}
public interface ReportCreatedCallback {
void openReportOk(Questions question);
void openReportError(WorkActionError cause);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.reply_activity);
getData(getIntent());
setFragment();
}
private void getData(Intent data) {
ID = data.getLongExtra("id", 0);
questions = data.getParcelableExtra("questions");
reports = data.getParcelableArrayListExtra("reports");
}
但是在FragmentActivity(ReplyActivity)中,额外的总是空的。我如何才能得到它?确保“reports”额外的不是一个大对象。
大型对象无法越过目标。
提示:如果是这种情况,您将看到类似的日志:“JAVA活页夹故障”将您的代码张贴在活动中读取额外代码的位置您的
launchMode
标志是什么?尝试重写onNewIntent(Intent)并查看它是否已被激发。它未被激发…:s