Posts Tagged ‘Activity’
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 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.
How to get Android local files URI
Posted by Dimitri | Filed under Programming
When programming applications for Android that requires the playback of audio or video files, sometimes, there’s the need to obtain the URI of those media files instead of using a String for the absolute path. But what is a URI? A URI (Uniform Resource Identifier) is an address to an local or internet resource. It’s more like a standardized path syntax that allows pointing to a specific resource that’s available over the internet, however we are going to use it to point it to a local resource.
A URI is specially useful, when using the VideoView class to load a video located on the res folder or in the SD card. Passing the video file to the VideoView as a String won’t even work on an emulated Android device. This way, we need to get the URI of the file.