суббота, 6 апреля 2013 г.

Android snippet: Linkify your Text Views

Linkify is a helper class that creates hyperlinks within Text View class trough RegEx pattern matching.

The Linkify class has presets that can detect and linkify web URLs, emails addresses and phone numbers. To apply a preset, use the static Linkify.addLinks method, passing in a View to Linkify and a bitmask of one of the following self-describing Linkify class constants: WEB_URLS, EMAIL_ADDRESSES, PHONE_NUMBERS and ALL.

TextView textView = (TextView) findViewById(R.id.myTextView);

Linkify.addLinks(textView, Linkify.WEB_URLS|Linkify.EMAIL_ADDRESSES);


You can also linkify Views directly within a layout using the android:autoLink attribute. It supports one or more of the following values: none, web, email, phone, all.

<TextView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:text="@string/linkify_me"

android:autolink="phone | email"

/>


вторник, 29 мая 2012 г.

The curious BlinkLayout in Android

Yesterday read some post from blog (http://www.androidzeitgeist.com/) of my Google+ friend Sebastian Kaspari. On the bottom you can see repost.

While reading the source code of Android's LayoutInflater class I found a hidden gem that seems to be quite unnoticed yet. Ladies and gentlemen I present you the mighty BlinkLayout. Views that are placed inside this ViewGroup blink at a rate of 500ms.The BlinkLayout is an inner class of the LayoutInflater and can therefore only be used in a XML layout that will be parsed by a LayoutInflater instance. Due to the implementation it's only possible to use it as root node using the <blink> tag inside a XML layout. It seems like the BlinkLayout is available since Android 4.0 and isn't used in the Android source code I observed. Maybe it was added for debugging reasons and was forgotten later.


The video above shows the BlinkLayout in action using the following layout XML:


     
    

The following snippet was used to inflate the layout and pass it to the activity:
package com.androidzeitgeist.blinklayout;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

public class BlinkLayoutActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View view = LayoutInflater.from(this).inflate(R.layout.main_layout, null);
        setContentView(view);
    }
}

четверг, 29 марта 2012 г.

Mobile UI Design Patterns


User interface design patterns are solutions to common design challenges, such as navigating around an app, listing data or providing feedback to users.

Mobile apps and sites have unique UI design requirements because, compared to their desktop counterparts, they’re used in smaller screens and, at least with today’s modern mobile devices, rely on fingers instead of a keyboard and mouse as input mechanisms.

Whether you’re designing a mobile app UI for the first time or in need of specific design solutions, these mobile UI design pattern resources will surely help!

воскресенье, 11 декабря 2011 г.

Some good tips if you have problems with the emulator

Some tips about the ICS emulator

1) Don't expect it to run well on any machine with less than 3GB of RAM. It can be done, but don't rely on it :).

2) There is a list of know issues in the emulator at http://tools.android.com/release/knownissues (from @ediTLJ on twitter)

3) Increase the default RAM for your AVDs to 1024MB (yup, 1GB)

4) If the emulator has crashed try deleting the AVD you used. If you're told the AVD is in use then you'll need to create a new AVD.

5) If you've hit problems with Snapshot set to Enabled on the AVD then turn it off.

6) Try setting the Max VM application heap size to 40MB or more (from+Reuben Scratton )

7) If your first boot appears to lock up it could be your contacts database. Try exiting the emulator and re-starting it (from +Reuben Scratton )

8) The screen resolution for the Nexus Prime is listed as WXGA720 in the AVD settings.

9) If you want to see what ICS will look like on a tablet use WSVGA or WXGA800 as the resolution.

10) The software buttons for Home, Back, etc. don't appear to be in the ICS image for some resolutions. Resolutions known to support the soft buttons are WSVGA and WXGA800.

четверг, 22 сентября 2011 г.

Android snippet: Check if the device is connected to the internet

Just a quick function to make your live easier
How to check if the device that runs your application has an active internet connection
Here is the function:
public static boolean isOnline(Context context) {
     ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
     NetworkInfo netInfo = cm.getActiveNetworkInfo();
     if (netInfo != null && netInfo.isAvailable() && netInfo.isConnected()) {
         return true;
     }
     return false;
}
Also You must add the INTERNET and ACCESS_NETWORK_STATE permissions to Your application
<uses-permission android:name="android.permission.INTERNET"  />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

четверг, 21 июля 2011 г.

Integrating twitter into android app


Many Android developers ask how to start the default twitter client from their application. Which Intent should you use?

It is often advised to send an Intent with ACTION_SEND. However, many programs will fire up: Gmail, SMS send, dropbox, twitter clients, MMS Send, flickr send, etc. This is too broad.

On the other hand, some people advise to filter on the MIME type application/twitter. But this is too restrictive: very few clients will recognize this unofficial/non-standardized MIME type (twidroid is among them, but HTC default client is not).

So, You can:

понедельник, 27 июня 2011 г.

Speed up your eclipse as a super fast IDE

Follow these 5 steps to speed up your eclipse as a super fast IDE , it works for 32 & 64 bit version eclipse/jdk.

1. Disable antivirus software, or add your jdk & eclipse & workspace & other related folder to white list in your antivirus software


2. Disable unecessary validations and startup action in eclipse reference.