Posts Tagged ‘Android Programming’
Android: Loading and playing videos from different sources
Posted by Dimitri | Filed under Featured, Programming
This is the 41st post on the website! It explains how to load images from a variety of locations, such as the ‘Resources’ folder, the SD card and from a remote server. As usual, the source code is available for download at the end of the post.
Let’s start with the basics: video formats. At the time this is being written, Android supports .3gp and .mp4 video files encoded as H.263,H.264 and MPEG-4 SP file formats. For an updated list, visit this link.
Android: Creating a button to load images from a remote server
Posted by Dimitri | Filed under Programming
This is a follow up to the post published two days ago that explained how to load images into a View’s Canvas from different sources. Differently from the last post, I will explain how to load images from a remote server after the View has been loaded and rendered on the screen. Also, this post features how to download an image after pressing a button.
So, let’s get to it. The first thing the reader might be thinking is that we just need to create a button and place the code that downloads the image inside it. It’s not as simple as that, due to these problems: (more…)
Android: loading images from a remote sever, SD card and from the Resources folder
Posted by Dimitri | Filed under Programming
As stated on the title, this post will explain how to load a image from 3 different sources: the SD card, from a remote server and from the Resources folder. Since the methods and code used to load these images from these sources are different from one another, this post is going to be divided into three different parts, one for each location.
Select one of the following links to go to a specific part of the post: (more…)
Android: touchscreen ‘swipe’ movement detection
Posted by Dimitri | Filed under Programming
This post explains how to code a simple swipe screen movement detection that can be used to control characters and other objects on an Android game or any other application.
All this code is written inside the View class, so open it up and let’s get to it. The first thing we will have to do is to create four different variables: one pair will store where the screen was touched, and the other one will be used to store the difference between the location where the screen has been pressed and where the screen has been released. Create this variables and assign zero to all of then, like this: (more…)
Android Manifest File for a Game
Posted by Dimitri | Filed under Programming
Android was designed to see every application as a collection of Activities united by intents. It also relies on the Activity stack to determine what Activity will be launched after the user finishes it by pressing the ‘back’ button. While the stack system is helpful for users and for some applications, this default behavior isn’t a necessarily a good thing for games.
That is mainly because of two things: a game use a lot of hardware resources from the device that runs it, meaning that having other activities in the same stack as the game Activity can have an impact on its performance. And the stack default behavior could lead to multiple instances of the same game running in the same stack.