OnVideoChatChangeState() usage in Quickblox - android

I am using quickblox api for 1 to 1 videochat but I dont know the usage OnVideoChatChangeState() of OnQBVideoChatListener() class and with what changes the event is invoked. I have modified the code but the video doesnt start the click functions but doesn't go to:
` public void onVideoChatStateChange(CallState state, VideoChatConfig receivedVideoChatConfig) {
videoChatConfig = receivedVideoChatConfig;
isCanceledVideoCall = false;
Toast.makeText(getApplicationContext(), "switch", Toast.LENGTH_LONG).show();
switch (state)
{
case ON_CALLING:
Toast.makeText(getApplicationContext(), "After this the showCallDialog() will be called.", Toast.LENGTH_LONG).show();
showCallDialog();
break;
case ON_ACCEPT_BY_USER:
progressDialog.dismiss();
startVideoChatActivity();
break;
case ON_REJECTED_BY_USER:
progressDialog.dismiss();
break;
case ON_DID_NOT_ANSWERED:
progressDialog.dismiss();
break;
case ON_CANCELED_CALL:
isCanceledVideoCall = true;
videoChatConfig = null;
break;
case ON_START_CONNECTING:
progressDialog.dismiss();
startVideoChatActivity();
break;
default:
break;
}
}
};
`
and the showCallDialog(); method is not called this shows the events doesn't occur here.
So I want to know can the event occurs so that the methods are called.

This has been fixed. Master branch is updated. Please try download and use the sample once again.

Related

How to create Fingerprint Lock using switch to enable/disable the Lock

