I'm trying to create an app if someone want to use my app they must create a user.
When they register they will insert first name, last name, phone and email address.
After I confirm that the phone is theirs by using Firebase authorization I want to insert his data to a table named Users in my RealTime Database.
When I tried to do it by using this function:
**EDIT: I added the onComplete function but it doesn't execute **
private void storeNewUserData() {
FirebaseDatabase rootNode = FirebaseDatabase.getInstance();
DatabaseReference reference = rootNode.getReference("Users");
User user = new User(phone,firstName,lastName,email);
reference.setValue(user).addOnCompleteListener(this);
}
#Override
public void onComplete(#NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(this, "Inserted User: "+phone+firstName+lastName+email, Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(this, task.getException().toString(), Toast.LENGTH_SHORT).show();
}
}
The database has not been updated but the Toast appeared (with all the data).
I don't think there is a problem in my code maybe it's a problem in my Firebase account.. Anyway I add the rules to this database and an image of the table.
Rules
{
"rules": {
".read": "true",
".write": "true"
}
}
build.gradle(app)
dependencies {
implementation platform('com.google.firebase:firebase-bom:26.8.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.firebase:firebase-database:19.7.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.browser:browser:1.3.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
}
';
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
#Override
public void onSuccess(AuthResult authResult) {
progressDialog.dismiss();
User user = new User(phone,firstName,lastName,email);
storeNewUserData();
Toast.makeText(PhoneAuthActivity.this, "Logged in as "+phone, Toast.LENGTH_SHORT).show();
startActivity(new Intent(PhoneAuthActivity.this, MainActivity.class));
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(PhoneAuthActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
logcat
2021-03-30 03:41:02.326 15207-15345/com.example.teorialearning E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with INVALID_CERT_HASH 400
2021-03-30 03:41:02.344 15207-15257/com.example.teorialearning V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 396
2021-03-30 03:41:02.345 15207-15257/com.example.teorialearning V/FA: Activity paused, time: 15824705
2021-03-30 03:41:02.389 15207-15207/com.example.teorialearning E/zzf: Failed to get reCAPTCHA token with error [There was an error while trying to get your package certificate hash.]- calling backend without app verification
2021-03-30 03:41:02.391 15207-15257/com.example.teorialearning V/FA: Activity resumed, time: 15824751
2021-03-30 03:41:02.395 15207-15245/com.example.teorialearning W/System: Ignoring header X-Firebase-Locale because its value was null.
2021-03-30 03:41:02.641 15207-15207/com.example.teorialearning D/MAIN_TAG: onCodeSent:ALiwoWIdFZrl9ResXiUM94aPJW-csmRjdDOqoa9DTOkNQbv2Vf8YN7X6mvBwXgg9MJxEnFUVoE2rWAP2JzpT8QdBcRK2kIi82e_uO3pXW_rC5CZqWgJaqYqPO6nMOxiavmaJELnkSRtTXo6HoYoEY2_CmtVplEbz2Q
2021-03-30 03:41:02.644 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:02.677 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:02.739 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:04.679 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:04.789 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:07.416 15207-15257/com.example.teorialearning V/FA: Inactivity, disconnecting from the service
2021-03-30 03:41:08.627 15207-15245/com.example.teorialearning W/System: Ignoring header X-Firebase-Locale because its value was null.
2021-03-30 03:41:08.668 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:08.685 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:08.691 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:08.696 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:08.755 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:08.936 15207-15245/com.example.teorialearning W/System: Ignoring header X-Firebase-Locale because its value was null.
2021-03-30 03:41:09.147 15207-15245/com.example.teorialearning D/FirebaseAuth: Notifying id token listeners about user ( QgYB9guxYgT2AQbr8u9CVrGnELw2 ).
2021-03-30 03:41:09.149 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:09.178 15207-15257/com.example.teorialearning V/FA: Recording user engagement, ms: 6787
2021-03-30 03:41:09.180 15207-15257/com.example.teorialearning V/FA: Connecting to remote service
2021-03-30 03:41:09.181 15207-15257/com.example.teorialearning V/FA: Activity paused, time: 15831539
2021-03-30 03:41:09.189 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:09.193 15207-15257/com.example.teorialearning V/FA: Connection attempt already in progress
2021-03-30 03:41:09.212 15207-15225/com.example.teorialearning V/FA: onActivityCreated
2021-03-30 03:41:09.229 15207-15257/com.example.teorialearning V/FA: Activity resumed, time: 15831590
2021-03-30 03:41:09.233 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:09.243 15207-15257/com.example.teorialearning V/FA: Connection attempt already in progress
2021-03-30 03:41:09.244 15207-15257/com.example.teorialearning V/FA: Connection attempt already in progress
2021-03-30 03:41:09.295 15207-15257/com.example.teorialearning D/FA: Connected to remote service
2021-03-30 03:41:09.296 15207-15257/com.example.teorialearning V/FA: Processing queued up service tasks: 4
2021-03-30 03:41:09.298 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:09.329 15207-15207/com.example.teorialearning W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
2021-03-30 03:41:09.330 15207-15207/com.example.teorialearning W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
2021-03-30 03:41:11.206 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:13.170 15207-15333/com.example.teorialearning D/EGL_emulation: eglMakeCurrent: 0xae4856c0: ver 3 1 (tinfo 0xae483990)
2021-03-30 03:41:14.310 15207-15257/com.example.teorialearning V/FA: Inactivity, disconnecting from the service
2021-03-30 03:42:02.393 15207-15348/com.example.teorialearning W/FirebaseAuth: [SmsRetrieverHelper] Timed out waiting for SMS.
P.S: I'm using Android studio
I could resolve this issue by changing my device's internet connection network. The app won't work on mobile data, but it worked on the WIFI of some other device.
The reason behind the problem isn't clear yet.
Reference answer -> https://stackoverflow.com/a/51122769/13546426
Related
Unable to fetch a value from the Firestore database. Trying to retrieve the value of the mobile number as and when the value of flat and block matches the entry in the database. Below is the code I am using. I have also attached the issues that are registered in LogCat file. Please check and help.
public class Test extends AppCompatActivity {
Button btn;
private FirebaseFirestore firestore;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
firestore = FirebaseFirestore.getInstance();
btn = (Button) findViewById(R.id.button3);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
getmobile();
//makecall();
}
});
}
private void makecall(){
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
intent.setData(Uri.parse("tel:9890910640"));
startActivity(intent);
}
private void getmobile() {
firestore.collection("users").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
#Override
public void onSuccess(QuerySnapshot documentSnapshots) {
String a = "101";
String b = "F1A";
for(DocumentSnapshot document: documentSnapshots){
if(document.getString("flat")==a&&document.getString("block")==b){
String mobilefromdatabase = document.get("mobile").toString();
Toast.makeText(Test.this, "mobile" + mobilefromdatabase, Toast.LENGTH_LONG).show();
break;
}
}
}
});
}
}
Logcat Details
05-05 03:59:26.721 8805-8805/? E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
05-05 03:59:26.721 8805-8805/? W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
05-05 03:59:26.722 8805-8805/? I/art: Not late-enabling -Xcheck:jni (already on)
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: VM with version 2.1.0 has multidex support
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: Installing application
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: VM has multidex support, MultiDex support library is disabled.
05-05 03:59:26.842 8805-8805/com.example.myrwaapp V/FA: Registered activity lifecycle callback
05-05 03:59:26.857 8805-8831/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-05 03:59:26.861 8805-8805/com.example.myrwaapp I/FirebaseInitProvider: FirebaseApp initialization successful
05-05 03:59:26.907 8805-8834/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-05 03:59:26.925 8805-8834/com.example.myrwaapp I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
05-05 03:59:26.986 8805-8805/com.example.myrwaapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-05 03:59:27.010 8805-8805/com.example.myrwaapp V/FA: onActivityCreated
05-05 03:59:27.047 8805-8805/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-05 03:59:27.047 8805-8805/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-05 03:59:27.048 8805-8830/com.example.myrwaapp V/FA: App measurement collection enabled
05-05 03:59:27.049 8805-8830/com.example.myrwaapp V/FA: App measurement enabled for app package, google app id: com.example.myrwaapp, 1:649640616763:android:9025242f82dd4767798d1e
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: App measurement initialized, version: 21028
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.myrwaapp
05-05 03:59:27.052 8805-8830/com.example.myrwaapp D/FA: Debug-level message logging enabled
05-05 03:59:27.077 8805-8830/com.example.myrwaapp V/FA: Connecting to remote service
05-05 03:59:27.089 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.143 8805-8830/com.example.myrwaapp V/FA: Activity resumed, time: 8622127
05-05 03:59:27.145 8805-8830/com.example.myrwaapp I/FA: Tag Manager is not found and thus will not be used
05-05 03:59:27.151 8805-8838/com.example.myrwaapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-05 03:59:27.154 8805-8805/com.example.myrwaapp D/Atlas: Validating map...
05-05 03:59:27.159 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.159 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.188 8805-8838/com.example.myrwaapp I/OpenGLRenderer: Initialized EGL, version 1.4
05-05 03:59:27.188 8805-8838/com.example.myrwaapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
05-05 03:59:27.215 8805-8838/com.example.myrwaapp D/EGL_emulation: eglCreateContext: 0xa2003100: maj 2 min 0 rcv 2
05-05 03:59:27.240 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:27.243 8805-8838/com.example.myrwaapp D/OpenGLRenderer: Enabling debug mode 0
05-05 03:59:27.294 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:27.738 8805-8830/com.example.myrwaapp D/FA: Connected to remote service
05-05 03:59:27.738 8805-8830/com.example.myrwaapp V/FA: Processing queued up service tasks: 4
05-05 03:59:32.795 8805-8830/com.example.myrwaapp V/FA: Inactivity, disconnecting from the service
05-05 03:59:38.884 8805-8830/com.example.myrwaapp V/FA: Recording user engagement, ms: 11740
05-05 03:59:38.886 8805-8830/com.example.myrwaapp V/FA: Connecting to remote service
05-05 03:59:38.892 8805-8830/com.example.myrwaapp V/FA: Activity paused, time: 8633867
05-05 03:59:38.894 8805-8805/com.example.myrwaapp V/FA: onActivityCreated
05-05 03:59:38.913 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.913 8805-8830/com.example.myrwaapp V/FA: Activity resumed, time: 8633895
05-05 03:59:38.926 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.926 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.993 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.034 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.051 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.177 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.222 8805-8830/com.example.myrwaapp D/FA: Connected to remote service
05-05 03:59:39.222 8805-8830/com.example.myrwaapp V/FA: Processing queued up service tasks: 4
05-05 03:59:39.224 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.335 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:44.247 8805-8830/com.example.myrwaapp V/FA: Inactivity, disconnecting from the service
05-05 03:59:48.704 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:48.871 8805-8849/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for providerinstaller not found.
05-05 03:59:48.877 8805-8849/com.example.myrwaapp I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
05-05 03:59:48.877 8805-8849/com.example.myrwaapp W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
05-05 03:59:48.881 8805-8849/com.example.myrwaapp W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
05-05 03:59:48.881 8805-8849/com.example.myrwaapp W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
05-05 03:59:48.942 8805-8849/com.example.myrwaapp W/linker: libconscrypt_gmscore_jni.so: unused DT entry: type 0x6ffffffe arg 0x13dc
05-05 03:59:48.942 8805-8849/com.example.myrwaapp W/linker: libconscrypt_gmscore_jni.so: unused DT entry: type 0x6fffffff arg 0x2
05-05 03:59:48.948 8805-8849/com.example.myrwaapp V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
05-05 03:59:48.963 8805-8820/com.example.myrwaapp I/art: Background sticky concurrent mark sweep GC freed 976(49KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 8MB/8MB, paused 5.861ms total 31.265ms
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
05-05 03:59:49.002 8805-8849/com.example.myrwaapp I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
First of all, String comparison in Java, should not be performed using == operator, as it will always compare the address of the objects from the memory and not the actual values. String comparison should be done using equals() method.
Moreover, if you need an AND operation, you should not get all documents that exist within the users collection and make the comparison on the client. For that, you should use a query that looks exactly like this:
String a = "101";
String b = "F1A";
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference usersRef = rootRef.collection("users");
Query query = usersRef.whereEqualTo("flat", a).whereEqualTo("block", b);
query.get().addOnSuccessListener(/* ... */);
In this way, you are going to get only the documents where the flat property holds the value of 101 AND the value of block holds F1A. As I think that only one apartment has that constraint, you'll be billed with only one read operation.
I am unable to write any data to my firebase database, however it is connected. My rules of both read and write are set to true, and I added the required SDK's but I still cannot add data.
Button RegisterBttn;
EditText userEmail, userPassword, userName;
//Firebase setup
FirebaseDatabase mydatabase;
DatabaseReference users;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_page);
RegisterBttn = (Button) findViewById(R.id.registerBttn);
//Firebase
mydatabase = FirebaseDatabase.getInstance();
users = mydatabase.getReference("Users");
userEmail = (EditText) findViewById(R.id.emailRegisterText);
userPassword = (EditText) findViewById(R.id.passwordRegisterText);
userName = (EditText) findViewById(R.id.nameRegisterText);
RegisterBttn.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v){
final User user = new User(userName.getText().toString(),
userPassword.getText().toString(),
userEmail.getText().toString());
users.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.child(user.getUserName()).exists()) {
Toast.makeText(RegisterPage.this, "The Username already exists", Toast.LENGTH_SHORT).show();
}
else{
users.child(user.getUserName()).setValue(user);
// Log.i("Info", "Button Pressed");
Toast.makeText(RegisterPage.this, "Registered successfully", Toast.LENGTH_SHORT).show();
}
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
// Toast.makeText(RegisterPage.this, "Error registering", Toast.LENGTH_SHORT).show();
}
});
}
});
}
}
I have a seperate class for "User", containing username, pass and email.
I am using Realtime DB. The rules are:
{
"rules": {
".read": true,
".write": true
}
}
Here is the Logcat:
2020-04-11 23:30:54.483 25114-25114/? I/xample.fitnote: Not late-enabling -Xcheck:jni (already on)
2020-04-11 23:30:54.563 25114-25114/? E/xample.fitnote: Unknown bits set in runtime_flags: 0x8000
2020-04-11 23:30:54.571 25114-25114/? W/xample.fitnote: Unexpected CPU variant for X86 using defaults: x86
2020-04-11 23:30:55.411 25114-25114/com.example.fitnotes V/FA: Registered activity lifecycle callback
2020-04-11 23:30:55.412 25114-25114/com.example.fitnotes I/FirebaseInitProvider: FirebaseApp initialization successful
2020-04-11 23:30:55.440 25114-25114/com.example.fitnotes W/RenderThread: type=1400 audit(0.0:124): avc: denied { write } for name="property_service" dev="tmpfs" ino=620 scontext=u:r:untrusted_app:s0:c134,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
2020-04-11 23:30:55.456 25114-25156/com.example.fitnotes D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2020-04-11 23:30:55.456 25114-25156/com.example.fitnotes W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2020-04-11 23:30:55.669 25114-25156/com.example.fitnotes D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2020-04-11 23:30:55.694 25114-25156/com.example.fitnotes D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2020-04-11 23:30:55.696 25114-25156/com.example.fitnotes D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2020-04-11 23:30:55.700 25114-25114/com.example.fitnotes V/FA: onActivityCreated
2020-04-11 23:30:55.806 25114-25114/com.example.fitnotes W/xample.fitnote: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2020-04-11 23:30:55.806 25114-25114/com.example.fitnotes W/xample.fitnote: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2020-04-11 23:30:55.945 25114-25167/com.example.fitnotes D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-04-11 23:30:56.021 25114-25153/com.example.fitnotes W/xample.fitnote: Verification of java.lang.Long com.google.android.gms.measurement.internal.zzap.zzbz() took 116.979ms
2020-04-11 23:30:56.201 25114-25154/com.example.fitnotes D/HostConnection: HostConnection::get() New Host Connection established 0xdbf3f320, tid 25154
2020-04-11 23:30:56.209 25114-25154/com.example.fitnotes D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
2020-04-11 23:30:56.225 25114-25154/com.example.fitnotes W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2020-04-11 23:30:56.227 25114-25154/com.example.fitnotes D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2020-04-11 23:30:56.227 25114-25154/com.example.fitnotes D/EGL_emulation: eglCreateContext: 0xdbf1a120: maj 3 min 0 rcv 3
2020-04-11 23:30:56.229 25114-25154/com.example.fitnotes D/EGL_emulation: eglMakeCurrent: 0xdbf1a120: ver 3 0 (tinfo 0xdbf0f1a0)
2020-04-11 23:30:56.253 25114-25154/com.example.fitnotes W/Gralloc3: mapper 3.x is not supported
2020-04-11 23:30:56.266 25114-25154/com.example.fitnotes D/HostConnection: createUnique: call
2020-04-11 23:30:56.267 25114-25154/com.example.fitnotes D/HostConnection: HostConnection::get() New Host Connection established 0xdbf3f460, tid 25154
2020-04-11 23:30:56.267 25114-25154/com.example.fitnotes D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
2020-04-11 23:30:56.268 25114-25154/com.example.fitnotes D/eglCodecCommon: allocate: Ask for block of size 0x1000
2020-04-11 23:30:56.268 25114-25154/com.example.fitnotes D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000
2020-04-11 23:30:56.294 25114-25154/com.example.fitnotes D/EGL_emulation: eglMakeCurrent: 0xdbf1a120: ver 3 0 (tinfo 0xdbf0f1a0)
2020-04-11 23:30:56.313 25114-25153/com.example.fitnotes V/FA: App measurement collection enabled
2020-04-11 23:30:56.314 25114-25153/com.example.fitnotes V/FA: App measurement enabled for app package, google app id: com.example.fitnotes, 1:247538218926:android:4af44b308740275bc97a3f
2020-04-11 23:30:56.323 25114-25153/com.example.fitnotes I/FA: App measurement initialized, version: 21028
2020-04-11 23:30:56.323 25114-25153/com.example.fitnotes I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-04-11 23:30:56.324 25114-25153/com.example.fitnotes I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.fitnotes
2020-04-11 23:30:56.324 25114-25153/com.example.fitnotes D/FA: Debug-level message logging enabled
2020-04-11 23:30:56.328 25114-25154/com.example.fitnotes D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
2020-04-11 23:30:56.675 25114-25125/com.example.fitnotes I/xample.fitnote: Background concurrent copying GC freed 12091(2542KB) AllocSpace objects, 9(244KB) LOS objects, 49% free, 1893KB/3787KB, paused 11.909ms total 108.785ms
2020-04-11 23:30:56.824 25114-25153/com.example.fitnotes V/FA: Connecting to remote service
2020-04-11 23:30:56.864 25114-25153/com.example.fitnotes V/FA: Connection attempt already in progress
2020-04-11 23:30:56.868 25114-25153/com.example.fitnotes V/FA: Activity resumed, time: 23076629
2020-04-11 23:30:56.881 25114-25153/com.example.fitnotes I/FA: Tag Manager is not found and thus will not be used
2020-04-11 23:30:56.919 25114-25153/com.example.fitnotes V/FA: Connection attempt already in progress
2020-04-11 23:30:56.920 25114-25153/com.example.fitnotes V/FA: Connection attempt already in progress
2020-04-11 23:30:56.920 25114-25153/com.example.fitnotes D/FA: Connected to remote service
2020-04-11 23:30:56.921 25114-25153/com.example.fitnotes V/FA: Processing queued up service tasks: 4
2020-04-11 23:31:00.791 25114-25114/com.example.fitnotes W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy#1e91d36
2020-04-11 23:31:00.799 25114-25153/com.example.fitnotes V/FA: Recording user engagement, ms: 4674
2020-04-11 23:31:00.815 25114-25114/com.example.fitnotes V/FA: onActivityCreated
2020-04-11 23:31:00.928 25114-25153/com.example.fitnotes V/FA: Activity paused, time: 23081303
2020-04-11 23:31:01.142 25114-25154/com.example.fitnotes D/EGL_emulation: eglMakeCurrent: 0xdbf1a120: ver 3 0 (tinfo 0xdbf0f1a0)
2020-04-11 23:31:01.170 25114-25154/com.example.fitnotes D/EGL_emulation: eglMakeCurrent: 0xdbf1a120: ver 3 0 (tinfo 0xdbf0f1a0)
2020-04-11 23:31:01.209 25114-25154/com.example.fitnotes D/EGL_emulation: eglMakeCurrent: 0xdbf1a120: ver 3 0 (tinfo 0xdbf0f1a0)
2020-04-11 23:31:01.271 25114-25153/com.example.fitnotes V/FA: Activity resumed, time: 23081552
2020-04-11 23:31:03.148 25114-25114/com.example.fitnotes I/AssistStructure: Flattened final assist data: 3084 bytes, containing 1 windows, 18 views
2020-04-11 23:31:06.509 25114-25153/com.example.fitnotes V/FA: Inactivity, disconnecting from the service
2020-04-11 23:31:10.941 25114-25114/com.example.fitnotes I/AssistStructure: Flattened final assist data: 3132 bytes, containing 1 windows, 18 views
2020-04-11 23:31:14.486 25114-25114/com.example.fitnotes I/Info: Button Pressed
2020-04-11 23:31:14.486 25114-25114/com.example.fitnotes I/Info: uu
I have a phonegap hybrid app with Facebook connect plugin. First time when I login then the FB login works but after I logout and then again try to login via Facebook then the app crashes with the following Logcat results :
Plugin URL :
https://github.com/jeduan/cordova-plugin-facebook4
06-18 21:31:50.071 3129-3219/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9b2370a0
06-18 21:31:50.096 3129-3129/? I/Choreographer: Skipped 39 frames! The application may be doing too much work on its main thread.
06-18 21:31:50.104 3129-3234/? D/EGL_emulation: eglMakeCurrent: 0x9e677300: ver 2 0 (tinfo 0xaa366e80)
06-18 21:31:50.356 3129-3129/? D/CordovaActivity: Incoming Result. Request code = 64206
06-18 21:31:50.356 3129-3129/? D/CordovaInterfaceImpl: Sending activity result to plugin
06-18 21:31:50.356 3129-3129/? D/ConnectPlugin: activity result in plugin: requestCode(64206), resultCode(-1)
06-18 21:31:50.372 3129-3129/? D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
06-18 21:31:50.372 3129-3129/? D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
06-18 21:31:50.378 3129-3129/? D/CordovaActivity: Resumed the activity.
06-18 21:31:50.379 3129-3129/? W/com.facebook.appevents.AppEventsLogger: activateApp events are being logged automatically. There's no need to call activateApp explicitly, this is safe to remove.
06-18 21:31:50.551 3129-3219/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x98eed520
06-18 21:31:51.043 3129-3129/? D/AndroidRuntime: Shutting down VM
--------- beginning of crash
06-18 21:31:51.044 3129-3129/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sqlchild.app1, PID: 3129
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.indexOf(int)' on a null object reference
at libcore.net.UriCodec.decode(UriCodec.java:153)
at java.net.URLDecoder.decode(URLDecoder.java:60)
at org.apache.cordova.facebook.ConnectPlugin.makeGraphCall(ConnectPlugin.java:751)
at org.apache.cordova.facebook.ConnectPlugin.access$200(ConnectPlugin.java:55)
at org.apache.cordova.facebook.ConnectPlugin$2$1.onCompleted(ConnectPlugin.java:111)
at com.facebook.GraphRequest$1.onCompleted(GraphRequest.java:301)
at com.facebook.GraphRequest$5.run(GraphRequest.java:1380)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-18 21:31:51.052 1667-2063/? W/ActivityManager: Force finishing activity com.sqlchild.app1/.MainActivity
06-18 21:31:51.067 1259-1321/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 589824
[ 06-18 21:31:51.097 1667: 2063 D/ ]
HostConnection::get() New Host Connection established 0x9aa0cc00, tid 2063
[ 06-18 21:31:51.099 1667: 2063 W/ ]
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
06-18 21:31:51.113 1259-1259/? E/EGL_emulation: tid 1259: eglCreateSyncKHR(1881): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-18 21:31:51.199 1667-1667/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 133ms
06-18 21:31:51.289 1667-1677/? I/art: Background partial concurrent mark sweep GC freed 36018(2MB) AllocSpace objects, 1(20KB) LOS objects, 33% free, 7MB/11MB, paused 3.358ms total 105.317ms
06-18 21:31:51.381 1667-1729/? I/OpenGLRenderer: Initialized EGL, version 1.4
06-18 21:31:51.390 1667-1729/? D/EGL_emulation: eglCreateContext: 0xa07fc120: maj 2 min 0 rcv 2
06-18 21:31:51.414 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:51.484 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:51.691 1667-3205/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
06-18 21:31:51.698 1667-1683/? W/ActivityManager: Activity pause timeout for ActivityRecord{21fdafb u0 com.sqlchild.app1/.MainActivity t8 f}
06-18 21:31:51.877 1667-3206/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityStack$ActivityStackHandler.handleMessage(android.os.Message) from ActivityStack.java:283 waiters=0 for 175ms
06-18 21:31:51.896 1667-1683/? I/ActivityManager: Killing 2545:com.android.keychain/1000 (adj 15): empty #17
06-18 21:31:52.070 2029-2239/? D/EGL_emulation: eglMakeCurrent: 0xae594600: ver 2 0 (tinfo 0xae5924b0)
06-18 21:31:59.062 3129-3129/? I/Process: Sending signal. PID: 3129 SIG: 9
06-18 21:31:59.075 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:59.079 1667-1729/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9e8d1360
06-18 21:31:59.128 1667-3206/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
06-18 21:31:59.130 1667-1721/? W/InputDispatcher: channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-18 21:31:59.130 1667-1721/? E/InputDispatcher: channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-18 21:31:59.129 1667-3206/? W/InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 3129 uid 10061
06-18 21:31:59.132 1667-1721/? W/InputDispatcher: channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-18 21:31:59.133 1667-1721/? E/InputDispatcher: channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-18 21:31:59.153 1667-3206/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
06-18 21:31:59.168 1667-1680/? I/WindowState: WIN DEATH: Window{e76402c u0 com.sqlchild.app1/com.facebook.FacebookActivity}
06-18 21:31:59.169 1667-1680/? W/InputDispatcher: Attempted to unregister already unregistered input channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)'
06-18 21:31:59.174 1667-2280/? D/GraphicsStats: Buffer count: 3
06-18 21:31:59.207 1667-1681/? I/ActivityManager: Process com.sqlchild.app1 (pid 3129) has died
06-18 21:31:59.257 1667-3110/? I/WindowState: WIN DEATH: Window{7f56d84 u0 com.sqlchild.app1/com.sqlchild.app1.MainActivity}
06-18 21:31:59.257 1667-3110/? W/InputDispatcher: Attempted to unregister already unregistered input channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)'
I'm trying to build and an Android app and managed to get through the main purpose of it. However, I'm severely stuck in successfully implementing an SQLite database to have users login if they already have an account off the SQLite database OR create and register for an account.
The relevant classes and XML files for these instructions are correct in my perspective but I believe there's something wrong with my SQLite Query or something wrong when I'd try to look into the Logcat and check for the the registered information from the app user and would display numerous of errors that I find too difficult to debug at this rate.
I will attach the relevant classes, XML files, and what it says at Logcat. Hopefully this way, I can receive the help I'd need as this is severely stopping me from even entering to the main purpose of the app. Your help would be very appreciated. Thank You.
login.java
public class login extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login);
final EditText etUsername = (EditText)findViewById(R.id.editText);
final EditText etPassword = (EditText)findViewById(R.id.editText2);
final Button bLogin = (Button)findViewById(R.id.loginbutton);
final Button bRegister = (Button)findViewById(R.id.registernowbutton);
bRegister.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v){
Intent registerIntent = new
Intent(login.this,RegisterUser.class);
login.this.startActivity(registerIntent);
}
});
}
}
RegisterUser.java
public class RegisterUser extends Activity {
EditText USER_NAME, USER_PASS, CON_PASS;
String user_name, user_pass, con_pass;
Button REG;
Context ctx = this;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_user);
USER_NAME = findViewById(R.id.reg_user);
USER_PASS = findViewById(R.id.reg_pass);
CON_PASS = findViewById(R.id.con_pass);
REG = findViewById(R.id.registerbutton);
REG.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
user_name = USER_NAME.getText().toString();
user_pass = USER_PASS.getText().toString();
con_pass = CON_PASS.getText().toString();
if(!(user_pass.equals(con_pass))){
Toast.makeText(getBaseContext(),"Passwords Do Not
Match",Toast.LENGTH_LONG).show();
USER_NAME.setText("");
USER_PASS.setText("");
CON_PASS.setText("");
}
else{
DatabaseOperations DB = new DatabaseOperations(ctx);
DB.putInformation(DB, user_name, user_pass);
Toast.makeText(getBaseContext(), "Registration Success",
Toast.LENGTH_LONG).show();
finish();
}
}
});
}
}
DatabaseOperations.java
public class DatabaseOperations extends SQLiteOpenHelper {
public static final int database_version = 1;
public String CREATE_QUERY = "CREATE TABLE
"+TableData.TableInfo.TABLE_NAME+"("+TableData.TableInfo.USER_NAME+"
TEXT,"+TableData.TableInfo.USER_PASSWORD+" TEXT );";
public DatabaseOperations(Context context) {
super(context, TableData.TableInfo.DATABASE_NAME, null,
database_version);
Log.d("Database operations", "Database created");
}
#Override
public void onCreate(SQLiteDatabase sdb) {
sdb.execSQL(CREATE_QUERY);
Log.d("Database operations","Table created");
}
#Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
}
public void putInformation(DatabaseOperations dop, String name, String
pass){
SQLiteDatabase SQ = dop.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(TableData.TableInfo.USER_NAME, name);
cv.put(TableData.TableInfo.USER_PASSWORD, pass);
SQ.insert(TableData.TableInfo.TABLE_NAME, null,cv);
Log.d("Database operations", "One raw inserted");
}
}
login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradient"
tools:context=".login"
android:id="#+id/relativeLayout">
<EditText
android:id="#+id/editText"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/editText2"
android:layout_centerVertical="true"
android:background="#11000000"
android:drawableStart="#drawable/ic_action_user"
android:ems="10"
android:hint="PSU Email"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText2"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/loginbutton"
android:layout_below="#+id/editText"
android:layout_marginTop="22dp"
android:background="#11000000"
android:drawableStart="#drawable/ic_action_pass"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText"
app:layout_constraintVertical_bias="0.008" />
<Button
android:id="#+id/loginbutton"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="#+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp"
android:background="#ff77aa"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.692" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="400dp"
android:layout_height="200dp"
android:layout_above="#+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginBottom="42dp"
android:src="#drawable/pennstateshield"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.249" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/loginbutton"
android:layout_centerHorizontal="true"
android:layout_marginTop="44dp"
android:gravity="center"
android:text="Not Registered? Please Join!"
android:textAlignment="center" />
<Button
android:id="#+id/registernowbutton"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/loginbutton"
android:layout_below="#+id/textView3"
android:background="#ff77aa"
android:text="Register Now"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.692" />
</RelativeLayout>
activity_register_user.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradient"
tools:context="m.rami.psucalculator.RegisterUser"
android:id="#+id/relativeactivityregister">
<ImageView
android:id="#+id/registerpsulogo"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:src="#drawable/pennstateshield"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.249" />
<EditText
android:id="#+id/reg_user"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#11000000"
android:drawableStart="#drawable/ic_action_user"
android:ems="10"
android:hint="Enter PSU Email"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/reg_pass"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/reg_user"
android:layout_below="#+id/reg_user"
android:layout_marginTop="20dp"
android:background="#11000000"
android:drawableStart="#drawable/ic_action_pass"
android:ems="10"
android:hint="Enter Password"
android:inputType="textPassword"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText"
app:layout_constraintVertical_bias="0.008" />
<EditText
android:id="#+id/con_pass"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/reg_pass"
android:layout_below="#+id/reg_pass"
android:layout_marginTop="20dp"
android:background="#11000000"
android:drawableStart="#drawable/ic_action_pass"
android:ems="10"
android:hint="Re-Enter Password"
android:inputType="textPassword"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText"
app:layout_constraintVertical_bias="0.008" />
<Button
android:id="#+id/registerbutton"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/con_pass"
android:layout_below="#+id/con_pass"
android:layout_marginTop="32dp"
android:background="#ff77aa"
android:text="Register"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.692" />
</RelativeLayout>
Information from Logcat of Errors:
04-20 12:37:32.428 22018-22018/m.rami.psucalculator I/zygote: Not late-
enabling -Xcheck:jni (already on)
04-20 12:37:32.437 22018-22018/m.rami.psucalculator W/zygote: Unexpected
CPU variant for X86 using defaults: x86
04-20 12:37:32.841 22018-22018/m.rami.psucalculator I/InstantRun: starting
instant run server: is main process
04-20 12:37:33.301 22018-22048/m.rami.psucalculator D/OpenGLRenderer: HWUI
GL Pipeline
04-20 12:37:33.351 22018-22048/m.rami.psucalculator I/OpenGLRenderer:
Initialized EGL, version 1.4
04-20 12:37:33.351 22018-22048/m.rami.psucalculator D/OpenGLRenderer: Swap
behavior 1
04-20 12:37:33.352 22018-22048/m.rami.psucalculator W/OpenGLRenderer:
Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying
without...
04-20 12:37:33.352 22018-22048/m.rami.psucalculator D/OpenGLRenderer: Swap
behavior 0
04-20 12:37:33.428 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglCreateContext: 0xa0e052a0: maj 2 min 0 rcv 2
04-20 12:37:33.488 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:33.608 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:36.566 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:36.745 22018-22018/m.rami.psucalculator I/AssistStructure:
Flattened final assist data: 2212 bytes, containing 1 windows, 7 views
04-20 12:37:42.827 22018-22023/m.rami.psucalculator I/zygote: Do partial
code cache collection, code=23KB, data=27KB
04-20 12:37:42.829 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=23KB, data=27KB
04-20 12:37:42.829 22018-22023/m.rami.psucalculator I/zygote: Increasing
code cache capacity to 128KB
04-20 12:37:42.902 22018-22023/m.rami.psucalculator I/zygote: Do partial
code cache collection, code=30KB, data=56KB
04-20 12:37:42.902 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=30KB, data=56KB
04-20 12:37:42.902 22018-22023/m.rami.psucalculator I/zygote: Increasing
code cache capacity to 256KB
04-20 12:37:42.902 22018-22023/m.rami.psucalculator I/zygote: JIT allocated
71KB for compiled code of void android.widget.TextView.<init>
(android.content.Context, android.util.AttributeSet, int, int)
04-20 12:37:42.902 22018-22023/m.rami.psucalculator I/zygote: Compiler
allocated 4MB to compile void android.widget.TextView.<init>
(android.content.Context, android.util.AttributeSet, int, int)
04-20 12:37:42.989 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:43.025 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:43.038 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:43.077 22018-22018/m.rami.psucalculator I/AssistStructure:
Flattened final assist data: 2060 bytes, containing 1 windows, 6 views
04-20 12:37:45.457 22018-22023/m.rami.psucalculator I/zygote: Do full code
cache collection, code=124KB, data=78KB
04-20 12:37:45.460 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=122KB, data=53KB
04-20 12:37:47.316 22018-22023/m.rami.psucalculator I/zygote: Do partial
code cache collection, code=124KB, data=58KB
04-20 12:37:47.320 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=124KB, data=58KB
04-20 12:37:47.320 22018-22023/m.rami.psucalculator I/zygote: Increasing
code cache capacity to 512KB
04-20 12:37:51.958 22018-22018/m.rami.psucalculator D/Database operations:
Database created
04-20 12:37:51.962 22018-22018/m.rami.psucalculator E/SQLiteLog: (1) table
reg_info has no column named user_password
04-20 12:37:51.965 22018-22018/m.rami.psucalculator E/SQLiteDatabase: Error
inserting user_password=Rami user_name=ram6077
android.database.sqlite.SQLiteException: table reg_info has no column named
user_password (code 1): , while compiling: INSERT INTO
reg_info(user_password,user_name) VALUES (?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native
Method)
at
android.database.sqlite.SQLiteConnection.
acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.
prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.
insertWithOnConflict(SQLiteDatabase.java:1472)
at android.database.sqlite.SQLiteDatabase.
insert(SQLiteDatabase.java:1343)
at
m.rami.psucalculator.DatabaseOperations.
putInformation(DatabaseOperations.java:44)
at m.rami.psucalculator.RegisterUser$1.onClick(RegisterUser.java:43)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
04-20 12:37:51.965 22018-22018/m.rami.psucalculator D/Database operations:
One raw inserted
04-20 12:37:52.083 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.103 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.238 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.274 22018-22048/m.rami.psucalculator I/chatty:
uid=10085(u0_a85) RenderThread identical 1 line
04-20 12:37:52.301 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.346 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.380 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:37:52.387 22018-22048/m.rami.psucalculator D/OpenGLRenderer:
endAllActiveAnimators on 0x8e9f3500 (Button) with handle 0xa0e03740
04-20 12:37:52.808 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:39:33.362 22018-22023/m.rami.psucalculator I/zygote: Do full code
cache collection, code=249KB, data=150KB
04-20 12:39:33.363 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=245KB, data=134KB
04-20 12:39:44.912 22018-22023/m.rami.psucalculator I/zygote: Do partial
code cache collection, code=245KB, data=137KB
04-20 12:39:44.913 22018-22023/m.rami.psucalculator I/zygote: After code
cache collection, code=245KB, data=137KB
04-20 12:39:44.913 22018-22023/m.rami.psucalculator I/zygote: Increasing
code cache capacity to 1024KB
04-20 12:40:02.461 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:02.507 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:02.516 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:02.564 22018-22018/m.rami.psucalculator I/AssistStructure:
Flattened final assist data: 2060 bytes, containing 1 windows, 6 views
04-20 12:40:16.580 22018-22018/m.rami.psucalculator D/Database operations:
Database created
04-20 12:40:16.585 22018-22018/m.rami.psucalculator E/SQLiteLog: (1) table
reg_info has no column named user_password
04-20 12:40:16.587 22018-22018/m.rami.psucalculator E/SQLiteDatabase: Error
inserting user_password=Rami user_name=ram6077
android.database.sqlite.SQLiteException: table reg_info has no column named
user_password (code 1): , while compiling: INSERT INTO
reg_info(user_password,user_name) VALUES (?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native
Method)
at
android.database.sqlite.SQLiteConnection.
acquirePreparedStatement(SQLiteConnection.java:889)
at
android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at
android.database.sqlite.SQLiteDatabase.
insertWithOnConflict(SQLiteDatabase.java:1472)
at android.database.sqlite.SQLiteDatabase.
insert(SQLiteDatabase.java:1343)
at
m.rami.psucalculator.DatabaseOperations.
putInformation(DatabaseOperations.java:44)
at m.rami.psucalculator.RegisterUser$1.onClick(RegisterUser.java:43)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
04-20 12:40:16.588 22018-22018/m.rami.psucalculator D/Database operations:
One raw inserted
04-20 12:40:16.648 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:16.662 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:16.733 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:16.774 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:16.879 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:16.920 22018-22048/m.rami.psucalculator I/chatty:
uid=10085(u0_a85) RenderThread identical 1 line
04-20 12:40:17.056 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 12:40:17.067 22018-22048/m.rami.psucalculator D/OpenGLRenderer:
endAllActiveAnimators on 0x9c5dc880 (Button) with handle 0xa0e03fa0
04-20 12:40:17.361 22018-22048/m.rami.psucalculator D/EGL_emulation:
eglMakeCurrent: 0xa0e052a0: ver 2 0 (tinfo 0xa0e032e0)
04-20 18:32:41.232 22018-22024/m.rami.psucalculator I/zygote:
Thread[3,tid=22024,WaitingInMainSignalCatcherLoop,
Thread*=0xaa3dac00,peer=0x131c0088,"Signal Catcher"]: reacting to signal 3
04-20 18:32:41.375 22018-22024/m.rami.psucalculator I/zygote: Wrote stack
traces to '/data/anr/traces.txt'
The insert into table reg_info isn't working because of
no column named user_password
, as per :-
table reg_info has no column named user_password (code 1): , while compiling: INSERT INTO reg_info(user_password,user_name) VALUES (?,?)
This is likely due to the table having been modified in your table create SQL (user_password column added at a guess), but that hasn't been applied due to how the onCreate method is invoked.
That is the onCreate method is invoked once when the database itself is created (unless invoked elsewhere), it is not run every time the App is run.
The quickest fix is to either :-
Delete the App's data from settings/Apps or
Uninstall the App
and to then rerun the App.
Noting that this deletes the database and thus any data stored in the database.
If you need to preserve data then you would need to run the SQL ALTER TABLE reg_info ADD COLUMN user_password TEXT at an appropriate place within the code.
Here is the full log:
03-20 22:49:26.953 4986-4986/? I/art: Not late-enabling -Xcheck:jni (already on)
03-20 22:49:26.955 4986-4986/? W/art: Unexpected CPU variant for X86 using defaults: x86
03-20 22:49:27.232 4986-4986/com.example.alphie.androidvideostream W/System: ClassLoader referenced unknown path: /data/app/com.example.alphie.androidvideostream-1/lib/x86
03-20 22:49:27.250 4986-4986/com.example.alphie.androidvideostream I/InstantRun: starting instant run server: is main process
03-20 22:49:27.535 4986-4986/com.example.alphie.androidvideostream W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-20 22:49:27.737 4986-5002/com.example.alphie.androidvideostream I/OpenGLRenderer: Initialized EGL, version 1.4
03-20 22:49:27.737 4986-5002/com.example.alphie.androidvideostream D/OpenGLRenderer: Swap behavior 1
03-20 22:49:27.738 4986-5002/com.example.alphie.androidvideostream W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
03-20 22:49:27.738 4986-5002/com.example.alphie.androidvideostream D/OpenGLRenderer: Swap behavior 0
03-20 22:49:27.741 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglCreateContext: 0x9f6316c0: maj 3 min 0 rcv 3
03-20 22:49:27.743 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:49:27.784 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:08.625 4986-4986/com.example.alphie.androidvideostream W/MediaPlayer: Couldn't open https://youtu.be/oEgpGv2CF1U: java.io.FileNotFoundException: No content provider: https://youtu.be/oEgpGv2CF1U
03-20 22:58:08.635 4986-4998/com.example.alphie.androidvideostream D/NetworkSecurityConfig: No Network Security Config specified, using platform default
03-20 22:58:08.666 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:09.980 4986-5049/com.example.alphie.androidvideostream E/MediaPlayer: error (1, -2147483648)
03-20 22:58:09.980 4986-4986/com.example.alphie.androidvideostream E/MediaPlayer: Error (1,-2147483648)
03-20 22:58:09.980 4986-4986/com.example.alphie.androidvideostream D/VideoView: Error: 1,-2147483648
03-20 22:58:10.069 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.092 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.131 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.141 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.625 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.647 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.661 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.669 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.675 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.745 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.759 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.927 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
"can't play video" error displays after hitting play button
As you can see, I have internet with the uses permission. heres my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alphie.androidvideostream">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
and here is my java for my MainActivity:
package com.example.alphie.androidvideostream;
import android.app.ProgressDialog;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity implements
View.OnClickListener {
ProgressDialog mDialog;
VideoView videoView;
ImageButton btnPlayPause;
String videoURL = "https://youtu.be/oEgpGv2CF1U";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView= (VideoView)findViewById(R.id.videoView);
btnPlayPause = (ImageButton)findViewById(R.id.btn_play_pause);
btnPlayPause.setOnClickListener(this);
}
#Override
public void onClick(View v) {
mDialog = new ProgressDialog(MainActivity.this);
mDialog.setMessage("Please wait...");
mDialog.setCanceledOnTouchOutside(false);
mDialog.show();
try
{
if(!videoView.isPlaying()) {
Uri uri = Uri.parse(videoURL);
videoView.setVideoURI(uri);
videoView.setOnCompletionListener(new
MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
btnPlayPause.setImageResource(R.drawable.ic_play);
}
});
}
else
{
videoView.pause();
btnPlayPause.setImageResource(R.drawable.ic_play);
}
}
catch (Exception ex )
{
}
videoView.requestFocus();
videoView.setOnPreparedListener(new
MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mDialog.dismiss();
mp.setLooping(true);
videoView.start();
btnPlayPause.setImageResource(R.drawable.ic_pause);
}
});
}
}
As you can see, I have parsed the url and am using uri so that way i can get a remote video. any ideas? thanks
https://youtu.be/oEgpGv2CF1U points to a website, not a video stream. An example of a video stream URI would be
rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov.
It used to be possible to get YouTube stream URIs using the YouTube API, but it was changed in 2015. I suggest you launch the video in the YouTube app, as detailed here.