I'm trying to integrate QuickBlox for audio and video calls.
I followed tutorial but it doesn't work.
To enable an ability of receiving incoming WebRTC calls need add signalling manager but method
public void signalingCreated(QBSignaling qbSignaling, boolean createdLocally)
doesn't call. What is wrong?
jniLibs and permissions added
build: added dependency
compile 'com.quickblox:quickblox-android-sdk-videochat-webrtc:3.3.0'
Here code:
private EditText mUsername;
private EditText mPassword;
private Button mSignUp;
private Button mSignIn;
private Button mCall;
private QBUser mUser;
QBRTCClient client;
QBSessionManager sessionManager;
QBChatService chatService;
QBRTCSession qbrtcSession;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET);
QBSettings.getInstance().setAccountKey(ACCOUNT_KEY);
mUsername = (EditText) findViewById(R.id.username);
mPassword = (EditText) findViewById(R.id.password);
mSignIn = (Button) findViewById(R.id.sign_in);
mSignUp = (Button) findViewById(R.id.sign_up);
mCall = (Button) findViewById(R.id.button_call);
client = QBRTCClient.getInstance(MainActivity.this);
QBChatService.setDebugEnabled(true);
QBChatService.setDefaultAutoSendPresenceInterval(60);
chatService = QBChatService.getInstance();
mSignIn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
mUser = new QBUser(mUsername.getText().toString(), mPassword.getText().toString());
// QBUsers.signIn(mUser).performAsync(new QBEntityCallback<QBUser>() {
QBAuth.createSession(mUser).performAsync(new QBEntityCallback<QBSession>() {
#Override
public void onSuccess(QBSession qbUser, Bundle bundle) {
Log.d(TAG, "My user: " + mUser);
Log.d(TAG, "received user: " + qbUser);
Log.d(TAG, "user logged in");
mUser.setId(qbUser.getUserId());
chatService.login(mUser, new QBEntityCallback<QBUser>() {
#Override
public void onSuccess(QBUser qbUser, Bundle bundle) {
Log.d(TAG, "user logged in to the chat");
client.prepareToProcessCalls();
chatService.getVideoChatWebRTCSignalingManager().addSignalingManagerListener(new QBVideoChatSignalingManagerListener() {
#Override
public void signalingCreated(QBSignaling qbSignaling, boolean createdLocally) {
Log.d(TAG, "created locally: " + createdLocally);
if (!createdLocally) {
client.addSignaling((QBWebRTCSignaling) qbSignaling);
}
}
});
This line never call:
Log.d(TAG, "created locally: " + createdLocally);
the method signalingCreated() is called when you make a call or when you get a call. You can look at video sample it works all ok. BTW, you don't need to manage session manually and there is no need to call createSession methods. Just use QBUsers.signIn(). Documentation.
Related
When i try to go to the next activity by pressing the sign_up in the sign up page or log in in the log page when the user already exists, the app just exits and brings up an error.
Sign up Activity
// variable
final String TAG ="signUp";
private MaterialEditText edit_name;
private MaterialEditText edit_password;
//DECLARING & INITIALISING BUTTON TO SIGN UP
FButton sign_Up;
final String KEY_NAME = "name";
final String KEY_PASSWORD ="password";
final String KEY_MARKS ="marks";
private FirebaseFirestore db = FirebaseFirestore.getInstance();
private DocumentReference user_reference = db.document("Users/Users details");
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_up);
//INITIALISING THE EDITTEXT VIEWS
edit_name = findViewById(R.id.editName);
edit_password = findViewById(R.id.editPassword);
sign_Up = findViewById(R.id.btn_signUp);
sign_Up.setOnClickListener(view ->
{
user_reference.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>()
{
Map<String, Object> users = new HashMap<>();
String name = edit_name.getText().toString();
String password = edit_password.getText().toString();
#Override
public void onSuccess(DocumentSnapshot documentSnapshot)
{
if(documentSnapshot.exists())
{ // GETTING INFORMATION FROM FIRESTORE DATABASE
name = documentSnapshot.getString(KEY_NAME);
password = documentSnapshot.getString(KEY_PASSWORD);
Toast.makeText(sign_up.this, "This user already exist, Try again", Toast.LENGTH_LONG).show();
}
else
{
users.put(KEY_NAME,name);
users.put(KEY_PASSWORD, password);
db.collection("Users").document(name).set(users);
Toast.makeText(sign_up.this,"Registered",Toast.LENGTH_LONG).show();
Intent i = new Intent(sign_up.this,sum_selection.class);
startActivity(i);
}
}// END OF ONSUCCESS
})
.addOnFailureListener(new OnFailureListener()
{
#Override
public void onFailure(#NonNull Exception e)
{
Toast.makeText(sign_up.this, "Error",Toast.LENGTH_LONG).show();
Log.d(TAG,e.toString());
}
});
Log in Activity
private MaterialEditText user_name;
private MaterialEditText user_password;
FButton sign_in;
private FirebaseFirestore database = FirebaseFirestore.getInstance();
private DocumentReference user_reference = database.document("Users/users details");
final String KEY_NAME = "name";
final String KEY_PASSWORD = "password";
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
sign_in = findViewById(R.id.btn_sign_in);
sign_in.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View view) // log in button
{
user_reference.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>()
{
#Override
public void onSuccess(DocumentSnapshot documentSnapshot)
{
if(documentSnapshot.exists())
{
Toast.makeText(log_in.this,"Welcome"+ user_name, Toast.LENGTH_LONG).show();
// ADD INTENT TO GO TO THE SUM_SELECTION PAGE
Intent in = new Intent(log_in.this, sum_selection.class);
startActivity(in);
}
else
{
// DISPLAY ERROR MESSAGE TO USER
Toast.makeText(log_in.this, "User does not exist", Toast.LENGTH_LONG).show();
}
}
})
.addOnFailureListener(new OnFailureListener()
{
#Override
public void onFailure(#NonNull Exception e)
{
Log.d(TAG, e.toString());
}
}); ```
[Error message][1]
[1]: https://i.stack.imgur.com/8gR62.png
Intent i = new Intent((this/activity),LoginActivity.class);
(this/activity).startActivity(i);
Check your intent properly, Intent take current activity as the first param and the activity you want to load up as the second param. Also, call startActivity(i) from the activity context becuase currently you are under the context of Firebase Listener.
Also, post the error log.
i want to register then when clicked on register button a verification email is sent to the email address.on clicking the link in the email.the email is verified.and the user can now login from the login screen.
RegisterActivity.java
public class RegisterActivity extends AppCompatActivity {
private static final String TAG = "RegisterActivity";
private Context mContext;
private String email, username, password;
private EditText mEmail, mPassword, mUsername;
private TextView loadingPleaseWait;
private Button btnRegister;
private ProgressBar mProgressBar;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private FirebaseMethods firebaseMethods;
private FirebaseDatabase mFirebaseDatabase;
private DatabaseReference myRef;
private String append = "";
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mContext = RegisterActivity.this;
//mAuth = FirebaseAuth.getInstance();
firebaseMethods = new FirebaseMethods(mContext);
Log.d(TAG, "onCreate: started.");
initWidgets();
setupFirebaseAuth();
init();
}
private void init(){
btnRegister.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
email = mEmail.getText().toString();
username = mUsername.getText().toString();
password = mPassword.getText().toString();
if(checkInputs(email, username, password)){
mProgressBar.setVisibility(View.VISIBLE);
loadingPleaseWait.setVisibility(View.VISIBLE);
firebaseMethods.registerNewEmail(email, password, username);
}
}
});
}
private boolean checkInputs(String email, String username, String password){
Log.d(TAG, "checkInputs: checking inputs for null values.");
if(email.equals("") || username.equals("") || password.equals("")){
Toast.makeText(mContext, "All fields must be filled out.", Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
private void initWidgets(){
Log.d(TAG, "initWidgets: Initializing Widgets.");
mEmail = (EditText) findViewById(R.id.input_email);
mUsername = (EditText) findViewById(R.id.input_username);
btnRegister = (Button) findViewById(R.id.btn_register);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
loadingPleaseWait = (TextView) findViewById(R.id.loadingPleaseWait);
mPassword = (EditText) findViewById(R.id.input_password);
mContext = RegisterActivity.this;
mProgressBar.setVisibility(View.GONE);
loadingPleaseWait.setVisibility(View.GONE);
}
private boolean isStringNull(String string){
Log.d(TAG, "isStringNull: checking string if null.");
if(string.equals("")){
return true;
}
else{
return false;
}
}
private void setupFirebaseAuth(){
Log.d(TAG, "setupFirebaseAuth: setting up firebase auth.");
mAuth = FirebaseAuth.getInstance();
mFirebaseDatabase = FirebaseDatabase.getInstance();
myRef = mFirebaseDatabase.getReference();
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
myRef.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
//1st check: Make sure the username is not already in use
if(firebaseMethods.checkIfUsernameExists(username, dataSnapshot)){
append = myRef.push().getKey().substring(3,10);
Log.d(TAG, "onDataChange: username already exists. Appending random string to name: " + append);
}
username = username + append;
//add new user to the database
firebaseMethods.addNewUser(email, username, "", "", "");
Toast.makeText(mContext, "Signup successful. Sending verification email.", Toast.LENGTH_SHORT).show();
mAuth.signOut();
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
finish();
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
// ...
}
};
}
#Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
#Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
}
Here are the firebase methods like to register new email,add new user, send verification email etc...
FirebaseMethods.java
public class FirebaseMethods {
private static final String TAG = "FirebaseMethods";
//firebase
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private FirebaseDatabase mFirebaseDatabase;
private DatabaseReference myRef;
private String userID;
private Context mContext;
public FirebaseMethods(Context context) {
mAuth = FirebaseAuth.getInstance();
mFirebaseDatabase = FirebaseDatabase.getInstance();
myRef = mFirebaseDatabase.getReference();
mContext = context;
if(mAuth.getCurrentUser() != null){
userID = mAuth.getCurrentUser().getUid();
}
}
public boolean checkIfUsernameExists(String username, DataSnapshot datasnapshot){
Log.d(TAG, "checkIfUsernameExists: checking if " + username + " already exists.");
User user = new User();
for (DataSnapshot ds: datasnapshot.child(userID).getChildren()){
Log.d(TAG, "checkIfUsernameExists: datasnapshot: " + ds);
user.setUsername(ds.getValue(User.class).getUsername());
Log.d(TAG, "checkIfUsernameExists: username: " + user.getUsername());
if(StringManipulation.expandUsername(user.getUsername()).equals(username)){
Log.d(TAG, "checkIfUsernameExists: FOUND A MATCH: " + user.getUsername());
return true;
}
}
return false;
}
/**
* Register a new email and password to Firebase Authentication
* #param email
* #param password
* #param username
*/
public void registerNewEmail(final String email, String password, final String username){
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(mContext, R.string.auth_failed,Toast.LENGTH_SHORT).show();
}
else if(task.isSuccessful()){
//send verification email
sendVerificationEmail();
userID = mAuth.getCurrentUser().getUid();
Log.d(TAG, "onComplete: Authstate changed: " + userID);
}
}
});
}
public void sendVerificationEmail(){
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null){
user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()){
}else{
Toast.makeText(mContext,"Couldn't send verification email.",Toast.LENGTH_SHORT).show();
}
}
});
}
}
public void addNewUser(String email, String username, String description, String website, String profile_photo){
User user = new User( userID, 1, email, StringManipulation.condenseUsername(username) );
myRef.child(mContext.getString(R.string.dbname_users))
.child(userID)
.setValue(user);
UserAccountSettings settings = new UserAccountSettings(
description,
username,
0,
0,
0,
profile_photo,
username,
website
);
myRef.child(mContext.getString(R.string.dbname_user_account_settings))
.child(userID)
.setValue(settings);
}
}
This are the log lines....
01-09 13:16:06.014 21548-21548/com.example.vishal.myinstagram D/RegisterActivity: onAuthStateChanged:signed_out
01-09 13:16:06.015 21548-21588/com.example.vishal.myinstagram D/FA: Connected to remote service
01-09 13:16:06.015 21548-21588/com.example.vishal.myinstagram V/FA: Processing queued up service tasks: 4
01-09 13:16:06.017 21548-21994/com.example.vishal.myinstagram W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000003a/n/arm64-v8a
01-09 13:16:11.043 21548-21588/com.example.vishal.myinstagram V/FA: Inactivity, disconnecting from the service
01-09 13:16:21.029 21548-21548/com.example.vishal.myinstagram W/Settings: Setting device_provisioned has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
01-09 13:16:21.957 21548-21548/com.example.vishal.myinstagram W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
01-09 13:16:32.737 21548-21548/com.example.vishal.myinstagram D/RegisterActivity: checkInputs: checking inputs for null values.
01-09 13:16:32.743 21548-21548/com.example.vishal.myinstagram W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms
01-09 13:16:34.088 21548-21548/com.example.vishal.myinstagram D/FirebaseMethods: createUserWithEmail:onComplete:false
Thanks in advance...
So before you can set any OnClickListener on a view, you must first initialize a variable with findViewById(R.id.button_register). For example,
private Button registerButton;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
...
registerButton = (Button) findViewById(R.id.button_register);
registerButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//handle click event
}
});
...
}
It is worth a mention that if you are using the support library >26 you do not need to cast the view anymore and can omit the (Button) in the initialization of registerButton. Android Studio should even prompt you that casting is no longer necessary.
https://stackoverflow.com/a/44903372/7900721
Now the R.id is something that is set upon the view in the layout XML file.
<Button
android:id="#+id/button_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/my_button_text"/>
Search for findViewById in the docs for more information
https://developer.android.com/reference/android/view/View.html
Just a recommendation for some cleaner code that is more readable, I'd recommend creating a private variable of View.OnClickListener that you pass in as the listener as shown below.
#Override
protected void onCreate(Bundle savedInstanceState) {
...
fab.setOnClickListener(clickListener);
}
/**
* Handle click listeners
*/
private View.OnClickListener clickListener = new View.OnClickListener() {
#Override
public void onClick(View v) {
//handle click event here
}
};
So if you begin to handle multiple click events, you could handle them in one section. As far as readability for others to maintain the code, it keeps methods such as onCreate() more concise with purpose of where each action is handled instead of scanning through multiple anonymous classes which would need to be instantiated for each setOnClickListener
My problem is solved...their was a problem in my jason file...anyway thanks everyone...
Hoping someone can help me on this, i've been trying at it for days.I'm building an Android app and integrating Amazon Cognito login.
I am wanting to create users as admin only in Amazon Cognito using the admin panel. When doing so, one requirement is that users change their password. Within the CognitoUserPoolSignInProvider which is an anonymous class, in order to authenticate users with new passwords i have the following code in the anonymous class:
#Override
public void authenticationChallenge(final ChallengeContinuation continuation) {
if ("NEW_PASSWORD_REQUIRED".equals(continuation.getChallengeName())) {
NewPasswordContinuation newPasswordContinuation = (NewPasswordContinuation) continuation;
newPasswordContinuation.setPassword("users new password goes here");
continuation.continueTask();
}
}
I have a separate Activity class called ChangePassword. This links to a User Interface and gets the input in an edit text box from the user.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password);
password = (EditText) findViewById(R.id.newPassword);
submit = (Button) findViewById(R.id.submit);
String pass = password.getText().toString();
How do i get the users input into the anonymous class to set the new password?
Any help is much appreciated
You need to use the button click callback to pull in the user password. As your code is written now, the password will be set to an empty string (or whatever is in the EditText field at the time of creation).
Start with this:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password);
final EditText password = (EditText) findViewById(R.id.newPassword);
Button submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String pass = password.getText().toString();
}
});
}
Once you have the button click action setup, create a class instance that overrides the authenticationChallenge method. Pass that class to the appropriate AWS class for authentication. Something like this:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password);
final EditText password = (EditText) findViewById(R.id.newPassword);
Button submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String pass = password.getText().toString();
AuthenticationHandler h = new AuthenticationHandler() {
#Override
public void onSuccess(CognitoUserSession cognitoUserSession, CognitoDevice cognitoDevice) { }
#Override
public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String s) { }
#Override
public void getMFACode(MultiFactorAuthenticationContinuation multiFactorAuthenticationContinuation) { }
#Override
public void authenticationChallenge(ChallengeContinuation continuation) {
if ("NEW_PASSWORD_REQUIRED".equals(continuation.getChallengeName())) {
NewPasswordContinuation newPasswordContinuation = (NewPasswordContinuation) continuation;
newPasswordContinuation.setPassword(pass);
continuation.continueTask();
}
}
#Override
public void onFailure(Exception e) { }
};
CognitoUserPool pool = new CognitoUserPool(getApplicationContext(), "poolId", "clientId", "clientSecret", Regions.US_WEST_2);
pool.getUser("userId").getSession(h);
}
});
}
These two methods addUser() and viewDetails() methods are not being used in this my main activity file. I could find the reason, I don't know where do I have to call them. I am using Android Studio.
public class MainActivity extends AppCompatActivity {
EditText userName, password;
DatabaseAdapter databaseHelper;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userName = (EditText) findViewById(R.id.editTextUser);
password = (EditText) findViewById(R.id.editTextPass);
databaseHelper = new DatabaseAdapter(this);
}
public void addUser(View view) {
String user = userName.getText().toString();
String pass = password.getText().toString();
long id = databaseHelper.insertData(user, pass);
if (id < 0) {
Message.message(this, "Unsuccessful");
} else {
Message.message(this, "Successful");
}
}
public void viewDetails(View view) {
String data = databaseHelper.getAllData();
Message.message(this, data);
}
}
After watching this code you are only declaring a function and give the definition of the function you are not using it or calling it .. any where that's why android studio show you not using this method's...
You can call this method like addUser(); or viewDetails();
I'm doing a Small android Application. In that I'm storing The user entered Information to my local data base With Http Rest Call.
There is nothing problem with the service It is working fine I tested In Browser and postman I'm able to Perform CRUD Operations through Postman Client.
But When I try to POST OR GET From Android It is Throwing Error Like I/O error On Post method Connection Refused.
I don't Know the Reason for this.
Below Is My Code in Android.
This code is for GET Request.
public class Result extends AppCompatActivity {
String ID;
Login login=new Login();
final String url = "http://192.168.1.189:9001/login";
// List login = new ArrayList<>();
Button logout;
TextView nameTv, ageTv, emailTv, usernameTv;
String NAME, AGE, EMAIL, USERNAME;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Intent intent=getIntent();
// ID=intent.getStringExtra("ID");
// new HttpGetTask().execute();
logout = (Button) findViewById(R.id.buttonLogout);
nameTv = (TextView) findViewById(R.id.nameTextView);
ageTv = (TextView) findViewById(R.id.ageTextView);
emailTv = (TextView) findViewById(R.id.emailTextView);
usernameTv = (TextView) findViewById(R.id.UsernameTextView);
nameTv.setText(NAME);
ageTv.setText(AGE);
emailTv.setText(EMAIL);
usernameTv.setText(USERNAME);
new HttpRequestTask().execute();
logout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent logoutintent = new Intent(Result.this, MainActivity.class);
startActivity(logoutintent);
}
});
}
private class HttpRequestTask extends AsyncTask<Void, Void, Login> {
#Override
protected Login doInBackground(Void... params) {
try {
// final String url = "http://192.168.1.213:9001/consumer/local/64";
RestTemplate restTemplate = new RestTemplate();
Login lg = restTemplate.getForObject(url, Login.class);
// NAME=lg.getName().toString();
Log.d("", "doInBackground:++++++++++++++++++++++ "+NAME);
return lg;
} catch (Exception e) {
Log.e("MainActivity", e.getMessage(), e);
}
return null;
}
This Below Code is for POST Request.
public class Register extends AppCompatActivity {
Button buttonRegister;
public String ID;
TextView editId,editName,editAge,editEmail,editUsername,editPassword;
private String Name,Age,Email,Username,Password;
Login login=new Login();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
editId=(TextView)findViewById(R.id.editId);
editName=(TextView)findViewById(R.id.editName);
editAge=(TextView)findViewById(R.id.editAge);
editEmail=(TextView)findViewById(R.id.editEmail);
editUsername=(TextView)findViewById(R.id.editUsername);
editPassword=(TextView)findViewById(R.id.editPassword);
buttonRegister = (Button)findViewById(R.id.buttonRegister);
buttonRegister.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(Register.this, "Registration Successful", Toast.LENGTH_SHORT).show();
Name = editName.getText().toString();
Age = editAge.getText().toString();
Email = editEmail.getText().toString();
Username = editUsername.getText().toString();
Password = editPassword.getText().toString();
Log.d("???????????", "onClick:------------> " + Name);
Log.d("???????????", "onClick:------------> " + ID);
Log.d("???????????", "onClick:------------> " + Age);
Log.d("???????????", "onClick:------------> " + Email);
Log.d("???????????", "onClick:------------> " + Username);
Log.d("???????????", "onClick:------------> " + Password);
new HttpPostTask().execute();
Intent regintent = new Intent(Register.this, Result.class);
//regintent.putExtra("ID",1);
startActivity(regintent);
/*Intent regintent = new Intent(Register.this, Result.class);
startActivity(regintent);*/
}
});
}
public class HttpPostTask extends AsyncTask<Void,Void,Login>{
#Override
protected Login doInBackground(Void... params) {
final String url = "http://192.168.1.189:9001/login";
RestTemplate restTemplate = new RestTemplate();
Login login = new Login();
login.setName(Name);
login.setAge(Age);
login.setEMail(Email);
login.setUserName(Username);
login.getId();
login.setPassword(Password);
Log.d("???????????", "onClick:!!!!!!!!!!!!!!> " + Name);
login = restTemplate.postForObject(url, login, Login.class);
ID=login.getId();
Log.d("???????????", "onClick:!!!!!!!!!!!!!!> " + login.getId());
return login;
}
#Override
protected void onPostExecute(Login login){
super.onPostExecute(login);
}
}
}
I have been searching for this problem since last two days.
Any help appreciated Thanks In advance...........
Restarting my System Solve My Problem