I want to integrate fingerprint lock into my application. The user has a choice to enable/disable the lock using switch. How can I achieve it programmatically.
For Example something like this:
Choice to enable/disable the lock inside the application
When user opens the application
So I have implemented this type of feature in my app but I don't know whether its a viable feature you may find an easy and sensible method but this is what I do
I use shared preferences for this so first in the activity where https://i.stack.imgur.com/3FY78.jpg exist I do like below
First I create this method
private void Biometric(){
androidx.biometric.BiometricManager biometricManager = androidx.biometric.BiometricManager.from(this);
switch (biometricManager.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK | BiometricManager.Authenticators.DEVICE_CREDENTIAL)) {
// this means we can use biometric sensor
case androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS:
SharedPreferences sharedPreferences = getSharedPreferences("Authentication",0);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(TEXT, "1");
editor.putBoolean(SWITCH1, Swicth_authenticate.isChecked());
editor.apply();
Intent intent = new Intent(AboutActivity.this, edit_profile.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
break;
// this means that the device doesn't have fingerprint sensor
case androidx.biometric.BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
Swicth_authenticate.setChecked(false);
Toast.makeText(this, "Error code 0x08080101 Authentication failed there's no Fingerprint Reader in your device.", Toast.LENGTH_SHORT).show();
break;
// this means that biometric sensor is not available
case androidx.biometric.BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
Swicth_authenticate.setChecked(false);
Toast.makeText(this, "Error code 0x08080102 Authentication failed biometric system not found.", Toast.LENGTH_SHORT).show();
break;
// this means that the device doesn't contain your fingerprint
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
Swicth_authenticate.setChecked(false);
Toast.makeText(this, "Error code 0x08080103 There's no password for this device.", Toast.LENGTH_SHORT).show();
break;
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
break;
case BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED:
break;
case BiometricManager.BIOMETRIC_STATUS_UNKNOWN:
break;
}
}
And Activate the above method whenever a user turns on the checkbox
And if user Deactivates I run the following in a method
SharedPreferences sharedPreferences = getSharedPreferences("Authentication",0);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(TEXT, "0");
editor.putBoolean(SWITCH1, Swicth_authenticate.isChecked());
editor.apply();
As you can see I have used Shared Preferences in that method and in my launcher activity I do the following thing.
SharedPreferences sharedPreferences = getSharedPreferences("Authentication", 0);
String bio = sharedPreferences.getString(TEXT, "");
if (bio.equals("1")) {
BiometricManager biometricManager = androidx.biometric.BiometricManager.from(this);
switch (biometricManager.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK | DEVICE_CREDENTIAL)) {
// this means we can use biometric sensor
case BiometricManager.BIOMETRIC_SUCCESS:
break;
// this means that the device doesn't have fingerprint sensor
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
break;
// this means that biometric sensor is not available
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
break;
// this means that the device doesn't contain your fingerprint
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
break;
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
break;
case BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED:
break;
case BiometricManager.BIOMETRIC_STATUS_UNKNOWN:
break;
}
// creating a variable for our Executor
Executor executor = ContextCompat.getMainExecutor(this);
// this will give us result of AUTHENTICATION
final BiometricPrompt biometricPrompt = new BiometricPrompt(StartActivity.this, executor, new BiometricPrompt.AuthenticationCallback() {
#Override
public void onAuthenticationError(int errorCode, #NonNull CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
}
// THIS METHOD IS CALLED WHEN AUTHENTICATION IS SUCCESS
#Override
public void onAuthenticationSucceeded(#NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
Toast.makeText(getApplicationContext(), "Login Success.", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(StartActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
#Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
}
});
// creating a variable for our promptInfo
// BIOMETRIC DIALOG
final BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder().setTitle("Authentication")
.setDescription("Use your fingerprint to login ")
.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_WEAK | DEVICE_CREDENTIAL).build();
biometricPrompt.authenticate(promptInfo);
} else {
Intent intent = new Intent(StartActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
If you have any doubt regarding this comment below I know its very huge but I don't know how much you know so I pretty much wrote whole code even then if you have doubt you can see the following source code https://github.com/MohammedAbidNafi/MessengerByMargs

How to execute two if conditions in android

I want to execute two if conditions either first if condition or second if condition based on my requirement.
Now below code if it executing second if condition everytime
switch (specilaity_name) {
case "Cardiac":
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_theme);
speclialistimage.setImageResource(R.drawable.ic_heart);
specialization.setTextColor(Color.WHITE);
break;
case "Urology":
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_theme);
speclialistimage.setImageResource(R.drawable.ic_urology__1___1_);
specialization.setTextColor(Color.WHITE);
break;
case "Gynaecology":
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_theme);
speclialistimage.setImageResource(R.drawable.ic_group_2105);
specialization.setTextColor(Color.WHITE);
break;
}
Well. You're using nested if else in the else part of outer if for each block of code.
If only code in second structure is working, then that's the only condition which holds true during execution of your App.
if(specilaity_name.equalsIgnoreCase("Cardiac")){
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_theme);
speclialistimage.setImageResource(R.drawable.ic_heart);
specialization.setTextColor(Color.WHITE);
}else if(specilaity_name.equalsIgnoreCase("Urology")) {
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_white);
speclialistimage.setImageResource(R.drawable.ic_urology__1_);
specialization.setTextColor(Color.rgb(73,179,206));
}else {
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_white);
speclialistimage.setImageResource(R.drawable.ic_group_2105);
specialization.setTextColor(Color.rgb(73, 179, 206));
}
String specialityName = specilaity_name.toUpperCase();
switch (specialityName) {
case "CARDIAC":
linearspeclist.setBackgroundResource(R.drawable.rectangle_border_theme);
speclialistimage.setImageResource(R.drawable.ic_heart);
specialization.setTextColor(Color.WHITE);
break;
case "UROLOGY":
// add code for urology
break;
case "GYNAECOLOGY":
// add code for Gynaecology
break;
default:
break;
}
}

isGestureDetectionAvailable() always returns 'FALSE' on android 28

I have built an app which lets the user control their scrolling action using the fingerprint sensor.
It used to work earlier until some weeks back, where I found that method: isGestureDetectionAvailable() always returns 'False' after starting 'accessibility service'
Since I am getting 'isGestureDetectionAvailable()' as always 'False',
my 'registerFingerprintGestureCallback' doesn't work and hence all my functionality of swiping gestures.
Can Someone please help and point out what I am doing wrong.
Here is my code.
protected void onServiceConnected() {
super.onServiceConnected();
FingerprintGestureController gestureController = getFingerprintGestureController();
Log.e(TAG, "Is available: " + gestureController.isGestureDetectionAvailable());
FingerprintGestureController.FingerprintGestureCallback callback = new
FingerprintGestureController.FingerprintGestureCallback() {
public void onGestureDetectionAvailabilityChanged(boolean available) {
super.onGestureDetectionAvailabilityChanged(available);
Log.d(TAG, "onGestureDetectionAvailabilityChanged " + available);
}
public void onGestureDetected(int gesture) {
switch (gesture) {
case FINGERPRINT_GESTURE_SWIPE_UP:
scrollDown();
break;
case FINGERPRINT_GESTURE_SWIPE_DOWN:
scrollUp();
break;
case FINGERPRINT_GESTURE_SWIPE_RIGHT:
execute_swipe_right_functionality();
break;
case FINGERPRINT_GESTURE_SWIPE_LEFT:
execute_swipe_left_functionality();
break;
default:
Log.e("My Service",
"Error: Unknown gesture type detected!");
break;
}
}
};
gestureController.registerFingerprintGestureCallback(callback, new Handler());
}

