有人可以告诉我为什么我在代码的这一部分中会得到null指针异常错误?尤其是此行-----字符串tokenizer wholeresp = new StringTokenizer(modgen.Response," |");
public void run() {
modGen = new ClaimVoucherActivity();
Intent intent = new Intent(ClaimVoucherActivity.this,ClaimVoucherDetailsActivity.class);
intent.putExtra("customerID", customerID);
intent.putExtra("type", type);
intent.putExtra("name", name);
intent.putExtra("email", email);
intent.putExtra("voucher", voucher);
intent.putExtra("branch", branch);
intent.putExtra("issued", issued);
intent.putExtra("expiration", expiration);
intent.putExtra("status", status);
intent.putExtra("vouchername", vouchername);
intent.putExtra("employeeid", employeeid);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} }
);
当我看到您的代码时,您可以使用您的活动类初始化modgen
,但不正确。您必须使用以下代码:
public void run() {
modGen = new ModGenClassName();
StringTokenizer wholeresp = new StringTokenizer(modGen.response,"|");
Intent intent = new Intent(ClaimVoucherActivity.this,ClaimVoucherDetailsActivity.class);
intent.putExtra("customerID", customerID);
intent.putExtra("type", type);
intent.putExtra("name", name);
intent.putExtra("email", email);
intent.putExtra("voucher", voucher);
intent.putExtra("branch", branch);
intent.putExtra("issued", issued);
intent.putExtra("expiration", expiration);
intent.putExtra("status", status);
intent.putExtra("vouchername", vouchername);
intent.putExtra("employeeid", employeeid);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
我不知道modgen的类名称,您需要用ModGenClassName
这不是通过您的意图单独发送10个项目的好方法,我认为您可以使用最多两个类别的所有项目,然后发送下一个活动的对象,这是更好,更清洁的方式。