CN106325862A - Page initialization method and device based on Android system - Google Patents
Page initialization method and device based on Android system Download PDFInfo
- Publication number
- CN106325862A CN106325862A CN201610688140.1A CN201610688140A CN106325862A CN 106325862 A CN106325862 A CN 106325862A CN 201610688140 A CN201610688140 A CN 201610688140A CN 106325862 A CN106325862 A CN 106325862A
- Authority
- CN
- China
- Prior art keywords
- page
- boolean
- false
- true
- initialized
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a page initialization method and device based on an Android system and relates to the field of application and development of the Android system. The method comprises the following steps: intercepting a system page initialization entrance to generate a Boolean value for judging whether a page is initialized or not, and assigning a value 'false' for representing 'uninitialized'; intercepting a system page size measurement entrance to detect the Boolean value for judging whether the page is initialized or not; if the Boolean value is 'true', representing that the page is initialized and stopping the process; if the Boolean value is 'false', representing that the page is uninitialized and reassigning the value 'true', and informing a developer to carry out later-period initialization. With the adoption of the page initialization method and device, operation authority and attribute information of a view in the page can be obtained and the page is prevented from being repeatedly called.
Description
Technical field
The present invention relates to the application and development field of Android system, be specifically related to a kind of page based on Android system initial
Change method and device.
Background technology
At present, most Android application programs have generally comprised multiple page (Activity), and each page has spy
Fixed function.Such as, current major video playing program often has main interface, column original list, video playback page, Yong Huguan
The reason page etc..
According to the characteristic of Android system, when starting the new page, this page is in the stage of a kind of no initializtion, needs
The initialization operation of person's manual handle page to be developed, view information (such as coordinate, the wide height in waiting process, on the page
Deng) it is in unusable state.
Assuming following scene, shown in Figure 1, this page has several views originally, a circular A and three rectangle B,
C, D, if developer wants in a bubble view A notification message displayed above " Hello World ", shown in Figure 2, open
Originator has following two to select:
(1) shown in Figure 3, to edit layout configuration file, additionally increase a text view for the page, all pages are all
An aspect;
(2) shown in Figure 4, layout configuration file is constant, directly one text view of dynamic insertion, message on the page
Text " Hello World " is suspended in above the page.
Wherein, the former inapplicable batch operation, it is desirable to multiple pages display message it is necessary to revise each page one by one
Layout configuration file;
The latter can be with dynamic operation, but premise is the information (coordinate and width high) that must obtain bubble view A in the page,
This text view showing " Hello World " can be calculated, which position of the page should be placed in actually.
Shown in Figure 5, the flow process of the current Android system auto-initiation page has following 4 steps:
(1) window being used for showing the page is created.In Android system, once starting a page, system is automatic
Can create a PhoneWindow, be used for showing the page, this process is that developer is invisible, can not intervene.
(2) read pre-configured topology file, topology file one page of generation is put into window.
(3) page being carried out early stage initialization, in this step, system can measure the position of A, B, C, D view on the page automatically
Information high with width.
(4) completing to initialize, notifications developer carries out later stage initialization operation, and e.g., developer can obtain the page
The operating right of upper A view, it is thus achieved that its position and size, calculates its central point, then Message-text " Hello
World " accurately it is inserted in center point coordinate.
Developer is before (4th) step completes, it is impossible to obtain the details (coordinate, wide height) of view, shown in Fig. 1
Example, developer have to wait for system complete whole early stage initialize, Message-text " Hello to be shown could be inserted
World”。
Simultaneously as in the early stage initialization step (3) of Android system, multiple little step, developer can be subdivided into again
If careful not, wrong step is write later stage setup code, easily cause and repeat the later stage and initialize and cause
System crash.
Summary of the invention
The invention aims to overcome the deficiency of above-mentioned background technology, it is provided that at the beginning of a kind of page based on Android system
Beginningization method and device, it is possible to obtain operating rights and the attribute information of view in the page, prevent the page from repeating to call.
The present invention provides a kind of page initial method based on Android system, comprises the following steps:
S1, the intercepting system page initialize entrance, generate the Boolean judging " page is the most initialized ", and are it
Assignment " false ", represents " no initializtion ";
S2, intercepting system page size measure entrance, the Boolean of detection " page initializes the most ": if this boolean
Value is " true ", and representation page is the most initialized, terminates this flow process;If Boolean is " false ", representation page is the most initial
Change, be the most again entered as " true ", notify that developer carries out later stage initialization.
The present invention also provides for a kind of page apparatus for initializing based on Android system, and this device includes Boolean signal generating unit
With Boolean detector unit, wherein:
Described Boolean signal generating unit is used for: the intercepting system page initializes entrance, and " page is the most to generate a judgement
Initialized " Boolean, and be its assignment " false ", represent " no initializtion ";
Described Boolean detector unit is used for: intercepting system page size measures entrance, and " page is the most initial in detection
Change " Boolean: if this Boolean is " true ", representation page is the most initialized, terminates this flow process;If Boolean is
" false ", representation page no initializtion, the most again it is entered as " true ", notifies that developer carries out later stage initialization.
Compared with prior art, advantages of the present invention is as follows:
The elder generation of the present invention intercepting system page initializes entrance, generates the Boolean judging " page is the most initialized ",
And be its assignment " false ", represent " no initializtion ";Then intercepting system page size measures entrance, and " page is the most in detection
Initialize " Boolean: if this Boolean is " true ", representation page is the most initialized, terminates this flow process;If Boolean
For " false ", representation page no initializtion, the most again it is entered as " true ", notifies that developer carries out later stage initialization.The present invention
By intercepting system entrance, perform the early stage initialization step through integrated optimization, and construct a notification interface, as long as
This notification interface carries out later stage initialization operation, it becomes possible to obtain operating rights and the attribute information of view in the page, prevent page
Face repeats to call.
Accompanying drawing explanation
Fig. 1 is that parent page contains a circular A and the schematic diagram of three rectangles B, C, D.
Fig. 2 is that developer wants the schematic diagram in a bubble view A notification message displayed above " Hello World ".
Fig. 3 be developer be the schematic diagram that the page additionally increases a text view.
Fig. 4 is developer's directly schematic diagram of one text view of dynamic insertion on the page.
Fig. 5 is the flow chart of the current Android system auto-initiation page.
Fig. 6 is the flow chart of page initial method based on Android system in the embodiment of the present invention.
Detailed description of the invention
Below in conjunction with the accompanying drawings and specific embodiment the present invention is described in further detail.
Shown in Figure 6, the embodiment of the present invention provides a kind of page initial method based on Android system, including following
Step:
S1, the intercepting system page initialize entrance, generate the Boolean of a judgement " page is the most initialized ", and
For its assignment " false ", represent " no initializtion ";
S2, intercepting system page size measure entrance, the Boolean of detection " page initializes the most ":
If this Boolean is " true ", representation page is the most initialized, it is not necessary to what developer carried out repeating calling sentences
Disconnected, terminate this flow process at once;If Boolean is " false ", representation page no initializtion is entered as " true " the most again, logical
Know that developer carries out later stage initialization.
The embodiment of the present invention also provides for a kind of page apparatus for initializing based on Android system, including Boolean signal generating unit
With Boolean detector unit, wherein:
Boolean signal generating unit is used for: the intercepting system page initialize entrance, generate a judgement " page the most at the beginning of
Beginningization " Boolean, and be its assignment " false ", represent " no initializtion ";
Boolean detector unit is used for: intercepting system page size measures entrance, detection " page initializes the most "
Boolean: if this Boolean is " true ", representation page is the most initialized, it is not necessary to what developer carried out repeating calling sentences
Disconnected, terminate this flow process at once;If Boolean is " false ", representation page no initializtion is entered as " true " the most again, logical
Know that developer carries out later stage initialization.
Illustrate as a example by Fig. 1 below:
The code using the primal system page (Activity) to write initialization bubble view A is:
public Demo extends Activity{
Private boolean isInitialized=false;The variable of one page init state of // statement
private View circle;// bubble view A
@Override//manifolding initializes page method
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);// manifolding system function must fill out code
setContentView(R.layout.main);// to arrange page layout file be main.xml
Circle=findViewById (R.id.circle);// search quoting of bubble view
}
@Override//manifolding page initializes complete method
public void onWindowFocusChanged(boolean hasFocus){
super.onWindowFocusChanged(hasFocus);// manifolding system function must fill out code
If(!IsInitialized) // judge whether this function is repeated to call
IsInitialized=true;
Int x=circle.getX ();// if calling for the first time, then obtain information (coordinate, the width of bubble view
High)
Int y=circle.getY ();
Int width=circle.getMeasuredWidth ();
Int height=circle.getMeasuredHeight ();
}
}
}
After using the page initial method based on Android system in the embodiment of the present invention, write initialization circle and regard
The code of figure A is:
public Demo extends ActivityFramework{
private View circle;// bubble view A
@Override//manifolding initializes page method
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);// manifolding system function must fill out code
setContentView(R.layout.main);// to arrange page layout file be main.xml
Circle=findViewById (R.id.circle);// search quoting of bubble view
}
@Override//manifolding initialization callback code, when performing this function, the page is inevitable the most initialized and has measured
Finish
public void config(){
Int x=circle.getX ();The information (coordinate, wide height) of // acquisition bubble view
Int y=circle.getY ();
Int width=circle.getMeasuredWidth ();
Int height=circle.getMeasuredHeight ();
}
}
By the code comparison of both the above method, it can clearly be seen that: the embodiment of the present invention simplifies developer and writes
Code, save and judge to repeat the step called, prevent developer from repeating to call the system crash caused.
Those skilled in the art can carry out various modifications and variations to the embodiment of the present invention, if these amendments and change
Type is within the scope of the claims in the present invention and equivalent technologies thereof, then these amendments and modification are also in protection scope of the present invention
Within.
The prior art that the content not described in detail in description is known to the skilled person.
Claims (2)
1. a page initial method based on Android system, it is characterised in that comprise the following steps:
S1, the intercepting system page initialize entrance, generate the Boolean judging " page is the most initialized ", and are its assignment
" false ", represents " no initializtion ";
S2, intercepting system page size measure entrance, the Boolean of detection " page initializes the most ": if this Boolean is
" true ", representation page is the most initialized, terminates this flow process;If Boolean is " false ", representation page no initializtion, then
Again it is entered as " true ", notifies that developer carries out later stage initialization.
2. a page apparatus for initializing based on Android system, it is characterised in that: this device include Boolean signal generating unit and
Boolean detector unit, wherein:
Described Boolean signal generating unit is used for: the intercepting system page initialize entrance, generate a judgement " page the most at the beginning of
Beginningization " Boolean, and be its assignment " false ", represent " no initializtion ";
Described Boolean detector unit is used for: intercepting system page size measures entrance, detection " page initializes the most "
Boolean: if this Boolean is " true ", representation page is the most initialized, terminates this flow process;If Boolean is
" false ", representation page no initializtion, the most again it is entered as " true ", notifies that developer carries out later stage initialization.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610688140.1A CN106325862A (en) | 2016-08-18 | 2016-08-18 | Page initialization method and device based on Android system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610688140.1A CN106325862A (en) | 2016-08-18 | 2016-08-18 | Page initialization method and device based on Android system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106325862A true CN106325862A (en) | 2017-01-11 |
Family
ID=57743229
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610688140.1A Pending CN106325862A (en) | 2016-08-18 | 2016-08-18 | Page initialization method and device based on Android system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106325862A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102520918A (en) * | 2011-09-27 | 2012-06-27 | 深圳市五巨科技有限公司 | Method and device for increasing list refreshing frequency |
US8694898B2 (en) * | 2010-11-06 | 2014-04-08 | Hon Hai Precision Industry Co., Ltd. | Electronic device with widgets and method for configuring widgets |
-
2016
- 2016-08-18 CN CN201610688140.1A patent/CN106325862A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8694898B2 (en) * | 2010-11-06 | 2014-04-08 | Hon Hai Precision Industry Co., Ltd. | Electronic device with widgets and method for configuring widgets |
CN102520918A (en) * | 2011-09-27 | 2012-06-27 | 深圳市五巨科技有限公司 | Method and device for increasing list refreshing frequency |
Non-Patent Citations (2)
Title |
---|
匿名: "如何保证某个函数只被调用一次", 《博客园网站》 * |
匿名: "解决在onCreate()过程中获取View的width和Height为0的4种方法", 《博客园网站》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8645912B2 (en) | System and method for use in replaying software application events | |
TWI515655B (en) | Method, system, and computer-readable memory for switching threads within routines | |
US9804955B2 (en) | Method and apparatus for creating reference images for an automated test of software with a graphical user interface | |
WO2019144769A1 (en) | Traffic switching method and apparatus, and computer device | |
CN109426415B (en) | Method and device for generating cascade selector | |
CN111047046A (en) | Visual generation method and equipment of machine learning model | |
CN114201144A (en) | Micro service system construction method, device and medium based on domain-driven design | |
CN102231127A (en) | System and method for detecting BIOS (Basic Input Output System) wrong information display | |
CN111728639A (en) | Ultrasonic tangent plane image acquisition method and device, electronic equipment and storage medium | |
CN107729097B (en) | Display page configuration method and corresponding equipment | |
KR101460860B1 (en) | GUI Test apparatus using test scenario model based on states and the method thereof | |
US20210097787A1 (en) | Information presentation method and apparatus | |
CN106325862A (en) | Page initialization method and device based on Android system | |
US20190102148A1 (en) | Development Environment for Real-Time Application Development | |
CN110531972A (en) | The edit methods and device of resource layout Resource Properties | |
CN105468527B (en) | The test method and device of component in a kind of application | |
CN111736748B (en) | Data processing method and device based on map information and electronic equipment | |
EP3528126B1 (en) | Representing a test execution of a software application using extended reality | |
CN109308703B (en) | Intelligent contouring of anatomical structures using structured user click-through points | |
CN112286785A (en) | User interface abnormity detection method and device | |
CN110543304A (en) | Scheme implementation method and device | |
CN110348127B (en) | Method, device, equipment and storage medium for generating test cases | |
CN110519650A (en) | A kind of OSD language upgrade method, apparatus, electronic equipment and storage medium | |
KR20140092596A (en) | System and method for providing service menu based on application service, and apparatus applied to the same | |
CN109117359A (en) | Serialize test method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170111 |