Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
On button click I want to show a progress dialog & load data to parse server, for this, I created a progress dialog and within run() I created a loaddata() which will load data to server & then dismiss the progress dialog.
when I click the button, Progress dialog should be visible but app got stopped instead..why?
My code -

Java
final ProgressDialog p = ProgressDialog.show(getApplicationContext(), "Registration",
"You are being registered", true, false);
new Thread(new Runnable() {
public void run() {
loaddata();
p.cancel();
}
}).start();
private int issuccessful(ParseObject testObject) {
				// TODO Auto-generated method stub
				try {
					testObject.save();
					return 1;
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					return 2;
				}
			}

private void loaddata() {
			ParseObject testObject = new ParseObject("Register");
				testObject.put("u_id", "v0001");
				testObject.put("f_name", a);
				testObject.put("m_name", x);
				testObject.put("l_name", c);
				testObject.put("contact", d);
				int y = issuccessful(testObject);
				if (y == 1) {
Toast.makeText(getApplicationContext(),"Successfully Registered!!",
Toast.LENGTH_LONG).show();
				} else {
					Toast.makeText(getApplicationContext(),
							"Sorry for inconvenience please try again",
							Toast.LENGTH_SHORT).show();
				}
			}
Posted
Updated 26-Jul-15 7:05am
v2
Comments
Dave Kreskowiak 26-Jul-15 10:17am    
And the question would be ......?
Member 11863945 26-Jul-15 13:04pm    
when I click the button, Progress dialog should be visible but app got stopped instead..why?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900