Android Create Floating Window

private void initFloatingWindow() {
        mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
        mWindow = PolicyManager.makeNewWindow(mContext);
        mWindow.setWindowManager(mWindowManager, null, null);
        mWindow.requestFeature(Window.FEATURE_NO_TITLE);
        mDecor = mWindow.getDecorView();
        mDecor.setOnTouchListener(mTouchListener);
        mWindow.setContentView(this);
        mWindow.setBackgroundDrawableResource(android.R.color.transparent);
        
        // While the media controller is up, the volume control keys should
        // affect the media stream type
        mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC);

        setFocusable(true);
        setFocusableInTouchMode(true);
        setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        requestFocus();
}

ref: MediaController.java

Xcode 使用 HTTP

XCode 7.0.1

ERROR:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

You can find this Note at Here.

App Transport Security

App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.

Temporary Solution Alt none

iOS Create Thumbnail by means of offscreen image context

- (void)setThumbnailFromImage:(UIImage *)image {
    CGSize origImageSize = image.size;
    CGRect newRect = CGRectMake(0, 0, 40, 40);
    float ratio = MAX(newRect.size.width / origImageSize.width, newRect.size.height / origImageSize.height);

    UIGraphicsBeginImageContextWithOptions(newRect.size, NO, ratio);

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:newRect cornerRadius:5.0];
    [path addClip];
    CGRect thumbRect;
    thumbRect.size.width = ratio * origImageSize.width;
    thumbRect.size.height = ratio * origImageSize.height;
    thumbRect.origin.x = (newRect.size.width - thumbRect.size.width) / 2.0;
    thumbRect.origin.y = (newRect.size.height - thumbRect.size.height) / 2.0;
    [image drawInRect:thumbRect];
    UIImage *thumbnail = UIGraphicsGetImageFromCurrentImageContext();

    //Get the thumbnail
    //self.thumbnail = thumbnail;
    
    UIGraphicsEndImageContext();
}

Windows 无法自动将 IP 协议堆栈绑定到网络适配器

自从卸载了“猎豹免费WIFI”后,我的windows系统就一直提示连接受限制,能连接WIFI路由器,但是拿不到IP,连不上网了。浪费了整整半天的时间,总算找到了解决方法。 回头想想,真替国人的软件感到羞耻!

PS:windows 10依然不太好用。

Alt none

Alt none

解决方案 去除Liebao WiFI NAT Driver

Alt none

iOS Application Status and Transitions

Alt none ref: iOS Programming 4th edition