Java null pointer exception in Android application?

A

AC Question

java null pointer exception in android application

This is my main activity code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
EditText ed1;
ed1=(EditText) findViewById(R.id.editText);
final String Fname=ed1.getText().toString();
EditText ed2;
ed2=(EditText)findViewById(R.id.editText2);
final String Lname=ed2.getText().toString();
EditText ed3;
ed3=(EditText)findViewById(R.id.editText3);
final String Email=ed3.getText().toString();
EditText ed4;
ed4=(EditText)findViewById(R.id.editText4);
final String Password=ed4.getText().toString();
Button btn3;
btn3=(Button) findViewById(R.id.button3);
btn3.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
registerUser(Fname, Lname, Email,Password);
}
});
}
public Integer registerUser(String Firstname,String Lastname,String Email,String Password){
//log.debug("In Register...");
Toast.makeText(getApplicationContext(), "1", Toast.LENGTH_LONG).show();

XmlRpcClient client = getXmlRpcClient();
try {

HashMap<String, Object> fields = new HashMap<String, Object>();
fields.put("name",Firstname );
fields.put("display_name", Lastname);
fields.put("email", Email);
fields.put("password", Password);
Toast.makeText(getApplicationContext(), "3", Toast.LENGTH_LONG).show();
log.debug("Got the customer fields, rpc call to create customer");

List<Object> callParams = getCallParameters("res.partner", MainActivity.ActionType.CREATE);
callParams.add(fields);

Object result = client.execute("execute", callParams);

Integer customerId = (result != null) ? (Integer) result : null;

log.debug("Customer/Partner record created, Id = " + customerId);

//log.debug("About to create a user login in res_users");
registerUser(Firstname, Lastname, Email, Password);

return customerId;

} catch (Exception e) {
Toast.makeText(getApplicationContext(), "7"+e, Toast.LENGTH_LONG).show();
System.out.println("Excpt" + e);
Log.d(null,Log.getStackTraceString(new Exception()));
//log.error(e.getMessage());
//log.error(e.fillInStackTrace());
}
return 0;
}
When i click the register button it just throws the java null pointer exception though i have called the method and passed values for method inside the onclick listener but still am getting the same error
 

Trending Posts

Forum statistics

Threads
944,465
Messages
6,922,873
Members
3,159,568
Latest member
youngdaddy3