Background technology
Along with the development of mobile Internet, the application of various electric terminals (particularly intelligent mobile terminal) emerges in an endless stream.For the social functions that provides electric terminal to use; Let the user can make things convenient for, share with other people in time the picture in the electric terminal, music etc., the huge customer group of shared social network sites simultaneously; A lot of mobile application have all combined the social network-i i-platform of present main flow; Like Sina's microblogging, everybody net, Facebook (face book) etc.
These with mobile application that the Internet social network sites combines in; Mandate that the user can provide through social network sites in application program and access to content interface are bound the social network sites number of the account; And the content that needs are shared sent to the Internet social network sites platform, share with other people.
Because the social platform in existing the Internet such as Sina's microblogging, everybody nets etc. and to have opened platform interface; The SDK that mobile application can directly provide through platform (Soft Develop Kit; Software development kit) visits the interface that the social network sites platform provides, obtain or push content.
After the mode of sharing of existing electric terminal operating system (such as pacifying tall and erect Android platform etc.) in moving application is user binding social network sites number of the account, content that selected needs are shared and the social network sites that need share.
For sharing this operation of content, the processing scheme in the Android platform application program mainly contains two kinds at present.
Scheme one: application program ejected dialog box when the user began to share, and the prompting user shares operation and begins, and the user need wait for that sharing operation accomplishes, and after sharing the prompted dialog frame and disappearing, carried out subsequent operation again.If the user manually cancels dialog box in this process, then sharing operation can be cancelled simultaneously, and the content of sharing can not be sent to social network sites yet.
Scheme two: similar with first kind of scheme, this mode also can adopt the mode of dialog box to point out the user to share the operation beginning.But when the user need carry out other operations, can cancel this dialog box.At this moment, sharing operation still can proceed in non-UI (User Interface, User Interface) thread.After sharing completion, share the result with Toast (a kind of prompting form in the Android platform) form prompting user.
All there is corresponding shortcoming in above-mentioned two kinds of schemes.
In the scheme one, the user just can carry out other operations after must waiting for that sharing operation accomplishes.Such as the software of taking pictures of a combination social network sites shares if the user has taken a photo, sharing operation still imperfect tense, and the user wants to continue to take pictures, then must the current upload operation of cancellation.Will certainly influence the user experience of software like this.
In the scheme two, the user can select cancellation to share the prompted dialog frame, and program is used a non-UI thread at this moment and continued to accomplish upload operation, and after upload operation was accomplished, program can will be shared operating result (success or failure) with the mode of Toast and inform the user.The benefit of doing like this be exactly the user can share the operation carry out in, carry out other operations.But there are two shortcomings in this mode:
(1) once can only share a content to a social network sites platform.Promptly once share operation and can only a content be shared a social network sites.If carry out perhaps " many to many " (many contents are shared a plurality of social network sites simultaneously) of " one to many " (one content is shared a plurality of social network sites platforms simultaneously), " how to one " (many contents are shared single social network sites simultaneously); Then (some contents are shared success owing to the diversity of sharing operating result; Other contents are shared failure) and complexity, just can't simply will share the operating result accurate description and inform the user with the Toast form.
(2) a plurality of operation contention bandwidth of sharing reduce to share being operable to power.If the user need carry out sharing of " one to many ", " how to one ", " many to many " forms, then must manually cancel the last time and share the operation indicating dialog box, begin the new operation of sharing again.All need open a thread and carry out owing to share operation at every turn,, then can produce a plurality of operation threads of sharing if one or several thread of sharing operation of front is not accomplished and withdrawed from.Be separate between these threads; Need to transfer data to through GPRS (General Packet Radio Service, wireless universal group technology) or WIFI (Wireless Fidelity, WLAN) simultaneously the server of social network sites; Meeting contention data bandwidth between the thread; Cause network to connect time-out error more easily, cause sharing operation failure, have a strong impact on the user experience of application program.
Summary of the invention
Embodiment of the invention technical problem to be solved is, a kind of data sharing method and electric terminal based on the Internet is provided.Solved in the prior art because of a plurality of operation contention bandwidth of sharing, reduced and share the technical problem that is operable to power, and realized to share the result and accurately informed the user in real time, user experience is provided greatly.
In order to solve the problems of the technologies described above, the embodiment of the invention provides a kind of data sharing method based on the Internet, comprising:
Start the serviced component of electric terminal operating system, in the function of said serviced component, accomplish the initialization of sharing mission thread, said initialization comprises setting up and shares task queue and set up the thread synchronization monitor;
Share task object and add the said task queue of sharing to when having monitored, said thread synchronization monitor call function wakes the said mission thread of sharing that is in suspended state up;
Said share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out and share task, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share.
Wherein, the said initialized step of sharing mission thread of in the function of said serviced component, accomplishing also comprises afterwards;
Whether monitoring receives is shared request; Saidly share request and comprise and share content information and share address information;
When monitored results when being, then share request and be packaged into the predefined task object of sharing said;
Add the said task object of sharing to said sharing in the task queue.
Wherein, the said attribute of sharing task object comprises the routing information of sharing content and shares address information; Also comprise: share content description information or/and share temporal information.
Wherein, said share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out the step of sharing task and comprise:
Share when not sharing task object in the task queue when said, said thread synchronization monitor call waiting function makes the said mission thread of sharing get into suspended state.
Wherein, said initialization also comprises the call back function share mission thread is set;
When the said mission thread of sharing is carried out when sharing successfully sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares successful information;
When the said mission thread of sharing is carried out when sharing failure sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares failure information.
Correspondingly, the invention also discloses a kind of electric terminal, comprising:
Start initialization module, be used to start the serviced component of electric terminal operating system, in the function of said serviced component, accomplish the initialization of sharing mission thread, said initialization comprises setting up and shares task queue and set up the thread synchronization monitor;
The thread synchronization monitor is used for sharing task object and adding the said task queue of sharing to when having monitored, and call function wakes the said mission thread of sharing that is in suspended state up;
Choose and share module; Be used for sharing task queue and choosing successively according to sequencing and share task object and carry out and to share task from said, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share through the said mission thread of sharing.
Wherein, said electric terminal also comprises;
Share monitoring module, be used for monitoring whether to receive sharing request; Saidly share request and comprise and share content information and share address information;
The object encapsulation module, be used for when the said monitored results of sharing monitoring module when being, then share request and be packaged into the predefined task object of sharing said;
Object adds module, is used for adding the said task object of sharing to the said task queue of sharing.
Wherein, the said attribute of sharing task object comprises the routing information of sharing content and shares address information; Also comprise: share content description information or/and share temporal information.
Wherein, said thread synchronization monitor also is used for: share task queue when not sharing task object when said, the call waiting function makes the said mission thread of sharing get into suspended state.
Wherein, said initialization also comprises the call back function share mission thread is set; Said electric terminal also comprises:
Notification module is used for carrying out when sharing successfully sharing task object when the said mission thread of sharing, and then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares successful information; When the said mission thread of sharing is carried out when sharing failure sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares failure information.
Embodiment of the present invention embodiment; Has following beneficial effect: share task queue through foundation; By share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out and share task, and the call back function of sharing mission thread is set, in the notice hurdle, inform that the user shares the state of task through the informing mechanism of electric terminal operating system; " one to many " have been realized; " how to one " and " many to many " form share operation, solved in the prior art because of a plurality of and shared operation and fight for bandwidth, the technical problem that is operable to power is shared in reduction; And can accurately inform the user in real time with sharing the result, user experience is provided greatly.
Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Referring to Fig. 1, be the first embodiment flow chart of the data sharing method based on the Internet provided by the invention, this method comprises:
Step S100: start the serviced component of electric terminal operating system, in the function of said serviced component, accomplish the initialization of sharing mission thread, said initialization comprises setting up and shares task queue and set up the thread synchronization monitor;
Particularly, be that Android is that example describes with electric terminal operating system, among the step S100, start an Android Service assembly, and in the onStart of this assembly function, accomplish the initialization of sharing mission thread.Need to prove that after task queue was shared in foundation, this was shared and does not share task in the task queue at this moment, therefore, said thread synchronization monitor can call the wait method, makes this share mission thread and gets into suspended state.
Step S101: share task object and add the said task queue of sharing to when having monitored, said thread synchronization monitor call function wakes the said mission thread of sharing that is in suspended state up;
Step S102: said share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out and share task, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share.
Particularly, the second embodiment flow chart that the present invention is based on the data sharing method of the Internet as shown in Figure 2, this method comprises:
Step S200: start the serviced component of electric terminal operating system, in the function of said serviced component, accomplish the initialization of sharing mission thread, said initialization comprises setting up and shares task queue and set up the thread synchronization monitor;
Step S201: whether monitoring receives is shared request; Saidly share request and comprise and share content information and share address information;
Particularly; The content that user such as need are liked oneself is shared social network sites, the content (can be content of multimedia such as picture, sound) that need select so to share and the network address of the social network sites that need share; Promptly can send and share request, begin to share operation to application program; Further, can be with reference to figure 3 (but being not limited to the embodiment shown in Fig. 3), the user has selected the picture of " setting sun in dormitory corridor " to share, and " Sina's microblogging " and " everybody net " shared in selection.Whether the application program of electric terminal is monitored in real time to receive and is shared request, when monitored results when being, execution in step S202 then, otherwise continue execution in step S201;
Further, the user can also be according to need selecting whether to add some to sharing the descriptive text of content, shares request so and also include and share content description information.
Step S202: asked to be packaged into the predefined task object of sharing said sharing;
Particularly, after the application program of electric terminal receives that this shares request, at first request is packaged into one and preestablishes the task object of sharing of (or definition).This attribute of sharing task object comprises the routing information of sharing content and shares address information; Can also comprise: share content description information or/and share information such as temporal information.
Step S203: add the said task object of sharing to said sharing in the task queue;
Step S204: share task object and add the said task queue of sharing to when having monitored, said thread synchronization monitor call function wakes the said mission thread of sharing that is in suspended state up;
Particularly, can wake up and share mission thread through in the thread simultaneous monitor, calling the notify function.
Step S205: said share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out and share task, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share.
Particularly, after this is shared mission thread and is waken up, just begin constantly from share task queue, to get to share task object, execute the task.This process circulates always, in sharing task queue, no longer includes the new task object of sharing.Share when not sharing task object in the task queue when said, said thread synchronization monitor call waiting function makes the said mission thread of sharing get into suspended state, up to there being the new task object of sharing to be added into and to share task queue.
Need to prove; Among the step S201, when the user to application program click to send share request after, the user can handle other thing immediately; Particularly can be with reference to figure 4; The user can switch to other program interfaces and carry out corresponding operating, shares the mission thread of scheme in the embodiment of the invention and shares operation from carrying out on the backstage, does not influence the user and carries out other operations;
Again further, the embodiment of the invention is accomplished in the function of said serviced component and is shared in the initialization of mission thread, and this initialization also comprises the call back function share mission thread is set; Can in the notice hurdle, inform the user through the Notification mechanism of operating system (is example with Android) with sharing the result in real time, guarantee that the user knows the current operation progress situation of sharing; Specifically can be with reference to figure 5 and Fig. 6; Informing in notice that the user is current in the hurdle among Fig. 5 is carrying out 1 and is sharing task; Accomplished 3, successful 3, click the administration interface of uploading that this notice can get into Fig. 6; Can show specifically that in Fig. 6 who object shares situation, notice hurdle, top can also notify the user to share the operation progress situation in real time:
When the said mission thread of sharing is carried out when sharing successfully sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares successful information; Like " IMG_0177.jpg is to the success of sharing of Sina's microblogging " among Fig. 6;
When the said mission thread of sharing is carried out when sharing failure sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares failure information.
Specified the data sharing method based on the Internet of the embodiment of the invention above, below correspondingly, the electric terminal of the embodiment of the invention be described:
Fig. 7 shows the structural representation of first embodiment of electric terminal of the present invention, and electric terminal 7 comprises: start initialization module 71, thread synchronization monitor 72 and choose and share module 73, wherein
Start the serviced component that initialization module 71 is used to start electric terminal operating system, in the function of said serviced component, accomplish the initialization of sharing mission thread, said initialization comprises setting up and shares task queue and set up the thread synchronization monitor;
Particularly, be that Android is that example describes with electric terminal operating system, start initialization module 71 and start an Android Service assembly, and in the onStart of this assembly function, accomplish the initialization of sharing mission thread.Need to prove that after task queue was shared in foundation, this was shared and does not share task in the task queue at this moment, therefore, thread synchronization monitor 72 can call the wait method, makes this share mission thread and gets into suspended state.
Thread synchronization monitor 72 is used for sharing task object and adding the said task queue of sharing to when having monitored, and call function wakes the said mission thread of sharing that is in suspended state up;
Choose and share module 73 and be used for sharing task queue and choosing successively according to sequencing and share task object and carry out and to share task from said, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share through the said mission thread of sharing.
Further; The structural representation of second embodiment of electric terminal of the present invention as shown in Figure 8; Electric terminal 7 comprises startup initialization module 71, thread synchronization monitor 72 and chooses and share outside the module 73; Can also comprise that sharing monitoring module 74, object encapsulation module 75 and object adds module 76, wherein
Whether share monitoring module 74 is used for monitoring to receive sharing request; Saidly share request and comprise and share content information and share address information;
Particularly; The content that user such as need are liked oneself is shared social network sites, the content (can be content of multimedia such as picture, sound) that need select so to share and the network address of the social network sites that need share; Promptly can send and share request, begin to share operation to application program; Further, can be with reference to figure 3 (but being not limited to the embodiment shown in Fig. 3), the user has selected the picture of " setting sun in dormitory corridor " to share, and " Sina's microblogging " and " everybody net " shared in selection.The sharing monitoring module 74 and will monitor in real time whether to receive and share request of electric terminal 7, when monitored results when being, then trigger object encapsulation module 75 and operate, continue monitoring in real time otherwise share monitoring module 74;
Further, the user can also be according to need selecting whether to add some to sharing the descriptive text of content, shares request so and also include and share content description information.
Object encapsulation module 75 be used for when the said monitored results of sharing monitoring module when being, then share request and be packaged into the predefined task object of sharing said;
Particularly, after electric terminal 7 received that this shares request, object encapsulation module 75 at first was packaged into one with request and preestablishes the task object of sharing of (or definition).This attribute of sharing task object comprises the routing information of sharing content and shares address information; Can also comprise: share content description information or/and share information such as temporal information.
Object adds module 76 and is used for adding the said task object of sharing to the said task queue of sharing.
Share task object and add the said task queue of sharing to when having monitored, thread synchronization monitor 72 call functions wake the said mission thread of sharing that is in suspended state up;
Choose and share module 73 and be used for sharing task queue and choosing successively according to sequencing and share task object and carry out and to share task from said, specifically comprise when said of sharing in the task queue being shared task object and carry out to share and choose the said next one of sharing in the task queue after finishing again and share the task object execution and share through the said mission thread of sharing.
Particularly, after this is shared mission thread and is waken up, choose and share module 73 and just begin constantly from share task queue, to get to share task object, execute the task.This process circulates always, in sharing task queue, no longer includes the new task object of sharing.Share when not sharing task object in the task queue when said, thread synchronization monitor 72 call waiting functions make the said mission thread of sharing get into suspended state, up to there being the new task object of sharing to be added into and to share task queue.
Again further; The structural representation of the 3rd embodiment of electric terminal of the present invention as shown in Figure 9; Electric terminal 7 comprise start initialization module 71, thread synchronization monitor 72, choose share module 73, share monitoring module 74, object encapsulation module 75 and object add outside the module 76; Can also comprise notification module 77, wherein start initialization that initialization module 71 carries out and can also comprise the call back function of sharing mission thread is set;
Notification module 77 is used for carrying out when sharing successfully sharing task object when the said mission thread of sharing, and then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares successful information; When the said mission thread of sharing is carried out when sharing failure sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares failure information.
Particularly, notification module 77 can be informed the user through the Notification mechanism of operating system (is example with Android) with sharing the result in real time in the notice hurdle, guarantee that the user knows the current operation progress situation of sharing; Specifically can be with reference to figure 5 and Fig. 6; Informing in notice that the user is current in the hurdle among Fig. 5 is carrying out 1 and is sharing task; Accomplished 3, successful 3, click the administration interface of uploading that this notice can get into Fig. 6; Can show specifically that in Fig. 6 who object shares situation, notice hurdle, top can also notify the user to share the operation progress situation in real time:
When the said mission thread of sharing is carried out when sharing successfully sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares successful information; Like " IMG_0177.jpg is to the success of sharing of Sina's microblogging " among Fig. 6;
When the said mission thread of sharing is carried out when sharing failure sharing task object, then the informing mechanism through electric terminal operating system shows in the notice hurdle and shares failure information.
In sum; Embodiment of the present invention embodiment has following beneficial effect: share task queue through foundation, by share mission thread from said share the task queue to choose successively according to sequencing share task object and carry out and share task; And the call back function of mission thread is shared in setting; Informing mechanism through electric terminal operating system informs that the user shares the state of task in the notice hurdle, realized " one to many ", " how to one " and " how to many " form share operation; Solved in the prior art because of a plurality of operation contention bandwidth of sharing; Reduce and share the technical problem that is operable to power, and can accurately inform the user in real time, user experience is provided greatly sharing the result.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method; Be to instruct relevant hardware to accomplish through computer program; Described program can be stored in the computer read/write memory medium; This program can comprise the flow process like the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-Only Memory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
Above disclosedly be merely a kind of preferred embodiment of the present invention; Certainly can not limit the present invention's interest field with this; One of ordinary skill in the art will appreciate that all or part of flow process that realizes the foregoing description; And, still belong to the scope that invention is contained according to the equivalent variations that claim of the present invention is done.