Summary of the invention
The graph text information feedback system fortune core function of Android is independent of third-party server, merely with existingThere is local area network to realize multimedia communication of multiple clients for running on Android 7.1.1 to a server, it can be timelyThe graph text information of client is fed back into server.Using concentrated meeting model and C/S (Client/Server, visitorFamily end/server) software architecture, client and server are all made of the intelligent movable equipment of Android7.1.1 version.The Android device is to possess the running memory of 4GB based on valiant imperial 625 processor of high pass, 1920*1200 resolution display,It is equipped with 8,000,000 pixel camera heads simultaneously, supports double frequency WIFI.Its specific embodiment is as follows: a kind of based on Android'sThe design of graph text information feedback system includes two dimensional code unit, client suspension push-button unit, Socket communication unit, serverPicture and text showing unit and server local picture library unit.
Its IP address in WLAN is generated two-dimension code image in server end by two dimensional code unit, and client is logicalThe foundation that the two dimensional code obtains the IP address of server and port number information is Socket communication is over-scanned to prepare.
The client suspension push-button unit, which can create a key, makes it be suspended in entire screen, and gesture is supported to graspMake that the operation such as it can be pulled, click.Suspension key is clicked, screenshotss behaviour will be carried out to client present displayed contentMake, generates Bitmap image.
The Socket communication unit is after client obtains server end IP address and port numbers, it is established that SocketCommunication, and by the information such as client sending information and picture.Server is receiving the picture from clientIt is stored to after file in storage.
The server picture and text showing unit shows the situation of registering of client in the form of a list respectively;What text was shownForm shows communications progress and source client user name;Picture shows that control shows picture and can put to itGreatly, it reduces.Translation is checked.
The server local picture library unit can be opened by server key, browse local picture library, and picture is chosenIt is shown on screen afterwards.
As a kind of design scheme, the client and server two dimensional code unit are divided into two parts realization.In server end,Core function is mainly completed to realize in GenerateQRCode class dependent on the Zxing integrated in Java core packet.FirstOne step seeks to the IP address by WifiManager case-based system server itself, and IP address is carried out encode later, rawAt monochrome pixels two-dimensional matrix, and generate Bitmap format two-dimension code image.It is integrated with Google's in client, engineeringZxing open source library, and pass through Intent and open rear camera unlatching CaptureActivity two-dimensional code scanning interface.
As a kind of design scheme, the client suspension push-button unit will acquire the SYSTEM_ of WindowManagerThe highest permission of ALERT_WINDOW can be suspended in screen.Again by pairThe parameter of WindowManager.LayoutParams configures suspension key.It joined to GesturDetector'sSupport enables key to monitor and identify gesture operation.Screen message realization is obtained by virtualDispay to cutFigure, converts thereof into Bitmap format and is stored in external storage with the format of png.
As a kind of design scheme, communication unit is realized by the short connection of Socket between the client and server.Server end creates a ServerSocket object and waits the connection request of client by accept method.Client existsAfter getting the IP address and port numbers of server, Socket connection request is sent to server and sets up Socket communication pair.Socket communication unit mainly realizes the transmission of text information and picture file.Server receive client picture file atAfter function, it is stored by file I/O stream into the specified folder of external storage.
As a kind of design scheme, the server picture and text showing unit shows the label of client using ListView controlTo situation, shows that Socket communication progress and server receive the source of picture using TextView control, use PhotoViewControl is shown as picture, and the load to picture is realized by Glide picture loading frame.The design uses Handler machineSystem realizes the update in communication thread to the interface UI of main thread.
As a kind of design scheme, this map office of the server local picture library unit is by creation oneACTION is set as ACTION_PICK, purpose be the Intent object of MediaStore and start the Intent realize open,Browsing function.Meanwhile the company between the object and picture library is established by MediaScannerConnectionClient objectIt connects, readjustment onMediaScannerConnected method is scanned picture library, realizes the real-time update function of picture library.
After above-mentioned design scheme, the beneficial effects of the present invention are:
Realize multiple client to more matchmakers of a server independent of third-party server, merely with existing local area networkThe screenshotss image information of client timely can be fed back to server by body communication.The record third party's service such as effectively preventDevice realizes the redundant operation of communication, while the network risks such as leaking data, loss of data are greatly reduced, and communicates more stableQuickly.Android device used in this secondary design is run based on valiant imperial 625 low-end microprocessor of high pass and 4GB simultaneously,It is low in cost and easy to carry, it can be used, be had higher in wider scene while the cost of the system of reductionPractical significance.
Specific embodiment
Explanation, but these examples will be further expalined to summary of the invention in conjunction with attached drawing and some examples in the following contentsOnly it is used to enumerate the present invention with the purposes and purpose of attached drawing, any type of not is constituted to real protection scope of the inventionWhat is limited, more non-that protection scope of the present invention is confined to this.
The design for shown in Fig. 1 being a kind of graph text information feedback system based on Android includes two dimensional code unit, clientSuspension push-button unit, Socket communication unit, server picture and text showing unit and server local picture library unit.
The two dimensional code unit is that client is divided in WLAN by what scanning server generated containing serverThe image in 2 D code for the IP address matched, to obtain the IP address information.
The client suspension push-button unit can be suspended in full frame, while can lead to gesture and the operation such as be pulled, clicked.It clicks suspension key and can intercept client current screen and show.
The Socket communication unit is enabled the client to as server end sending information information and picture file.TextInformation, which is mainly user name and the IP address of client, a little shows that picture file is then to function and picture file source to realizeThe screenshot picture of client.Server is saved in external storage after picture finishes receiving.
The server picture and text showing unit has mainly registered user's list of file names, picture transfer progress and figure to clientPiece display area three parts.Picture display area is used to show schemes in the screenshot picture of client and this map officePiece.
The server local picture library unit can open this map office and be browsed by server key, choose a certainIt is shown on screen after picture.Meanwhile it often receiving the screenshot picture from client and will actively update onceThis map office.
Fig. 2 is that the two dimensional code of server generates and client is registered statistical information interface.Server uses 1920*1200 resolution ratio show screen, and the interface UI is divided into two pieces of left and right, and upper left setting has registered two dimension there are two key respectivelyCode systematic function and interface turn function;One TextView control is used to show the number of registering counted on;Lower-left is provided withOne LIstView control shows specific client user's name with sliding list;Right side is arranged an ImageView and controlsPart, for showing the two-dimension code image of generation.
Function of registering is realized to the user name and IP address of server transmission client.One is first created in serverHashMap, user name are placed in Adapter the value that HashMap is also used as while showing on ListView, clientIP address be then as client unique identification as HashMap key.By the IP of client that judges newly to registerWhether location is present in the key of HashMap to ensure that each client can only be signed and once arrive.
Fig. 3 a is the two-dimensional code scanning interface of client, by by key control open 8,000,000 pixels rear camera intoRow scan operation.It is integrated into project by this open source projects by Zxing.CaptureActivity is that Zxing is supplied toUser recalls the API at scanning interface, is integrated with initialization camera, decoding and returns a series of processes such as data.Exist firstPermission dynamic is applied when registering camera permission and operation in AndroidManifest.Later, it is jumped to by IntentCaptureActivity, that is, openable rear camera opens scanning interface.
Fig. 3 b is that client sweeps the interface after taking result return information, it can be seen that client is with obtaining the IP of serverThe port numbers of location and Socket communication.The scanning result data result adjusted back in CaptureActivity passes throughThe parameter data of onActivityResult is transmitted to former activity, and by that will scan the address IP and port numbers point that parsing obtainsAt two String objects of IP address and port numbers.
Fig. 4 is customized picture file transport protocol in Socket communication unit.Complete picture is transmitted in system designFile is completed in a Socket connection, the simple association of oneself setting one Collaboration Server and client transmissions picture fileView.Agreement provides that the content of Socket connection transmission is artificially divided into 3 parts:
First part: the reception of filename length uses DataInputStream.When server end is from clientAfter Socket receives InputStream, InputStream is first packaged into DataInputStream, and pass through readIntMethod reads first header data, and is converted into an Int type data.So far the filename of picture file has been gotLength.
Second part: the byte arrays of one with filename equal length were established in the reception of filename before this, were passed through laterThe read method of InputStream reads the 2nd of entire inlet flow to the byte between (2+ filename length), this partial contentJust corresponding to the name of picture file.Byte arrays are converted into String later and have just obtained required filename.
Part III: the buffering byte arrays that a length is 1024 are founded in the reception display of file, later with the arrayThe data in InputStream are constantly read for unit until all data all read completion.
Fig. 5 a is the interface that client screenshotss key is suspended in other application.The SYSTEM_ of WindowManagerALERT_WINDOW, which is set as highest priority, makes it be suspended in screen, simultaneously because suspension push-button unit is in Service componentIt completes, so that it still is able to exist at the interface of other application.
Fig. 5 b is display interface of the server picture and text showing unit after receiving the screenshotss image of client.TextView control shows the reception progress of picture file and the source of file (in the form of user name).The change of content is thenBy upDateUI method, the interface UI is changed using Handler message mechanism.
Fig. 5 c is that server amplifies to picture, reduces and translate the demonstration graph checked.PhotoView picture is aobviousShow that region is the main undertaker of pictorial information, his ImageView carried out the zoom of function gesture operation control picture withThe reinforcement of the functions such as smooth movement.The load of picture is then to have used Glide picture loading frame.
Fig. 6 is the surface chart that server browses this map office.This map office is opened by Intent realization's.Creating an Intent object and its ACTION is arranged is ACTION_PICK, and purpose starts after being MediaStoreIntent.MidiaStore's returns the result the Uri that type is picture file, this result will be returned in onActivityResultBitmap image is converted thereof into tune method, and is shown on PhotoView control.It receives every time from clientPicture is simultaneously stored to local, requires manually to be updated picture library.
Fig. 7 is the program chart of server end.The necessary condition for establishing Socket connection as seen from the figure is that client obtainsThe IP address and port numbers of server end.Server is obtained from the IP address of body in a wlan first, and its content is integrated and is given birth toAt the picture comprising these information, it is shown on ImageView control.ServerSocket object is created simultaneously waits clientThe information of registering at end, and it is primary using the not reproducible featured configuration of the key of HashMap with a client the records such as to be only capable of.Equal records successClient user's name afterwards is shown with ListView tabular form, and the quantity of the client of having registered of statistics is passed throughTextView is shown.
It clicks after starting meeting key, into meeting interface.Server receives the picture and text for coming each clientThis information.The information such as user name show that the picture received utilizes Glide as the label in client source by TextViewPicture loading frame information is shown in PhotoView control, while there are also save picture to external memory space.
Clicking can open after this map office key, browse this map office, can be shown in after selecting a certain picturePhotoView control.This map office is actively updated after receiving the new picture from client.
Fig. 8 is the program chart of client.Client is the main producers of data, information as seen from the figure, and is led toIt crosses internal network and is returned to server.It is swept after click scan key into two dimensional code and takes interface, can will sweep the clothes gotThe two-dimension code image at business device end is parsed into corresponding IP address information and port numbers, for carrying out Socket connection.Establish connectionServer end is sent to using the user name of the machine and IP address as information of registering afterwards.Meeting interface is jumped to later, clicks lifeSuspension button can be created at suspension key, can then it be deleted by clicking delete button.Suspension key mainly completes three functionCan:
Firstly, being that highest priority is suspended in it by the SYSTEM_ALERT_WINDOW that WindowManager is arrangedOn the overall situation.Simultaneously because suspension key creation, operate in a Service when, exit application after still be able to suspendOn other application, and it is constantly in the front end of screen.
Secondly, can pull in screen: obtain GesturDetector example to onDown, onSingleTapUp,The gesture operations such as onScroll are able to carry out identification, and handle corresponding response logic;It obtains
Finally, screen printing: single machine suspension key can intercept current screen.In order to obtain full width, complete picture, cuttingIt takes moment setting suspension key setVisibility (View.GONE) to make its disappearance, calls the postDelayed of handlerMethod, and a branch thread is created, screenshotss operation is realized in this thread.Screenshotss are virtually shown by virtualDisplayShow device to obtain, by screenshot Content Transformation at Bitmap picture after screenshotss.Bitmap is stored in by file I/OExternal storage, while server end is sent to by Socket communication.
Key is set to disappear, picture is shown in screen after intercepting successfully again.After the completion of interception, by its Context resolution atBitmap picture for later be transferred to server and locally downloading calling.
It is above exactly exhaustive presentation of the present invention to specific embodiment.
It should be appreciated that the purposes of these examples is merely to illustrate the present invention and is not intended to limit the scope of the invention.In addition, it should also be understood that, those skilled in the art can do various change to the present invention after having read the present invention to technology contentsDynamic or modification, all these equivalent forms are equally fallen within the scope of the appended claims within the limits of the protection.