Invention content
In view of above-mentioned deficiencies of the prior art, the purpose of the present invention is to provide a kind of domain names of intelligent terminal application program
Dynamic switching method and intelligent terminal, it is intended to solve in the prior art intelligent terminal application program can not switching at runtime domain name ask
Topic.
Technical scheme is as follows:
A kind of domain name dynamic switching method of intelligent terminal application program, wherein, including step:
A, acquiescence domain name is defined in a manner of hard coded in application program;
B, server storage domain name file, and provide download address to application program beyond the clouds;
C, when application program starts for the first time, acquiescence domain name is read, while domain name text is downloaded according to the download address
Then part parses domain name file and obtains new domain name therein and preserve;
D, when application program is restarted, current domain name is replaced using the new domain name preserved.
The domain name dynamic switching method of the intelligent terminal application program, wherein, it is further included after the step D:
E, continue to download new domain name file to cloud server, and parse new domain name file acquisition neofield therein
Name, and current domain name is replaced using new domain name.
The domain name dynamic switching method of the intelligent terminal application program, wherein, the step E is specifically included:
E1, continue to download new domain name file to cloud server, parse new domain name file acquisition new domain name therein
And it preserves;
E2, when reactivating application program, current domain name is matched with the new domain name locally preserved, if consistent
Flow terminates, and current domain name is replaced using new domain name if inconsistent.
The domain name dynamic switching method of the intelligent terminal application program, wherein, it is current replacing in the step D
After domain name, all data for relying on current domain name, and the re-request data on the basis of new domain name are discharged.
The domain name dynamic switching method of the intelligent terminal application program, wherein, in the step B, to domain name file
It is encrypted, and the outside access link of exposure domain name file.
The domain name dynamic switching method of the intelligent terminal application program, wherein, in the step C, to domain name file
It is decrypted and obtains new domain name therein and preserve.
The domain name dynamic switching method of the intelligent terminal application program, wherein, using persistence preserving type to new
Domain name is preserved.
The domain name dynamic switching method of the intelligent terminal application program, wherein, the step D is specifically included:
D1, when application program is restarted, whether detection is local preserves workable new domain name, is entered step if having
D2, flow terminates if nothing;
D2, new domain name is read, and current domain name is replaced using new domain name.
The domain name dynamic switching method of the intelligent terminal application program, wherein, it is encrypted using symmetry algorithm.
A kind of intelligent terminal, wherein, including:
Processor, be adapted for carrying out each instruction and
Storage device, suitable for storing a plurality of instruction, described instruction is suitable for being loaded and being performed by processor:
Acquiescence domain name is defined in a manner of hard coded in application program;
When application program starts for the first time, acquiescence domain name is read, while download according to the download address of cloud server
The domain name file of cloud server is stored in, then parse domain name file and obtains new domain name therein and preserves;
When application program is restarted, current domain name is replaced using the new domain name preserved.
Advantageous effect:By the method for the present invention, after application issued, still can be specified by way of being configured
The domain name of arbitrary background server realizes the domain name switching at runtime function of intelligent terminal application program.
Specific embodiment
The present invention provides a kind of the domain name dynamic switching method and intelligent terminal of intelligent terminal application program, to make the present invention
Purpose, technical solution and effect it is clearer, clear and definite, the present invention is described in more detail below.It should be appreciated that this place
The specific embodiment of description is only used to explain the present invention, is not intended to limit the present invention.
Referring to Fig. 1, Fig. 1 is a kind of domain name dynamic switching method preferred embodiment of intelligent terminal application program of the present invention
Flow chart, as shown in the figure, it includes step:
S1, acquiescence domain name is defined in a manner of hard coded in application program;
S2, beyond the clouds server storage domain name file, and download address is provided to application program;
S3, application program for the first time start when, read acquiescence domain name, while according to the download address download domain name text
Then part parses domain name file and obtains new domain name therein and preserve;
S4, when application program is restarted, current domain name is replaced using the new domain name that has preserved.
The present invention, when restarting, uses downloaded new domain name by using acquiescence domain name when starting first time,
In this way after application issued, it is nonetheless possible to use arbitrary new domain name, so as to fulfill switching at runtime domain name.
Specifically, in the step S1, the present invention defines acquiescence domain name first in application program in a manner of hard coded,
The acquiescence domain name is used when application program starts for the first time.Further, the acquiescence domain name is alternatively arranged as unsuccessfully abnormal standby
With, i.e., in subsequent step if new domain name failure is downloaded using default domain name as spare.
That is, the value that acquiescence domain name enables can not be changed, can not be erased.Its effect has two:First, using journey
Sequence uses when starting for the first time;Second is that when pulling dynamic domain name failure, as spare domain name.
In the step S2, server storage domain name file, and provide download address to application program beyond the clouds.
Cloud server therein can be third party's cloud server, i.e., do not corresponded to for the domain name involved in the present invention arrived
Server.The address of third party's cloud server will not be changed in this way, facilitate application program that can get at any time
Newest domain name file.
Such as server storage portion hostname files (domain name file) beyond the clouds, the domain name that needs switch is written to
In this document, and download address is provided to application program
Foundation is configured for dynamic domain name in domain name file, and the domain name (i.e. new domain name) that need to switch is written in the inner.Preferably, it is right
Domain name file is encrypted, and may insure the safety of domain name file in this way.That is, when domain name is written, pacify to ensure
It should be written entirely with ciphertext.Encryption method selects the symmetric encipherment algorithm of any maturation.After the completion of write-in, by domain name file
Outside access link be exposed, application program can be accessed and downloads.
In the step S3, when application program starts for the first time, acquiescence domain name is read.Download ground according to described simultaneously
Domain name file is downloaded in location, then parses domain name file and obtains new domain name therein and preserve.
Specifically, using the acquiescence domain name after acquiescence domain name is read, hereafter the server-side of entire application program is related
Request is all initiated based on default domain name.
After cloud server is accessed, domain name file is downloaded, if downloaded successfully, domain name file is decrypted, example
It is such as decrypted using symmetry algorithm, obtains new domain name therein, and preserve obtained new domain name.If failed download, keep existing
There is acquiescence domain name, do not make any change.
When being preserved to new domain name, persistence preservation is preferably carried out to new domain name, is such as protected in the method for shell adding packaging
It is stored in the memory space of application program, it is ensured that new domain name will not be lost.Specifically, it is comparatively safe to achieve the purpose that, such as
Filing storage can be used, can also store sqlite databases.
In the step S4, when application program is restarted, current domain name is replaced (herein using the new domain name preserved
Current domain name i.e. give tacit consent to domain name).
Specifically, the step S4 is specifically included:
S41, when application program is restarted, whether detection is local preserves workable new domain name, and step is entered if having
Rapid S42, flow terminates if nothing;
S42, new domain name is read, and current domain name is replaced using new domain name.
In the step S41, when application program is restarted, whether detection is local preserves workable new domain name,
It successfully or not necessarily can be used because the domain name file downloaded not necessarily is downloaded before, local whether preserve need to be detected
Workable new domain name, if yes then enters step S42, can directly terminate flow if nothing.
In the step S42, new domain name is read, then current domain name is replaced using new domain name, that is, gives tacit consent to domain name.
It after current domain name is replaced, gives notice to entire application program, discharges all data for relying on current domain name, and
The re-request data on the basis of new domain name.
That is, after current domain name is replaced, the server-side association requests of entire application program are all with the entitled base of neofield
Plinth is initiated, and achievees the purpose that switch domain name.So replacing domain name should be happened at before all server-side requests, holding for domain name is replaced
Row major grade should be set as high-level.
Further, it is further included after the step S4:
S5, continue to download new domain name file to cloud server, and parse new domain name file acquisition neofield therein
Name, and current domain name is replaced using new domain name.
After domain name is replaced, the hostname files that cloud server is downloaded in request are also continued to.If there is new domain name text
Part then downloads, and carries out parsing and obtain new domain name therein.The domain name file of this step and the domain name file in step S2
Difference is newest domain name file.
That is, the domain name file that can be stored to cloud server arbitrary when is updated, apply in this way
Program all can download newest domain name file to high in the clouds in the process of running, so as to obtain wherein newest domain name.
After new domain name file is downloaded to, it is decrypted, then obtains new domain name, aforementioned similar side can be used
Method is updated and replaces to current domain name.
Specifically, the step S5 is specifically included:
S51, continue to download new domain name file to cloud server, parse new domain name file acquisition new domain name therein
And it preserves;
S52, when reactivating application program, current domain name is matched with the new domain name locally preserved, if unanimously
Then flow terminates, and current domain name is replaced using new domain name if inconsistent.
In the step S51, new domain name file is downloaded, and it is therein that acquisition is decrypted to cloud server request
Then new domain name carries out persistence preservation, for example filing storage can be used, and can also store sqlite databases.
In the step S52, when reactivating application program, by the new domain name preserved and the progress of current domain name
Match, need not be updated if consistent, if inconsistent replace current domain name (the as step of current domain name herein using new domain name
The new domain name used in rapid S4).
It after the completion of current domain name is replaced, gives notice to entire application program, discharges all data for relying on former domain name,
Re-request data on the basis of the domain name newly replaced.
The application program that reactivates in the step S52 refers to:Application program is suspended, intelligent terminal return desktop or
Other application, when then reactivating application program again;It can certainly refer to restart application program.
In addition, it should be noted that, due to that server can be updated beyond the clouds to domain name file in the present invention, to apply
Program gets newest domain name, and the present invention is preferably identified the new domain name downloaded to, is convenient for subsequently being compared in this way
And matching, thereby using newest domain name.Such as version identifier or time identifier can be added, such as the new domain name of first time
Labeled as V1.0, secondary new domain name is labeled as V1.1, and the new domain name of third time is labeled as V1.2, and so on;Or the
Primary new domain name is labeled as V2017.9.26, and secondary new domain name is labeled as V2017.10.12, the neofield identifier of third time
It is denoted as V2017.10.22, and so on.These new domain names persistence can be stored in the memory space of application program simultaneously,
After downloading to new domain name, currently used domain name with the new domain name downloaded is matched, whether judges currently used domain name
For new domain name.
The process of comparison match can be all performed during to avoid reactivating application program every time, can be downloaded to detecting
New domain name and while reactivating application program is matched, so as to improve efficiency.
The present invention also provides a kind of intelligent terminal, including:
Processor, be adapted for carrying out each instruction and
Storage device, suitable for storing a plurality of instruction, described instruction is suitable for being loaded and being performed by processor:
Acquiescence domain name is defined in a manner of hard coded in application program;
When application program starts for the first time, acquiescence domain name is read, while download according to the download address of cloud server
The domain name file of cloud server is stored in, then parse domain name file and obtains new domain name therein and preserves;
When application program is restarted, current domain name is replaced using the new domain name preserved.
The processor can be general processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), show
It is field programmable gate array (FPGA), microcontroller, ARM (Acorn RISC Machine) or other programmable logic device, discrete
Any combinations of door or transistor logic, discrete hardware component or these components.In addition, processor can also be any biography
System processor, microprocessor or state machine.Processor can also be implemented as the combination of computing device, for example, DSP and microprocessor
Combination, multi-microprocessor, one or more microprocessors combination DSP core or any other this configuration of device.
Storage device is as a kind of non-volatile computer readable storage medium storing program for executing, available for storing non-volatile software journey
Sequence, non-volatile computer executable program and module, as the domain name dynamic switching method in the embodiment of the present invention is corresponding
Program instruction.Processor is stored in non-volatile software program, instruction and unit in storage device by operation, so as to hold
The domain name switching at runtime in above method embodiment is realized in the various function application of Mobile state domain name switching and data processing
Method.
In conclusion by the method for the present invention, after application issued, still can be specified by way of being configured
The domain name of arbitrary background server realizes the domain name switching at runtime function of intelligent terminal application program.
It should be understood that the application of the present invention is not limited to the above, it for those of ordinary skills, can
To be improved or converted according to the above description, all these modifications and variations should all belong to the guarantor of appended claims of the present invention
Protect range.