I noticed my app wasn't working on Pixel 3. I went into android studio and emulated a few devices and noticed it is not working on any Android Pie (API 28) devices, but works fine on any other. I put a few logs throughout my code, and it seemed that I was not getting a response within my Volley usage. The app itself loads, but does not display any data, and I receive an error
E/RecyclerView: No adapter attached; skipping layout
My code is
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
DatabaseManagement db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
db = new DatabaseManagement(this);
grabData();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(MainActivity.this, com.hellapunk.hellapunk.feature.Main2Activity.class);
startActivity(i);
finish();
}
}, 3000);
}
public void grabData() {
//Log.i("Made it", "You made it this far");
String url = "http://hellapunk.com/listallshows.php?id=2018";
StringRequest sr = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONArray showInfo = new JSONArray(response);
Log.i("Something", "response");
for (int i = 0; i < showInfo.length(); ++i) {
JSONObject showInfo1 = showInfo.getJSONObject(i);
if ((db.checkShow(showInfo1.getString("show_summary"),
showInfo1.getString("show_date"))) > 0) {
Log.i("Results", "Show already exists");
} else {
db.insertShows(showInfo1.getString("show_summary"),
showInfo1.getString("venue_name"),
showInfo1.getString("show_date"),
showInfo1.getString("shows_img"),
showInfo1.getString("venue_address"),
showInfo1.getString("city_name"),
showInfo1.getString("city_region"));
}
}
} catch (Exception e) {
Log.i("Error", e.getMessage());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("TAG", ""+error);
}
});
Volley.newRequestQueue(this).add(sr);
}
}
I grab the data during my splash screen and store it into a local database. Then it is called from the db on the next Activity. Any advice will be appreciated!