I have pass the data from Project1.java to Claims.java and named them to name and result. They can show on c.setText. But when I want to save them in SQLite database, app crashed.
Claims.java
String result;
String name;
fk = bundle.getLong("ab");
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
int button = data.getIntExtra("k1", 0);
if (button == 1) {
switch (requestCode) {
case 0:
result = data.getStringExtra("text");
name = data.getStringExtra("a");
as=Long.parseLong(result);
c.setText(" " + name + "------" + "RM " + result);
break;
case 1:
result = data.getStringExtra("text");
name = data.getStringExtra("a");
as=Long.parseLong(result);
c.setText(" " + name + "------" + "RM " + result);
break;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
if ((name != null && name.trim().length() > 0) && (result != null && result.trim().length() > 0)) {
SB.insertStaffBenefit(name, result, fk);
} else {
Toast.makeText(getActivity(), "A", Toast.LENGTH_LONG).show();
}
}
});
11-04 17:09:40.876 20272-20272/com.example.project.project E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.project.project, PID: 20272 java.lang.NullPointerException at com.example.project.project.Claims$7.onClick(Claims.java:153) at android.view.View.performClick(View.java:4654)
Aucun commentaire:
Enregistrer un commentaire