CN105847319A - Mobile terminal network request method and system - Google Patents
Mobile terminal network request method and system Download PDFInfo
- Publication number
- CN105847319A CN105847319A CN201610096651.4A CN201610096651A CN105847319A CN 105847319 A CN105847319 A CN 105847319A CN 201610096651 A CN201610096651 A CN 201610096651A CN 105847319 A CN105847319 A CN 105847319A
- Authority
- CN
- China
- Prior art keywords
- network
- mobile terminal
- asynchronous task
- request
- application
- 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/566—Grouping or aggregating service requests, e.g. for unified processing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/40—Support for services or applications
Abstract
The invention discloses a mobile terminal network request method and system. The method comprises that network applications of a mobile terminal receives network requests comprising network request parameter information; the network applications sends the network requests to an asynchronous task comprising a callback function, wherein according to the asynchronous task, the network requests are executed and request result data is downloaded according to the network request parameter information, and the request result data is returned to the network applications by the callback function; the network applications analyze the request result data returned by the callback function, thus obtaining application data. According to the method and the system, the network requests sent by the network applications are received by the asynchronous task; according to the asynchronous task, network access is carried out uniformly; the network access is independent; multiple network applications are avoided from executing the network requests by themselves; the network requests of the mobile terminal can be managed uniformly; disorder is reduced; and the error probability is reduced.
Description
Technical field
The present invention relates to field of mobile terminals, particularly relate to a kind of mobile terminal network requesting method and
System.
Background technology
Mobile terminal, particularly smart mobile phone, have been able to carry out well network access.User
Network is accessed by the various application on mobile terminal.For mobile terminal, due to processor
Limited performance, therefore, its operating system, such as Android system (android), be with a main line
Journey shows the visible view (view) of drafting, and the most any time-consuming network request will be at new line
Processing in journey, the most any time-consuming request is required for processing multithreading, and leads to
Crossing execution cross-thread operation and the result of network request is notified main thread, main thread receives request results
The most also to resolve numerous and jumbled character string, ultimately generate the result that user wants, process is extremely complex,
Amount of redundancy is big.
For an application being full of network request, the network request of magnanimity to be processed,
It is continuously generated new thread, often processes cross-thread operation, it is easy to occur application without response
(application not response, ANR), reduces satisfaction of users.
Summary of the invention
Based on this, it is necessary to complicated in mobile terminal network visiting process for prior art, easily make mistakes
Technical problem, it is provided that a kind of mobile terminal network requesting method and system.
The present invention provides a kind of mobile terminal network requesting method, including:
Network request receiving step, including: the network application of mobile terminal receives and includes that network please
Seek the network request of parameter information;
Asynchronous task download step, including: described network request is sent to wrap by described network application
Including in the asynchronous task of call back function, described asynchronous task is held according to described network request parameter information
The described network request of row downloads request results data, by described request results data by described readjustment
Function returns to described network application;
Network application analyzing step, including: described call back function is returned by described network application
Request results data carry out parsing and are applied data.
Further, described asynchronous task includes single worker thread, and described asynchronous task downloads step
In Zhou, described asynchronous task performs described network request by described worker thread.
Further, described asynchronous task also includes for described worker thread and mobile terminal master
The cross-thread of thread communication processes logic, and described main thread is for enterprising at described mobile terminal screen
Row renders display;
Described network application analyzing step, also includes: described application data are sent out by described network application
Delivering to described asynchronous task, described asynchronous task is called at described cross-thread by described worker thread
Described application data are sent to main thread, by described main thread at described mobile terminal screen by reason logic
The described application data of display are rendered on Mu.
Further, described asynchronous task download step performs on the backstage of described mobile terminal.
Further, described network request parameter information is network address information and content type letter
Breath.
The present invention provides a kind of mobile terminal network Request System, including:
Network request receiver module, is used for: the network application of mobile terminal receives and includes that network please
Seek the network request of parameter information;
Asynchronous task download module, is used for: described network request is sent to bag by described network application
Including in the asynchronous task of call back function, described asynchronous task is held according to described network request parameter information
The described network request of row downloads request results data, by described request results data by described readjustment
Function returns to described network application;
Network application parsing module, is used for: described call back function is returned by described network application
Request results data carry out parsing and are applied data.
Further, described asynchronous task includes single worker thread, and described asynchronous task downloads mould
In block, described asynchronous task performs described network request by described worker thread.
Further, described asynchronous task also includes for described worker thread and mobile terminal main line
The cross-thread of Cheng Tongxin processes logic, and described main thread is for carrying out on described mobile terminal screen
Render display;
Described network application parsing module, also includes: described application data are sent out by described network application
Delivering to described asynchronous task, described asynchronous task is called at described cross-thread by described worker thread
Described application data are sent to main thread, by described main thread at described mobile terminal screen by reason logic
The described application data of display are rendered on Mu.
Further, described asynchronous task download module performs on the backstage of described mobile terminal.
Further, described network request parameter information is network address information and content type letter
Breath.
Implement the embodiment of the present invention, have the advantages that receiving network by asynchronous task answers
With the network request sent, carried out network access by this asynchronous task is unified, thus network is accessed
Independent, it is to avoid multiple network applications perform network request voluntarily so that the network of mobile terminal
Request can be managed collectively, and reduces confusion, reduces error probability.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will
The accompanying drawing used required in embodiment or description of the prior art is briefly described, it is clear that
Ground, the accompanying drawing in describing below is only some embodiments of the present invention, skill common for this area
From the point of view of art personnel, on the premise of not paying creative work, it is also possible to obtain according to these accompanying drawings
Obtain other accompanying drawing.
Fig. 1 is the flow chart of inventive network requesting method;
Fig. 2 is the most preferred embodiment flow chart of Fig. 1;
Fig. 3 is the structural representation of asynchronous task of the present invention management system;
Fig. 4 is the structured flowchart of terminal of the present invention.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, to the technical scheme in the embodiment of the present invention
It is clearly and completely described, it is clear that described embodiment is only that a part of the present invention is real
Execute example rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill
The every other embodiment that personnel are obtained under not making creative work premise, broadly falls into this
The scope of invention protection.
It is illustrated in figure 1 the workflow diagram of the present invention a kind of mobile terminal network requesting method, bag
Include:
Step S101, including: the network application of mobile terminal receives and includes that network request parameter is believed
The network request of breath;
Step S102, including: described network request is sent to include adjusting back letter by described network application
In the asynchronous task of number, described asynchronous task performs described net according to described network request parameter information
Request results data are downloaded in network request, described request results data are returned by described call back function
To described network application;
Step S103, including: the request results that described call back function is returned by described network application
Data carry out parsing and are applied data.
Mobile terminal has multiple application, and wherein certain applications need to access network, i.e. network application.
When user clicks on network application, and when asking to access network by network application, network application obtains
To network request parameter information, generate network request, and perform step S101.Step S101 is called
Asynchronous task, is sent to asynchronous task by network request, includes call back function in this asynchronous task,
The effect of call back function is the application for recording request asynchronous task, thus when triggering readjustment,
Can be by call back function to the application return information asking this asynchronous task.Asynchronous task performs step
S102 completes the network request that network application is generated, and passes through back after obtaining request results data
Letter of transfer number returns to call the network application of asynchronous task.Network application is in step s 103 to request
Result data resolves.
The present invention receives, by asynchronous task, the network request that network application sends, by this asynchronous task
Unification carries out network access, thus is accessed by network independent, it is to avoid multiple network applications are voluntarily
Perform network request so that the network request of mobile terminal can be managed collectively, reduce confusion, reduce
Error probability.Simultaneously as asynchronous task is asynchronous execution network request, therefore network application will
After network request is sent to asynchronous task, other things can be performed, improve efficiency.
Wherein in an embodiment, described asynchronous task includes single worker thread, described step
In S102, described asynchronous task performs described network request by described worker thread.
In the present embodiment, asynchronous task only includes single worker thread, is performed by this worker thread
Network request, owing to using the single-threaded network request that carries out, between the most different network applications,
Cross-thread process can't be carried out, the confusion of network request can be avoided further.
Wherein in an embodiment, described asynchronous task also includes for described worker thread and shifting
The cross-thread of dynamic terminal main thread communication processes logic, and described main thread is at described mobile terminal
Carry out on screen rendering display;
Described step S103, also includes: described application data are sent to described by described network application
Asynchronous task, described asynchronous task calls described cross-thread process logic by described worker thread will
Described application data are sent to main thread, described main thread render on described mobile terminal screen
Show described application data.
It is different from multiple network applications in prior art and performs the cross-line with main thread the most voluntarily
Journey processes logic, and the present embodiment will process logically independent encapsulation with the cross-thread of mobile terminal main thread
In asynchronous task, the unified cross-thread that carries out of asynchronous task process logic, avoid further reducing
The risk that cross-thread processes, reduces probability ANR occur, improves user satisfaction.
Wherein in an embodiment, described step S102 performs on the backstage of described mobile terminal.
In the present embodiment, asynchronous task the backstage of mobile terminal perform network request, reduce to
The interference at family.
Preferably, described network request parameter information is network address information and content-type information.
Wherein, network address information be also referred to as uniform resource locator (Uniform Resource Locator,
URL)。
It is the workflow diagram of preferred embodiment as described in Figure 2, including:
Step S201, network application 21 generates network request;
Concrete, this network request includes network request parameter information, in the middle of specific implementation process,
This network request parameter information is that network address information is also referred to as uniform resource locator (Uniform
Resoure Locator, URL) and content-type information;
Step S202, network application 21 instantiation asynchronous task 22, and network request is sent to
Asynchronous task, specific as follows:
New ThemeSummariesTask (context, callback,
params).executeOnExecutor(ThemeSummariesTask.THREAD_POOL_EXEC
UTOR), the asynchronous task during wherein ThemeSummariesTask is the present embodiment;
Step S203, asynchronous task 22 downloads web data according to network request from server 24,
Generate request results data;
Concrete, system performs asynchronous task in the worker thread of asynchronous task on backstage
DoInBackground method, sets up network in doInBackground method and connects, perform net
Network is asked;
Perform network request, first determine network request method according to different network request contents,
Then set up network according to URL to connect, from network connects, obtain network response, if response is just
Often, then then resolve network response;
Set up the method that network connects, including:
Configuration connects time-out time;
In the head of the Http request of network connection, add the content-type information (ratio of required parameter
Such as JSON or XML), such as the required parameter of JSON form is joined in request body,
JSON form is as follows:
From network connects, open inlet flow, from inlet flow, obtain network response message, i.e. obtain
The information returned from server, such as wallpaper apply the description etc. of asked wallpaper, concrete, logical
Cross the URL of paging process class (EntityLoader) the process paging request that data are downloaded, then lead to
Cross request response (doRequest) method of network request instrument (HttpUrlConnectionUtil)
URL request parameter is put in network request and does corresponding network request, download web data, and
Generate request results data;
Step S204, asynchronous task 22 should to network by the transmission of request results data by call back function
With 21;
Step S205, network application 21 resolves described request results data, the data letter needed for acquisition
Breath;
Concrete, resolve class (EntityParser) analysis request number of results by network request result
According to, the application data message needed for acquisition;
Step S206, application data message is sent to asynchronous task 22 by network application 21;
Step S207, asynchronous task 22 calls onPostExecute method notice interface (User
Interface, UI) main thread 23;
Step S208, main thread display application data message.
It is illustrated in figure 3 one mobile terminal network Request System of the present invention, including:
Network request receiver module 301, is used for: the network application of mobile terminal receives and includes network
The network request of required parameter information;
Asynchronous task download module 302, is used for: described network request is sent to by described network application
Including in the asynchronous task of call back function, described asynchronous task is according to described network request parameter information
Perform described network request and download request results data, by described request results data by described time
Letter of transfer number returns to described network application;
Network application parsing module 303, is used for: described call back function is returned by described network application
Request results data carry out parsing and be applied data.
Wherein in an embodiment, described asynchronous task includes single worker thread, described asynchronous
In task download module, described asynchronous task performs described network request by described worker thread.
Wherein in an embodiment, described asynchronous task also includes for described worker thread and shifting
The cross-thread of dynamic terminal main thread communication processes logic, and described main thread is at described mobile terminal
Carry out on screen rendering display;
Described network application parsing module, also includes: described application data are sent out by described network application
Delivering to described asynchronous task, described asynchronous task is called at described cross-thread by described worker thread
Described application data are sent to main thread, by described main thread at described mobile terminal screen by reason logic
The described application data of display are rendered on Mu.
Wherein in an embodiment, described asynchronous task download module is after described mobile terminal
Platform performs.
Wherein in an embodiment, described network request parameter information is network address information and interior
Hold type information.
Being illustrated in figure 4 the structured flowchart of terminal of the present invention, it specifically includes that processor 401, deposits
Reservoir 402 and communications component 403 etc..In general, the mobile terminal of the present invention is preferably intelligence
Mobile phone.
Memorizer 402 wherein stores the specific code of preceding method, processor 401 specifically holds
OK, communications component 403 communicates with server.
Above disclosed only one preferred embodiment of the present invention, can not limit with this certainly
Determine the interest field of the present invention, the equivalent variations therefore made according to the claims in the present invention, still belong to this
The scope that invention is contained.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not take off
From the spirit and scope of the present invention.So, if these amendments of the present invention and modification belong to this
Within the scope of bright claim and equivalent technologies thereof, then the present invention be also intended to comprise these change and
Including modification.
Claims (10)
1. a mobile terminal network requesting method, it is characterised in that including:
Network request receiving step, including: the network application of mobile terminal receives and includes that network please
Seek the network request of parameter information;
Asynchronous task download step, including: described network request is sent to wrap by described network application
Including in the asynchronous task of call back function, described asynchronous task is held according to described network request parameter information
The described network request of row downloads request results data, by described request results data by described readjustment
Function returns to described network application;
Network application analyzing step, including: described call back function is returned by described network application
Request results data carry out parsing and are applied data.
Mobile terminal network requesting method the most according to claim 1, it is characterised in that institute
State asynchronous task and include single worker thread, in described asynchronous task download step, described asynchronous
It is engaged in performing described network request by described worker thread.
Mobile terminal network requesting method the most according to claim 2, it is characterised in that institute
State asynchronous task also to include at the cross-thread that described worker thread communicates with mobile terminal main thread
Reason logic, described main thread is for carrying out rendering display on described mobile terminal screen;
Described network application analyzing step, also includes: described application data are sent out by described network application
Delivering to described asynchronous task, described asynchronous task is called at described cross-thread by described worker thread
Described application data are sent to main thread, by described main thread at described mobile terminal screen by reason logic
The described application data of display are rendered on Mu.
4. according to the mobile terminal network requesting method described in any one of claim 1-3, its feature
Being, described asynchronous task download step performs on the backstage of described mobile terminal.
5. according to the mobile terminal network requesting method described in any one of claim 1-3, its feature
Being, described network request parameter information is network address information and content-type information.
6. a mobile terminal network Request System, it is characterised in that including:
Network request receiver module, is used for: the network application of mobile terminal receives and includes that network please
Seek the network request of parameter information;
Asynchronous task download module, is used for: described network request is sent to bag by described network application
Including in the asynchronous task of call back function, described asynchronous task is held according to described network request parameter information
The described network request of row downloads request results data, by described request results data by described readjustment
Function returns to described network application;
Network application parsing module, is used for: described call back function is returned by described network application
Request results data carry out parsing and are applied data.
Mobile terminal network Request System the most according to claim 6, it is characterised in that institute
State asynchronous task and include single worker thread, in described asynchronous task download module, described asynchronous
It is engaged in performing described network request by described worker thread.
Mobile terminal network Request System the most according to claim 7, it is characterised in that institute
State asynchronous task also to include at the cross-thread that described worker thread communicates with mobile terminal main thread
Reason logic, described main thread is for carrying out rendering display on described mobile terminal screen;
Described network application parsing module, also includes: described application data are sent out by described network application
Delivering to described asynchronous task, described asynchronous task is called at described cross-thread by described worker thread
Described application data are sent to main thread, by described main thread at described mobile terminal screen by reason logic
The described application data of display are rendered on Mu.
9. according to the mobile terminal network Request System described in any one of claim 6-8, its feature
Being, described asynchronous task download module performs on the backstage of described mobile terminal.
10. according to the mobile terminal network Request System described in any one of claim 6-8, its feature
Being, described network request parameter information is network address information and content-type information.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610096651.4A CN105847319A (en) | 2016-02-22 | 2016-02-22 | Mobile terminal network request method and system |
PCT/CN2016/097007 WO2017143747A1 (en) | 2016-02-22 | 2016-08-26 | Network request method and system for network terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610096651.4A CN105847319A (en) | 2016-02-22 | 2016-02-22 | Mobile terminal network request method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105847319A true CN105847319A (en) | 2016-08-10 |
Family
ID=56586905
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610096651.4A Pending CN105847319A (en) | 2016-02-22 | 2016-02-22 | Mobile terminal network request method and system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN105847319A (en) |
WO (1) | WO2017143747A1 (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107015871A (en) * | 2016-12-07 | 2017-08-04 | 阿里巴巴集团控股有限公司 | A kind of data processing method and device |
WO2017143747A1 (en) * | 2016-02-22 | 2017-08-31 | 乐视控股(北京)有限公司 | Network request method and system for network terminal |
CN107368377A (en) * | 2017-06-30 | 2017-11-21 | 武汉斗鱼网络科技有限公司 | Network request processing method and processing device in a kind of Android application programs |
CN108063713A (en) * | 2016-11-09 | 2018-05-22 | 北京国双科技有限公司 | A kind of processing method and processing device of network request |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112887390B (en) * | 2021-01-20 | 2023-02-17 | 上海易校信息科技有限公司 | Network request method |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101290746A (en) * | 2008-06-18 | 2008-10-22 | 北京工业大学 | Image updating method of electronic paper screen |
CN103760966A (en) * | 2013-05-02 | 2014-04-30 | 乐视网信息技术(北京)股份有限公司 | Picture buffering implementation method |
CN104714835A (en) * | 2013-12-16 | 2015-06-17 | 中国移动通信集团公司 | Data access processing method and device |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8713571B2 (en) * | 2010-02-17 | 2014-04-29 | Microsoft Corporation | Asynchronous task execution |
CN103064690B (en) * | 2012-12-16 | 2016-09-07 | 互动在线(北京)科技有限公司 | A kind of Development Framework based on Android operation system and the method for execution thereof |
CN105847319A (en) * | 2016-02-22 | 2016-08-10 | 乐视移动智能信息技术(北京)有限公司 | Mobile terminal network request method and system |
-
2016
- 2016-02-22 CN CN201610096651.4A patent/CN105847319A/en active Pending
- 2016-08-26 WO PCT/CN2016/097007 patent/WO2017143747A1/en active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101290746A (en) * | 2008-06-18 | 2008-10-22 | 北京工业大学 | Image updating method of electronic paper screen |
CN103760966A (en) * | 2013-05-02 | 2014-04-30 | 乐视网信息技术(北京)股份有限公司 | Picture buffering implementation method |
CN104714835A (en) * | 2013-12-16 | 2015-06-17 | 中国移动通信集团公司 | Data access processing method and device |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2017143747A1 (en) * | 2016-02-22 | 2017-08-31 | 乐视控股(北京)有限公司 | Network request method and system for network terminal |
CN108063713A (en) * | 2016-11-09 | 2018-05-22 | 北京国双科技有限公司 | A kind of processing method and processing device of network request |
CN108063713B (en) * | 2016-11-09 | 2021-02-12 | 北京国双科技有限公司 | Network request processing method and device |
CN107015871A (en) * | 2016-12-07 | 2017-08-04 | 阿里巴巴集团控股有限公司 | A kind of data processing method and device |
CN107368377A (en) * | 2017-06-30 | 2017-11-21 | 武汉斗鱼网络科技有限公司 | Network request processing method and processing device in a kind of Android application programs |
CN107368377B (en) * | 2017-06-30 | 2020-03-17 | 武汉斗鱼网络科技有限公司 | Network request processing method and device in Android application program |
Also Published As
Publication number | Publication date |
---|---|
WO2017143747A1 (en) | 2017-08-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105847319A (en) | Mobile terminal network request method and system | |
US20200285508A1 (en) | Method and Apparatus for Assigning Computing Task | |
CN108279882B (en) | Framework generation method, device, equipment and computer readable medium | |
CN109656799B (en) | Test method and device | |
CN108023905B (en) | Internet of things application system and method | |
CN108958933B (en) | Configuration parameter updating method, device and equipment of task executor | |
CN113760438A (en) | Page display method and device for webpage application | |
CN107395663B (en) | Data acquisition method and device | |
CN113806216A (en) | Interface test method, device, medium and equipment | |
CN111414154A (en) | Method and device for front-end development, electronic equipment and storage medium | |
CN111767149A (en) | Scheduling method, device, equipment and storage equipment | |
CN113282444A (en) | Visualization method and device for business process debugging | |
CN111338928A (en) | Chrome-based browser testing method and device | |
CN115811481A (en) | Interactive service testing method and device, computer equipment and storage medium | |
CN109344353A (en) | A kind of the local cache method for refreshing and terminal of configurableization | |
CN114625458A (en) | Page data processing method and device, electronic equipment and storage medium | |
CN114301970A (en) | Service calling method and device, electronic equipment and storage medium | |
CN114490318A (en) | Environment management system and method for realizing weak isolation based on bytecode enhancement | |
CN114064176A (en) | View interaction method and device, electronic equipment and computer readable medium | |
CN113779122A (en) | Method and apparatus for exporting data | |
CN111401020A (en) | Interface loading method and system and computing equipment | |
CN111400060A (en) | Equipment linkage method, device, server and medium | |
CN104978199A (en) | Plug-in application method and device used for multiple browsers | |
CN111124523A (en) | Method and apparatus for initializing applications | |
CN113760487B (en) | Service processing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20160810 |