Android Open Source - acs-android-sdk Sign Up






From Project

Back to project page acs-android-sdk.

License

The source code is released under:

Apache License

If you think the Android project acs-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.appcelerator.cloud.demo;
//from  ww w . ja  v a  2s . c  o m
import java.io.IOException;
import java.util.HashMap;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.appcelerator.cloud.sdk.CCRequestMethod;
import com.appcelerator.cloud.sdk.ACSClientError;


public class SignUp extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup);

        View signupButton = findViewById(R.id.signup);
        signupButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
            try {
          performSignup();
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }});
        
        View cancelButton = findViewById(R.id.cancel);
        cancelButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
            finish();
        }});
    }

    public void performSignup() {
    final ProgressDialog dialog = new ProgressDialog(SignUp.this);
      dialog.setMessage("Registering...");
      dialog.show();
      
      String firstName = ((EditText) findViewById(R.id.first_name)).getText().toString();
      String lastName = ((EditText) findViewById(R.id.last_name)).getText().toString();
      String email = ((EditText) findViewById(R.id.email_address)).getText().toString();
      String password = ((EditText) findViewById(R.id.pw)).getText().toString();

      String errorMsg = null;
    try {
      HashMap<String, Object> dataMap = new HashMap<String, Object>();
      dataMap.put("email", email);
      dataMap.put("password", password);
      dataMap.put("password_confirmation", password);
      dataMap.put("first_name", firstName);
      dataMap.put("last_name", lastName);
      DemoApplication.getSdk().sendRequest("users/create.json", CCRequestMethod.POST, dataMap, false);
        /*CCRestfulRequest signupRequest;
        signupRequest = new CCRestfulRequest(ACSClient.getDefaultInstance());
        signupRequest.registerUser(email, "", firstName, lastName, password);*/
        Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
    } catch (ACSClientError e) {
      errorMsg = e.getMessage();
      
    } catch (IOException e) {
      e.printStackTrace();
    } 
    dialog.dismiss();
    
    if (errorMsg != null) {
      AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Signup Failed");
        alertDialog.setMessage(errorMsg);
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
              // here you can add functions
             dialog.dismiss();
           }
        });
        alertDialog.setIcon(R.drawable.icon);
        alertDialog.show();
    }
    }

}




Java Source Code List

com.appcelerator.cloud.demo.BaloonLayout.java
com.appcelerator.cloud.demo.CheckinAdapter.java
com.appcelerator.cloud.demo.DemoApplication.java
com.appcelerator.cloud.demo.DemoSession.java
com.appcelerator.cloud.demo.Explore.java
com.appcelerator.cloud.demo.MyDlgCustomizer.java
com.appcelerator.cloud.demo.PlaceAdapter.java
com.appcelerator.cloud.demo.PlaceView.java
com.appcelerator.cloud.demo.SignUp.java
com.appcelerator.cloud.demo.TabView.java
com.appcelerator.cloud.demo.UserView.java
com.appcelerator.cloud.pushdemo.ArrivalActivity.java
com.appcelerator.cloud.pushdemo.CustomReceiver.java
com.appcelerator.cloud.pushdemo.ExtendedReceiver.java
com.appcelerator.cloud.pushdemo.GCMUtility.java
com.appcelerator.cloud.pushdemo.PushActivity.java
com.appcelerator.cloud.pushdemo.PushNotificationsManager.java
com.appcelerator.cloud.sdk.ACSClientError.java
com.appcelerator.cloud.sdk.ACSClient.java
com.appcelerator.cloud.sdk.CCConstants.java
com.appcelerator.cloud.sdk.CCMeta.java
com.appcelerator.cloud.sdk.CCMultipartEntity.java
com.appcelerator.cloud.sdk.CCObject.java
com.appcelerator.cloud.sdk.CCPagination.java
com.appcelerator.cloud.sdk.CCRequestMethod.java
com.appcelerator.cloud.sdk.CCResponse.java
com.appcelerator.cloud.sdk.CCUser.java
com.appcelerator.cloud.sdk.SerializableCookie.java
com.appcelerator.cloud.sdk.oauth2.ACSClientDialog.java
com.appcelerator.cloud.sdk.oauth2.DialogError.java
com.appcelerator.cloud.sdk.oauth2.DialogListener.java
com.appcelerator.cloud.sdk.oauth2.DlgCustomizer.java
com.appcelerator.cloud.sdk.oauth2.Util.java
com.appcelerator.com.cloud.demotest.TestDriver.java