Code in the studio !:

public class Task_list extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> { SharedPreferences sPref; SharedPreferences.Editor ed; ListView li; DB db; Cursor cursor; SimpleCursorAdapter scAdapter; int task_sort, archive, report, task_report; long task_id; ImageView icon_unsort, icon_sortAZ, icon_sortZA, icon_home, icon_help; Intent intent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_task_list); //получаем данные из файла "Pref" sPref = getSharedPreferences("Pref", MODE_PRIVATE); ed = sPref.edit(); task_sort = sPref.getInt("task_sort", 1); // объявляем и отождествляем переменные с элементами icon_home = (ImageView) findViewById(R.id.icon_home); icon_unsort = (ImageView) findViewById(R.id.icon_unsort); icon_sortAZ = (ImageView) findViewById(R.id.icon_sortAZ); icon_sortZA = (ImageView) findViewById(R.id.icon_sortZA); icon_help = (ImageView) findViewById(R.id.icon_help); // открываем подключение к БД db = new DB(this); db.open(); // переменные для адаптера scAdapter = new SimpleCursorAdapter(this, R.layout.list_view, null, new String[]{"name", "archive"}, new int[]{R.id.textView_task, R.id.LinearLayout_task}, 0); // указываем адаптеру свой биндер scAdapter.setViewBinder(new ArchiveViewBinder()); // создааем список li = (ListView) findViewById(R.id.li); //настраиваем список (соединяем с адаптером) li.setAdapter(scAdapter); // создаем лоадер для чтения данных getSupportLoaderManager().initLoader(5, null, this); intent = getIntent(); final int task_from = intent.getIntExtra("from", 0); //реакция на выбор пункта (короткое нажатие) li.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) { cursor = scAdapter.getCursor(); task_id = cursor.getLong(cursor.getColumnIndex("_id")); task_report = cursor.getInt(cursor.getColumnIndex("report")); if (task_from == 1) // выбирает задачу для отчета { String task_name = cursor.getString(cursor.getColumnIndex("name")); int task_archive = cursor.getInt(cursor.getColumnIndex("archive")); intent = new Intent(); intent.putExtra("task_id", task_id); intent.putExtra("task_archive", task_archive); intent.putExtra("task_report", task_report); intent.putExtra("task_name", task_name); setResult(RESULT_OK, intent); Task_list.this.finish(); } if (task_from == 2) // работает как формирование выбранных задач { db.report_change(task_id, task_report); getSupportLoaderManager().getLoader(5).forceLoad(); } if (task_from == 3) // выбирает задачу для отчета 2 { String task_name = cursor.getString(cursor.getColumnIndex("name")); int task_archive = cursor.getInt(cursor.getColumnIndex("archive")); intent = new Intent(); intent.putExtra("task_id", task_id); intent.putExtra("task_archive", task_archive); intent.putExtra("task_report", task_report); intent.putExtra("task_name", task_name); setResult(RESULT_OK, intent); Task_list.this.finish(); } } }); } public void onclick_icon_unsort (View view) { task_sort = 1; ed.putInt("task_sort", task_sort); ed.commit(); getSupportLoaderManager().getLoader(5).forceLoad(); } public void onclick_icon_sortAZ (View view) { task_sort = 2; ed.putInt("task_sort", task_sort); ed.commit(); getSupportLoaderManager().getLoader(5).forceLoad(); } public void onclick_icon_sortZA (View view) { task_sort = 3; ed.putInt("task_sort", task_sort); ed.commit(); getSupportLoaderManager().getLoader(5).forceLoad(); } public void onclick_icon_home (View view) { startActivity(new Intent(this, MainActivity.class)); this.finish(); } public void onclick_icon_help (View view) { startActivity(new Intent(this, Help_Task_list.class)); } @Override public void onBackPressed() { intent = new Intent(); setResult(RESULT_CANCELED, intent); finish(); } protected void onDestroy() { super.onDestroy(); // закрываем курсор и подключение при выходе cursor = scAdapter.getCursor(); cursor.close(); db.close(); } @Override public Loader<Cursor> onCreateLoader(int id, Bundle bndl) { return new MyCursorLoader(this, db); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { scAdapter.swapCursor(cursor); // обновляем состояние кнопок switch (task_sort) { case 1: icon_unsort.setImageResource(R.drawable.ic_sort_grey600_36dp) ; icon_sortAZ.setImageResource(R.drawable.ic_sort_ascending_white_36dp) ; icon_sortZA.setImageResource(R.drawable.ic_sort_descending_white_36dp) ; break; case 2: icon_unsort.setImageResource(R.drawable.ic_sort_white_36dp) ; icon_sortAZ.setImageResource(R.drawable.ic_sort_ascending_grey600_36dp) ; icon_sortZA.setImageResource(R.drawable.ic_sort_descending_white_36dp) ; break; case 3: icon_unsort.setImageResource(R.drawable.ic_sort_white_36dp) ; icon_sortAZ.setImageResource(R.drawable.ic_sort_ascending_white_36dp) ; icon_sortZA.setImageResource(R.drawable.ic_sort_descending_grey600_36dp) ; break; } } @Override public void onLoaderReset(Loader<Cursor> loader) { } class ArchiveViewBinder implements SimpleCursorAdapter.ViewBinder { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { archive = cursor.getInt(cursor.getColumnIndex("archive")); report = cursor.getInt(cursor.getColumnIndex("report")); switch (view.getId()) { // меняем фон линейной разметки в случае архивной задачи case R.id.LinearLayout_task: if (archive == 1 && report == 1) view.setBackgroundResource(R.drawable.button_change_task); if (archive == 1 && report == 0) view.setBackgroundResource(R.drawable.button_stop); if (archive == 0 && report == 1) view.setBackgroundResource(R.drawable.button_start); if (archive == 0 && report == 0) view.setBackgroundResource(R.drawable.button_task); return true; } return false; } } static class MyCursorLoader extends CursorLoader { DB db; public MyCursorLoader(Context context, DB db) { super(context); this.db = db; } @Override public Cursor loadInBackground() { Cursor cursor = db.list_task_report(); return cursor; } } 

}

