How do generics of generics work?

As Kenny has noted in his comment, you can get around this with: List<Test<? extends Number>> l = Collections.<Test<? extends Number>>singletonList(t); This immediately tells us that the operation isn’t unsafe, it’s just a victim of limited inference. If it were unsafe, the above wouldn’t compile. Since using explicit type parameters in a generic method as … Read more

Record a video of the screen using .NET technologies [closed]

There isn’t any need for a third-party DLL. This simple method captures the current screen image into a .NET Bitmap object. private Image CaptureScreen() { Rectangle screenSize = Screen.PrimaryScreen.Bounds; Bitmap target = new Bitmap(screenSize.Width, screenSize.Height); using(Graphics g = Graphics.FromImage(target)) { g.CopyFromScreen(0, 0, 0, 0, new Size(screenSize.Width, screenSize.Height)); } return target; } I am sure you … Read more

capturing images with MediaStore.ACTION_IMAGE_CAPTURE intent in android

Photos taken by the ACTION_IMAGE_CAPTURE are not registered in the MediaStore automatically on all devices. The official Android guide gives that example: http://developer.android.com/guide/topics/media/camera.html#intent-receive But that does not work either on all devices. The only reliable method I am aware of consists in saving the path to the picture in a local variable. Beware that your … Read more

android capture video frame

The following works for me: public static Bitmap getVideoFrame(FileDescriptor FD) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(FD); return retriever.getFrameAtTime(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (RuntimeException ex) { ex.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException ex) { } } return null; } Also works if you use a … Read more

Record Video of Screen using .NET technologies [closed]

There is no need for a third party DLL. This simple method captures the current screen image into a .NET Bitmap object. private Image CaptureScreen() { Rectangle screenSize = Screen.PrimaryScreen.Bounds; Bitmap target = new Bitmap(screenSize.Width,screenSize.Height); using(Graphics g = Graphics.FromImage(target)) { g.CopyFromScreen(0,0,0,0,new Size(screenSize.Width,screenSize.Height)); } return target; } I am sure you can figure out how to … Read more

What is a capture conversion in Java and can anyone give me examples?

Capture conversion was designed to make wildcards (in generics), ? useful. Suppose we have the following class: public interface Test<T> { public void shout(T whatever); public T repeatPreviousShout(); } and somewhere on our code we have, public static void instantTest(Test<?> test) { System.out.println(test.repeatPreviousShout()); } Because test is not a raw Test and since repeatPreviousShout() in … Read more