Customizing Toasts A toast notification is a message that pops up on the surface of the window. It only fills the amount of space required for the message and the user's current activity remains visible and interactive. The notification automatically fades in and out, and does not accept interaction events. The Basics You can create customized Toasts and setting its display position, as you like. Here's a little code snippet to demonstrate how it works: String text = “example … [Read more...]
SQLite Basics

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. Basic SQLite commands: 1, Create table 1. CREATE TABLE testtable (id integer primary key, name text); 2, Insert into table 1. INSERT INTO "testtable" VALUES(1,'Joseph'); 3, Create a … [Read more...]
Using ksoap2 for android, and parsing output data

SDK Version: M3 So the other day, I was asked to check out how we could use soap on Android, preferably with ksoap2 for android, and a public SOAP Web Service. For the latter the TopGoalScorers web service was chosen. This example will prepare a soap message with one extra variable and value (iTopN, 5) and get a soap object as response. private static final String METHOD_NAME = "TopGoalScorers"; private static final String SOAP_ACTION = … [Read more...]
Calling system settings from an Android app – GPS example

This tutorial shows how to redirect the user to a system settings screen asking to modify some settings the application depends on. We will make a specific example with GPS: The application can be used only if GPS is available. The android systems GPS setting screen can be called just like any other Activities: startActivityForResult(newIntent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0); To check GPS availability use the code code below: (the Activity must implement … [Read more...]
HTC EVO 4G Tips and Tricks

So you’re the proud new owner of the HTC EVO 4G and you want to get the most out of what is arguably one of the most powerful phones on the market. We’ve all spent so many months drooling over this phone that having it your hand might just be a little overwhelming at first. Luckily for you, the friendly folks over at the EVO section of AndroidForums are eager to help with any question you could possibly think of, but we’ll cover a few basics here. Getting to Know Android and HTC … [Read more...]
Android 2.1 Eclair for T-mobile Pulse

If you haven't heard about Pulse yet, go to http://en.wikipedia.org/wiki/T-Mobile_Pulse You may also want to check its little brother: Pulse mini: http://phandroid.com/2010/02/16/t-mobile-pulse-mini-announced-for-europe-demoed/ So 2.1 finally has been released for Pulse. To see a running Eclair on a Pulse was a big suprise. Somehow the 1.5 seemed so unstable and laggy that I didn't really liked it. But with this new version of Android, I absolutely changed my mind, and I'm looking … [Read more...]
How to send email from your application

Today we'll create an easy email sender application. First of all we need to create a layout to set the address, the subject and email body box. <?xml version="1.0" encoding="utf-8"?><LinearLayout android:id="@ +id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"><LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" … [Read more...]
How to play video and audio on Android Part 2.

In this part, I'm going to focus on MediaPlayer. I'm going to show you, how to stop it properly, and how to create a media player more easily. The default behavior is the same, with every activity, after onPause and onStop, if the activity is not destroyed, it will continue to run in the background, until it is killed so the system can free up the memory it is using. So until the activity is destroyed, the mediaplayer will continue to occupy space in the phones memory. private MediaPlayer … [Read more...]
How to avoid OutOfMemory Error / OOM

ERROR/dalvikvm-heap(4204): 691456-byte external allocation too large for this process. 01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 691456 bytes 01-25 22:13:18.694 If you have ever got the message above, you are at the right place. First of all the reason: Heap size != External Memory size Dalvik's external memory that a process can use is limited to ~ 4MB-s (That is the Ugly Truth). If it's overflow, you get the BitmapFactory.DecodeFile Error. That's why even if you have … [Read more...]
How to play video and audio on Android

There is more than one way, to play media files on an Android phone, let me show you two of them. Audio: MediaPlayer is the easier way, if you just want to play an audio file in the background, somewhere in an appliaction. There are no ui controls here, but of course you can use MediaPlayer.stop(), play(), seekTo() ,etc. Just bind the needed functions to a button, gesture, or event. As you can see, it also throws a lot of exceptions, which you need to catch. public void audioPlayer(String … [Read more...]















Recent Comments