Posts

Showing posts from December, 2014

Get the Size of display in android

To get the current screen's width and height, just using DisplayMetrics  and WindowManager DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; int screenHeight = displayMetrics.heightPixels;

Email Address Validation

Lot of peoples validate their field by using field length or Regular Expressions . In this way, Email Addresses validation has been difficult some times. Format of Email Address: The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters - but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters.<sup id="cite_ref-0"> [1] </sup> The formal definitions are in RFC 5322 (sections 3.2.3 and 3.4.1) and RFC 5321 - with a more readable form given in the informational RFC 3696 <sup id="cite_ref-1">[2]</sup> and the associated errata. Supported Characters: The local-part of the email address may use any of these ASCII characters RFC 5322 Section 3.2.3: Uppercase and lowercase English letters (a–z, A–Z) (ASCII: 65-90, 97-122) Digits 0 to 9 (ASCII: 48-57) Cha

Float Label Edit Text in android

Image
Last few days, i search some new UI on Edittext. Finally i found it  and its very awesome. Float Label EditText Meanwhile, some of jquery components only do this, but now android achieved it.  In android, such big form shows the hint text, but after text changed it will be disappear. Using TextView with EditText makes more screen space. Float Label Edit Text solves your problem. It's Support from version 2.2. It's also the one of best pluses. In XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       xmlns:tools="http://schemas.android.com/tools"     xmlns:floatlabel="http://schemas.android.com/apk/res-auto"      android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"> <com.ind.floatlabeleditext.FloatLabelEditText     android:id="@+id/username"     android:layout_width="match_parent"

Set the height and width of layout, programmatically in android

Create the layout LinearLayout linearLayout= (LinearLayout)findViewById(R.id.numberPadLayout); Gets the layout params that will allow you to resize the layout LayoutParams Lparams =  linearLayout.getLayoutParams(); Changes the height and width by specified pixels Lparams .height = 100; Lparams .width = 100;

Clear the app data programmatically in android

Image
Clear the App Data Programmatically in Android Application data has been created due to use shared preference data, databases and network caches data. This data has been manually clear on Settings -- > Apps (or) Application Manager --> Select the app you want to clear the data. --> Then click button clear data to erase the app from the Phone and SDCARD. Applications like facebook, google+, gmail and some games captures more data on phone and SDCARD. Once you clear the data of your app, all passwords and saved settings in app has been lost. So carefull to use this method. Create the Class MyApplication public class MyApplication extends Application {  private static MyApplication instance;  @Override  public void onCreate() {   super.onCreate();   instance = this;  }  public static MyApplication getInstance(){   return instance;  }  public void clearApplicationData() {   File cache = getCacheDir();   File appDir = new File(cache.getParent());   if

Image Downloading Library - Picasso

Picasso is best image downloading and caching library using in android. It's very fast to show the image from the URL. Using picasso is very simple to do it. From Gradle       compile 'com.squareup.picasso:picasso:2.4.0' Maven    <dependency>   <groupId>com.squareup.picasso</groupId>   <artifactId>picasso</artifactId>   <version>2.4.0</version> </dependency> If you are using Proguard, Just add the line, -dontwarn com.squareup.okhttp.** Download the JAR . Samples and Library Click here .

Shake Detection Library

If you want to detect the shake sensor, Implement like this,  SensorManager public class Demo extends Activity implements ShakeDetector.Listener Class Implementation,  SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); ShakeDetector sd = new ShakeDetector(this); sd.start(sensorManager); Interface public void hearShake() { Toast.makeText(this, "Now You're Shaking", Toast.LENGTH_SHORT).show(); }  Get the Library from this link