How to customize Toasts

SDK Version: 
M3

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:

  1.        String text = “example toast text!;
  2.        Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
  3.        /* Positioning your Toast */
  4.        int offsetX = 0, offsetY = 0;
  5.        toast.setGravity(Gravity.BOTTOM, offsetX, offsetY);
  6.        toast.show();

Creating a Custom Toast View

Date handling in Android development

SDK Version: 
M3

This unusual topic came around quite a few times in the last couple of days, first with our own rss parser, and today with android-xmlrpc.
In our rss parser, we wanted to have as much flexibility as possible, so we could use many types of localized rss pages, that have different date formats.

Android avatar creator game, coming soon

Here we go with the first pictures of Android avatar creator.




Players will be able to create avatars with unique personalities, fulfill their desires or go mad...

WebView with zoom controls, image from SDCARD

SDK Version: 
M3

The Problem:
When I'm trying to load an image (tried both gif and png) from my assets directory, into a webview.
In my assets folder, I have an image called myImage.gif
Here's my wrong code:

  1. WebView data = (WebView) findViewById(R.id.data)
  2. data.loadData("<IMG HEIGHT=\"42px\" WIDTH=\"42px\" SRC=\"file:///android_assets/myImage.gif\" />", "text/html",  "UTF-8");

All that happens when I try it, is that I get a blank screen with a
empty 42px/42px box.
In logcat, I see the message:
03-30 00:21:14.398: DEBUG/WebCore(214): Console: Not allowed to load
local resource: file:///android_assets/myImage.gif line: 0 source:

The Solution:
Even though, I'm going to load the image file from the filesystem (SDCARD or Phone Storage), instead of Assets folder, I've found a solution for this, and you don't even have to care about ContentProviders... (Which is also a good solution, but this is much easier & quicker in this case.)

ACRA - Application Crash Report for Android

The worst part in having FC-s in your application, is the user response, which is 1 star reviews and disappointed user's comments in the android market.
For example: "crash on start" or "bad..uninstall", 1*. These are quite common on the android market, and are not very helpful, for developers. You don't see users mailing in crash reports, very often, because it's hard for the avarage user, to get the data, the devs need.
A few days ago in Jozsi’s article Useful Java APIs for Android applications, a commenter named Kevin Gaudin (thanks Kevin!) recommended ACRA - Application Crash Report for Android. He is also the developer of the project.

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.

Magento webshop on android

Magento is an eCommerce platform, and they are working on releasing their mCommerce platform for Android/iPhone/iPad this august.

Calling system settings from an Android app - GPS example

SDK Version: 
M3
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:

  1. startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);

To check GPS availability use the code code below: (the Activity must implement LocationListener)

Useful Java APIs for Android applications

1 - Java MSN Messenger Library (JML)
If you want to use msn messenger protocol in your application, JML is your best choice. JML is a java MSN Messenger library that supports MSNP8-MSNP12. It is optimized for multiple users and is intended to be very easy to follow and use.
JML homepage

'The project itself is supposed by a number of developers, and used in a number of projects, including but not limited to:'


  • JClaim (Generic IM Framework + Generic Swing UI)
  • SIP Communicator - the Java VoIP and Instant Messaging client
  • Openfire IM Gateway plugin
  • MSN Alert
  • MSN2Go
  • Omnivide
  • Kiosk Messenger

On sourceforge website you can found a number of quick examples, resources and useful links too.

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.

Syndicate content