Android 7.1.1 System screenshot

Source: Internet
Author: User

Frameworks/base/packages/systemui/src/com/android/systemui/screenshot/takescreenshotservice.java

Takescreenshotservice.java

 PackageCom.android.systemui.screenshot;ImportAndroid.app.Service;Importandroid.content.Intent;ImportAndroid.os.Handler;ImportAndroid.os.IBinder;ImportAndroid.os.Message;ImportAndroid.os.Messenger;Importandroid.os.RemoteException;ImportAndroid.os.UserManager;ImportAndroid.util.Log;ImportAndroid.view.WindowManager; Public classTakescreenshotserviceextendsService {Private Static FinalString TAG = "Takescreenshotservice"; Private StaticGlobalscreenshot Mscreenshot; PrivateHandler Mhandler =NewHandler () {@Override Public voidhandlemessage (Message msg) {FinalMessenger callback =Msg.replyto; Runnable Finisher=NewRunnable () {@Override Public voidrun () {Message reply= Message.obtain (NULL, 1); Try{callback.send (reply); } Catch(RemoteException e) {}}; //If The storage for this user are locked, we have no place to store//the screenshot, so skip taking it instead of showing a misleading//animation and error notification.            if(!getsystemservice (Usermanager.class). isuserunlocked ()) {LOG.W (TAG,"Skipping screenshot because storage is locked!");                Post (finisher); return; }            if(Mscreenshot = =NULL) {Mscreenshot=NewGlobalscreenshot (Takescreenshotservice. This); }            Switch(msg.what) { CaseWindowManager.TAKE_SCREENSHOT_FULLSCREEN:mScreenshot.takeScreenshot (finisher, Msg.arg1> 0, msg.arg2 > 0);  Break;  CaseWindowManager.TAKE_SCREENSHOT_SELECTED_REGION:mScreenshot.takeScreenshotPartial (Finisher, Msg.arg 1> 0, msg.arg2 > 0);  Break;    }        }    }; @Override Publicibinder onbind (Intent Intent) {return NewMessenger (Mhandler). Getbinder (); } @Override Public BooleanOnunbind (Intent Intent) {if(Mscreenshot! =NULL) Mscreenshot.stopscreenshot (); return true; }}

The main is to create a Globalscreenshot object, through the Globalscreenshot object to implement the screenshot, the reason that the class is hosted in the service because the screenshot may be time-consuming, this should be the design-time concept.

Of course, it is entirely possible to create Globalscreenshot objects by themselves, to achieve screenshots within the thread.

Android 7.1.1 System screenshot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.