Android Firebase Phone Auth crashed when clicked button of empty edittext

With no problem, connected my app to firebase and I can test realtime database and other features, but when it comes to Phone Authentication, I am having problems. The problem is when Edittext is left empty and Button is clicked the app gets crashed. Don't know which code should be responsible for this problem.
Please help me to define it.
If you have carefully read the documentation of phone auth in firebase you will have below code:
private boolean validatePhoneNumber() {
String phoneNumber = mPhoneNumberField.getText().toString();
if (TextUtils.isEmpty(phoneNumber)) {
mPhoneNumberField.setError("Invalid phone number.");
return false;
}
return true;
Then either with if-else or switch-case
You should call this method
NOTE: onCLick method comes after btn.setOnClickListener depending upon your button id.
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button_start_verification:
if (!validatePhoneNumber()) {
return;
}
startPhoneNumberVerification(mPhoneNumberField.getText().toString());
break;
case R.id.button_verify_phone:
String code = mVerificationField.getText().toString();
if (TextUtils.isEmpty(code)) {
mVerificationField.setError("Cannot be empty.");
return;
}
verifyPhoneNumberWithCode(mVerificationId, code);
break;
case R.id.button_resend:
resendVerificationCode(mPhoneNumberField.getText().toString(), mResendToken);
break;
case R.id.sign_out_button:
signOut();
break;
}
}
Due to the codes which were not provided by you, I have written some references based on my own app. Please consider changing those and probably you wont get further crashes.

Swichcase not working in android?

I am stuck in swich case. Please check code below
Log.e("##################### pos",""+posSel_lay);
String ff=Integer.toString(posSel_lay);
//var ffs=Integer.toString(posSel_lay);
Log.e("##################### pos",""+ff);
if(ff.equals("0")){
Log.e("###################Lagan","");
}else if(ff.equals("1")){
Log.e("###################MBBS","");
}else if(ff.equals("2")){
Log.e("###################JODHA","");
}else if(ff.equals("3")){
Log.e("###################ZINDAGI","");
}
I got log only this line
##################### pos 2
& its not going in swich case why i dont know, can you help me please?
All the answers are good.
but you should at least put any message into message param of Log. otherwise you will not able to see this in logs
Log.e("###################ZINDAGI","some message.");
By default a switch case works WITH integers, why don't you try something like the following:
Log.e("##################### pos",""+posSel_lay);
switch (posSel_lay){
case 0:
Log.e("###################Lagan","");
break;
case 1:
Log.e("###################MBBS","");
break;
case 2:
Log.e("###################JODHA","");
break;
case 3:
Log.e("###################ZINDAGI","");
break;
default:
break;
}
Now instead of converting to a string, and using an if-else chain, you use a select statement, which IMO is much cleaner.
Log.e("##################### pos", "" + posSel_lay );
switch( posSel_lay ) {
case 0:
Log.e("###################Lagan","");
break;
case 1:
Log.e("###################MBBS","");
break;
case 2:
Log.e("###################JODHA","");
break;
case 3:
Log.e("###################ZINDAGI","");
break;
}
I can't really understand your question , but here is SwitchCase
switch(posSel_lay){
case 0:
Log.e("###################Lagan","");
break;
case 1:
Log.e("###################MBBS","");
break;
case 2:
Log.e("###################JODHA","");
break;
case 3:
Log.e("###################ZINDAGI","");
break;
}
I found solution. I get this posSel_lay from bundle which is passed by other activity.Previously i written switch code in on button click so now i changed flow,
When i am getting value of posSel_lay from bundle that time only i written code of switch
& there i am making some boolean values true or false which is declared locally. And when user
clicks on button that time i used boolean variables for checking. Then its done.
Thanks for your reply.

Categories

Resources