I faced infinite run when I am trying using ListView with retrieving data from firebase, and I don't know how can I solve it.
My main goal is retrieving from firebase with a dynamic number of clients who have a status of "Not approved".
This my RUN
10/03 21:30:58: Launching app $ adb shell am start -n "com.example.atheer.booklyv1/com.example.atheer.booklyv1.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Client not ready yet..Waiting for process to come online Connected to process 8309 on device emulator-5554 Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. W/atheer.booklyv: JIT profile information will not be recorded: profile file does not exits. I/chatty: uid=10086(com.example.atheer.booklyv1) identical 10 lines W/atheer.booklyv: JIT profile information will not be recorded: profile file does not exits. W/atheer.booklyv: Unsupported class loader W/atheer.booklyv: Skipping duplicate class check due to unsupported classloader W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found. W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found. W/atheer.booklyv: Verification of android.content.Intent com.google.android.gms.common.zzf.zza(android.content.Context, int, java.lang.String) took 130.356ms I/BiChannelGoogleApi: [FirebaseAuth: ] No Fallback module; NOT setting up for lazy initialization D/FirebaseAuth: Notifying id token listeners about user ( N72Vpxaf6dao4pSf5cvBJ1jwzGo2 ). D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization. V/FA: Cancelling job. JobID: -1422956107 V/FA: Registered activity lifecycle callback I/FirebaseInitProvider: FirebaseApp initialization successful I/InstantRun: starting instant run server: is main process V/FA: Collection enabled V/FA: App package, google app id: com.example.atheer.booklyv1, 1:666514046827:android:60ad4570c33e1aec I/FA: App measurement is starting up, version: 11910 To enable debug logging run: adb shell setprop log.tag.FA VERBOSE To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.example.atheer.booklyv1 D/FA: Debug-level message logging enabled W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found. V/FA: onActivityCreated V/FA: Connecting to remote service I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions. [FirebaseAuth:] Preparing to create service connection to gms implementation V/FA: Connection attempt already in progress W/atheer.booklyv: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection) W/atheer.booklyv: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection) D/OpenGLRenderer: Skia GL Pipeline V/FA: Connection attempt already in progress Activity resumed, time: 1574868 I/FA: Tag Manager is not found and thus will not be used D/FirebaseApp: Notifying auth state listeners. D/FirebaseApp: Notified 0 auth state listeners. D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=5185910341027462403}] D/: HostConnection::get() New Host Connection established 0xdeffec40, tid 8354 I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0 android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0 I/OpenGLRenderer: Initialized EGL, version 1.4 D/OpenGLRenderer: Swap behavior 1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... D/OpenGLRenderer: Swap behavior 0 D/EGL_emulation: eglCreateContext: 0xcc20f240: maj 3 min 0 rcv 3 D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 4 V/StudioProfiler: StudioProfilers agent attached. V/StudioProfiler: Acquiring Application for Events V/StudioProfiler: Transformed class: java/net/URL W/atheer.booklyv: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it! V/StudioProfiler: Memory control stream started. V/StudioProfiler: Live memory tracking disabled. V/StudioProfiler: Live memory tracking enabled. JNIEnv not attached V/StudioProfiler: Loaded classes: 11553 V/StudioProfiler: Tracking initialization took: 410566000ns W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@f188cbd V/FA: Recording user engagement, ms: 4164 V/FA: Activity paused, time: 1579010 V/FA: onActivityCreated I/atheer.booklyv: Background concurrent copying GC freed 662(4MB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3MB/6MB, paused 1.122ms total 328.178ms D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=4164, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=5185910341027462403}] V/FA: Activity resumed, time: 1580197 D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=MainActivity, firebase_previous_id(_pi)=5185910341027462403, firebase_screen_class(_sc)=mHomePage, firebase_screen_id(_si)=5185910341027462404}] D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@877a26c V/FA: Recording user engagement, ms: 4828 V/FA: Activity paused, time: 1585022 V/FA: onActivityCreated D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=4828, firebase_screen_class(_sc)=mHomePage, firebase_screen_id(_si)=5185910341027462404}] I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6 Selected remote version of com.google.android.gms.firebase_database, version >= 6 V/FA: Activity resumed, time: 1585685 I/Choreographer: Skipped 37 frames! The application may be doing too much work on its main thread. W/atheer.booklyv: Unsupported class loader W/atheer.booklyv: Skipping duplicate class check due to unsupported classloader D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=mHomePage, firebase_previous_id(_pi)=5185910341027462404, firebase_screen_class(_sc)=loginActivity, firebase_screen_id(_si)=5185910341027462405}] I/OpenGLRenderer: Davey! duration=916ms; Flags=1, IntendedVsync=1585088907737, Vsync=1585705574379, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1585721516670, AnimationStart=1585721565670, PerformTraversalsStart=1585722412670, DrawStart=1586003516670, SyncQueued=1586003568670, SyncStart=1586003659670, IssueDrawCommandsStart=1586003710670, SwapBuffers=1586004070670, FrameCompleted=1586005330670, DequeueBufferDuration=162000, QueueBufferDuration=300000, D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) D/NetworkSecurityConfig: No Network Security Config specified, using platform default I/AssistStructure: Flattened final assist data: 3404 bytes, containing 1 windows, 11 views V/FA: Inactivity, disconnecting from the service I/AssistStructure: Flattened final assist data: 3428 bytes, containing 1 windows, 11 views W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms D/FirebaseAuth: Notifying id token listeners about user ( N72Vpxaf6dao4pSf5cvBJ1jwzGo2 ). D/FirebaseApp: Notifying auth state listeners. D/FirebaseApp: Notified 1 auth state listeners. V/FA: Recording user engagement, ms: 21363 V/FA: Connecting to remote service W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@48f31b0 V/FA: Activity paused, time: 1607047 D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=21363, firebase_screen_class(_sc)=loginActivity, firebase_screen_id(_si)=5185910341027462405}] V/FA: onActivityCreated V/FA: Connection attempt already in progress I/atheer.booklyv: NativeAlloc concurrent copying GC freed 25494(1649KB) AllocSpace objects, 19(632KB) LOS objects, 50% free, 3MB/7MB, paused 580us total 742.771ms V/FA: Connection attempt already in progress V/FA: Activity resumed, time: 1608103 D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=loginActivity, firebase_previous_id(_pi)=5185910341027462405, firebase_screen_class(_sc)=dashboardAdmin, firebase_screen_id(_si)=5185910341027462406}] D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 4 W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@7f475a4 V/FA: Recording user engagement, ms: 5136 V/FA: Activity paused, time: 1613235 D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=5136, firebase_screen_class(_sc)=dashboardAdmin, firebase_screen_id(_si)=5185910341027462406}] V/FA: onActivityCreated V/FA: Activity resumed, time: 1613594 D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=dashboardAdmin, firebase_previous_id(_pi)=5185910341027462406, firebase_screen_class(_sc)=approvedAdmin, firebase_screen_id(_si)=5185910341027462407}] D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) W/atheer.booklyv: Long wait of 5.943ms for Thread[1,tid=8309,Native,Thread*=0xe6674000,peer=0x738f9ec8,"main"] suspension! D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) D/EGL_emulation: eglMakeCurrent: 0xcc20f240: ver 3 0 (tinfo 0xe2730c60) V/FA: Inactivity, disconnecting from the service E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) I/chatty: uid=10086(com.example.atheer.booklyv1) Binder:8309_5 identical 3 lines E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions. I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
And this is my java code
package com.example.atheer.booklyv1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.Map;
public class approvedAdmin extends AppCompatActivity implements View.OnClickListener{
DatabaseReference dref;
ListView listview;
ArrayList<String> list=new ArrayList<>();
ArrayAdapter<String> adapter;
public approvedAdmin() {
}
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_approved_admin);
listview=(ListView)findViewById(R.id.list);
dref= FirebaseDatabase.getInstance().getReference("client");
// adapter.notifyDataSetChanged();
dref.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String status;
String name;
String email;
Toast.makeText(approvedAdmin.this, "ok", Toast.LENGTH_SHORT).show();
for(DataSnapshot ds: dataSnapshot.getChildren() ){
if (ds.hasChild("Status")){
status=ds.child("Status").getValue(String.class);
if (status.equalsIgnoreCase("Not approved")){
name= ds.child("name").getValue(String.class);
list.add(name);
adapter= new ArrayAdapter<String>(approvedAdmin.this, android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
}}
}}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
@Override
public void onClick(View v) {
}
}
And this is my xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".approvedAdmin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
adapter= new ArrayAdapter<String>(approvedAdmin.this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter);
– Krishna Sharma