我正在开发一个看起来像启动器但用于书籍的应用程序。
在主要 Activity 中,我有书籍图像,我可以通过点击在特定的阅读器应用程序中打开它们。效果很好。
但是当我从阅读器应用程序返回时,我发现布局已损坏, Activity 的上方被状态栏覆盖。如果我再次打开阅读器应用程序并再次返回主 Activity - 一切都很好!
这是我用于打开书籍的代码:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri bookFileUri = Uri.fromFile(new File(book.getFilePath()));
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(bookFileUri.toString());
String mimeType = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
intent.setDataAndType(bookFileUri, mimeType);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.d("Onyx", ex.getMessage());
Toast.makeText(getApplicationContext(), getResources().getString(R.string.error_opening_book_message), Toast.LENGTH_LONG).show();
}
and after first time when i'm got back, i see this (look to top of activity)
如何解决?
最佳答案
尝试在 OnResume() 中初始化 View 。当您按回键时,不会调用 onCreate()。
关于java - Android:从全屏 Activity 返回后布局被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43111507/