I set the background image with full hd quality and after that, the application became terribly slow, fps 5 probably. PS The application displays a list of data from the database, with the usual background, everything is fine (RGB or something like that), put a picture in the style and everything, tryndets ...

public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; private Cursor c; public ArrayList mDataSet = new ArrayList(); public ArrayList mDataSet1 = new ArrayList(); @Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG,"onCreate start"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); MyDatabase db = new MyDatabase(this); c = db.getEmployees(); MyTask mt = new MyTask(); mt.execute(); Log.d(TAG,"onCreate finished"); } private ArrayList<String> getDataSet() { Log.d(TAG,"start getDataset"); c.moveToFirst(); for (int i = 1; i < c.getCount();i++) { mDataSet.add(c.getString(1)); c.moveToNext(); } return mDataSet; } private ArrayList<String> getDataSet1() { Log.d(TAG,"start getDataset1"); c.moveToFirst(); for (int i = 1; i < c.getCount();i++) { mDataSet1.add(c.getString(2)); c.moveToNext(); } return mDataSet1; } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_settings: Toast toast = Toast.makeText(MainActivity.this, "Пункт настроек в разработке", Toast.LENGTH_SHORT); toast.show(); Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } class MyTask extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected Void doInBackground(Void... params) { return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); ArrayList<String> myDataset = getDataSet(); ArrayList<String> myDataset1 = getDataSet1(); RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(MainActivity.this); if (mRecyclerView != null) { mRecyclerView.setLayoutManager(mLayoutManager); } RecyclerAdapter mAdapter = new RecyclerAdapter(myDataset, myDataset1); if (mRecyclerView != null) { mRecyclerView.setAdapter(mAdapter); } } } } 
  • What is being done in the application? show the code / markup - Android Android
  • one
    why push FHD? Upload a picture to fit the background. the difference will not notice. You just got this picture of all your memory. - Chaynik
  • The code seems to be fine. Before that, there was not one lag, as soon as I put the background in the styles, everything started with this. Yes, and how the picture weighing 1 megabyte, can so load the phone ?? - Slava Nenashev
  • one
    The role is not the weight of the picture, but its size in pixels and how much byte is spent per pixel -> 1920 * 1080 * 4 (RGBA_8888) = 8 megabytes of memory ... to the background .... - Chaynik
  • @Chaynik What are the options? reduce image resolution? - Slava Nenashev

0