When you turn the screen, the onCreate method is called again, which causes the application to crash. If you prohibit this by specifying in the manifest

  <activity android:name=".Task_list" android:configChanges="orientation" android:screenOrientation="portrait" /> 

The application does not die when turning the screen due to the "promise" to independently process the orientation change:

  android:configChanges="orientation" 

At the same time, it is also well experienced in changing the font size in the settings of the phone, and changes the font size inside the application in accordance with the selected settings, although there is no broad “promise”, like this:

  android:configChanges="orientation|screenSize|fontScale" 

The question arises: why does a reboot due to a change in orientation result in a crash, but a reboot due to a change in font size does not? The practical significance of this issue lies in the fact that another application using a similar code (I could not find a significant difference in the code, as I did not try), already dies when the font size is changed in the phone settings. What are the features of overloading the application due to font size changes?

  • four
    why can not see the log? so you can only guess, when changing the font, a configuration change occurs after which some NullPointerException occurs. Looking for logs! - Kirill Stoianov
  • one
    @ St-st Show the code, otherwise the question may be closed. - Vladimir Glinskikh
  • Well, find how to see the log, the programmer! - VladD
  • The most ordinary code: strings yes ListVyu. - St-st
  • 2
    I can not see the log, the code is the easiest .. with such input you need to contact the psychics forum, here you are unlikely to help. - pavlofff

1 answer 1

No wonder: Android does not support all fonts. Depending on the version, only True Type or True Type and Open Type fonts are supported.

Well, if you decide to insert a raster font, then, as they say, the sheriff does not care about the problems of the Indians :)

PS It can not be that you can not see the logs. Take the wiring and stick it in the computer? Or install CatLog on the device - is it really that way?

  • standard font, did not change anything. Now I will install CatLog. Tell me where to find the desired log? - St-st
  • Ruth is right, unfortunately. - St-st