one. Essay content (scene content direction)
1. Project background
I originally created a small toolbar APP in my school’s Android application practice last year. The reason is that there are elderly people at home who are using the new smart phone but it is inconvenient to operate. Many commonly used functions cannot be found, which causes the elderly’s distress. On this occasion, I personally made a simple toolbox app, not only as a personal practice of Android apps, but also an attempt to provide convenience for the elderly.
2. Challenges
one. Fragment switch
The first thing that comes to mind is the key switch of the subscript bar in the APP, that is, the homepage segmentation for Fragment. The problems encountered are as follows:
(1) In the Java code in the project package, it is encountered that the class of Fragment cannot be inherited normally by using MainActivity, which causes many Java methods to be unable to be used normally, resulting in a crash.
(2) When performing Fragment substitution switching, the program opens normally but crashes.
(3) Fragment is not initialized, causing the program to open normally but crash.
two. Delay page entry software
很多APP进入页面时有对应广告或者说明,做了个小型的介绍页面以及触摸任何一个地方进行延迟取消进入APP,遇到的问题有
如下:
Without adding the timer thread, the page switching effect of the time delay processing alone will have crashes, crashes, etc.
3. Steps to solve the problem
one. Fragment switching solution
(1) In the Java code in the project package, it is encountered that the use of MainActivity cannot normally inherit the Fragment class, resulting in many Java methods that cannot be used normally, resulting in a red crash. You cannot inherit from Fragment as usual. You should inherit from FragmentActivity. The MainActivity achieves the effect consistent with the ordinary Activity class.
(2) When the program opens normally but crashes when switching to Fragment substitution, the FrameLayout should be embedded in the activity_main file in the layout file
In this way, the FragmentManager class in the java file can call getSupportFragmentManager normally
(3) If the Fragment is not initialized and the program opens normally but crashes, you should initialize a fixed page in the APP first
two. Delayed page crash resolution
Join the following two categories
If it is a picture interface, you can use ImageView, first write the code to close the welcome interface jump
Then add a delay function, use the intent method to jump, and timer.schedule to delay, the delay time can be selected by yourself.
two. Project summary
A large app requires more threads and logical scheduling. Although I am a small app this time, I have made a lot of distressing mistakes when I first started to develop Android apps. Although I am currently using it with improved fluency and almost no crash bugs Under the premise of, there are many shortcomings, and the following measures should be taken:
(1) The name of the page has also delayed a lot of time, so the name of the interface should be classified as a txt so that you can query by yourself
(2) The selection of functions requires correct reading and understanding of information, rather than blindly extracting. Sometimes a function is updated and replaced or is not properly connected to the main class, and errors that are difficult to find when the subsequent types are inherited.
(3) Since the understanding of development tools and application knowledge is still very insufficient, a simple APP development takes a lot of time to find errors. The foundation should be consolidated first, rather than mechanically applied. Online methods should be based on the essence of the dross and understand Good the logic and write it out in your own way.
3. Personal profile
Author: Wei Chengchen
A school student majored in the direction of artificial intelligence in Internet of Things application technology. The main programming languages learned at school include Python, C language, Java and Linux basics, etc., and participated in the China Software Cup and "Internet +" with the team. Undergraduate entrepreneurship competitions, etc., have a basic understanding of deep learning and Python applications.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。