Tuesday, December 10, 2013

Sith Browser

2 comments

Sinhala Android web Browser | Tamil Android web Browser 

Sinhala Android web browser

Sith Browser is light weight fast Android web Browser (Sinhala Android web browser / Tamil Android web Browser). Happy Browsing
★ Sinhala web Browser
★ Tamil web Browser
Features:
- Unlimited Tabs
- Full Screen Mode
- Incognito Browsing (Incognito Mode keeps you safe while browsing,History is not saved, Cookies are disabled, and Location access is disabled to ensure as best we can that you are not being tracked )
- Bookmarks
- History
- Block Images
- Flash Support
- Fast Sinhala and Tamil Rendering
- Search Engine
- FREE No Ads
Download Sith Browser and enjoy a faster experience with Sinhala Tamil web browsing.

Tamil Android web Browser



Read more...

Friday, September 6, 2013

Android Swipe List View

1 comments


SwipeListView 

An Android List View implementation with support for drawable cells and many other swipe related features. on Android for @ 47 Degrees





Fork source code from githon Android for @ 47 Degreesub
Read more...

Thursday, June 27, 2013

Android AnimationDrawable - Loading Example

0 comments

Android Drawable Animation 


In this tutorial you will learn how to animate Image set by using Android AnimationDrawable 




loading.xml

res/anim/loading.xml


<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/voipemLoading"
    android:oneshot="false" >

    <item
        android:drawable="@drawable/loading_01"
        android:duration="300"/> 
    <item
        android:drawable="@drawable/loading_02"
        android:duration="300"/>
    <item
        android:drawable="@drawable/loading_03"
        android:duration="300"/>
    <item
        android:drawable="@drawable/loading_04"
        android:duration="300"/>

</animation-list>


DravableAnimation


package com.javasrilankansupport.drawableanimation;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;

public class DravableAnimation extends Activity implements OnClickListener {

 private AnimationDrawable mAnimation;
 private ImageView mAnimLogo;
 private Button mbtnStart;
 private boolean mStart;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.dravable_animation);

  mAnimLogo = (ImageView) findViewById(R.id.loading_image);
  mAnimation = (AnimationDrawable) mAnimLogo.getDrawable();
  mbtnStart = (Button) findViewById(R.id.btn_start);

  mbtnStart.setOnClickListener(this);
 }

 @Override
 public void onClick(View v) {
  if (!mStart) {
    // start animation 
   mAnimLogo.post(new Runnable() {
    @Override
    public void run() {
     mAnimLogo.setVisibility(View.VISIBLE);
     mAnimation.start();
     mStart = true;
     mbtnStart.setText("Stop");
    }
   });
  } else {     
   // stop animation            
   mAnimation.stop();
   mbtnStart.setText("Start");
   mStart = false;
  }
 }
}


dravable_animation.xml


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DravableAnimation"
    android:background="@drawable/bg_login" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="44dp"
        android:text="@string/hello_world"
        android:textColor="@color/black"
        android:textSize="24sp" />

    <ImageView
        android:id="@+id/loading_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="37dp"
        android:src="@anim/loading"
        android:visibility="invisible" />

    <Button
        android:id="@+id/btn_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/loading_image"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp"
        android:text="@string/btn_start" />

</RelativeLayout>

Download AnimationDrawable complete source code 




Read more...

How to move an image from left to right and right to left in android

2 comments

Android Animation with TranslateAnimation

In this tutorial you will learn how to animate an image from left to right and right to left in android using TranslateAnimation


Android Animation TranslateAnimation



     ImageView img_animation = (ImageView) findViewById(R.id.img_animation);

        TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,
                0.0f, 0.0f);          //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
        animation.setDuration(5000);  // animation duration 
        animation.setRepeatCount(5);  // animation repeat count
        animation.setRepeatMode(2);   // repeat animation (left to right, right to left )
//      animation.setFillAfter(true);      

        img_animation.startAnimation(animation);  // start animation 


Animation 


package com.javasrilankansupport.animation;

import android.os.Bundle;
import android.app.Activity;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class Animation extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.);

  ImageView img_animation = (ImageView) findViewById(R.id.img_animation);

  TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,
    0.0f, 0.0f);
  animation.setDuration(5000);
  animation.setRepeatCount(5);
  animation.setRepeatMode(2);
  animation.setFillAfter(true);
  img_animation.startAnimation(animation);

 }
}


activity_animation.xml


 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Animation" >
    
    <ImageView
        android:id="@+id/img_animation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="42dp"
        android:src="@drawable/emo_im_crying" />

</RelativeLayout>



Read more...

Tuesday, June 25, 2013

Android OnKeyListener Example

0 comments
In this post you will learn how to implement Android OnKeyListener with EditText

android onkeylistener javasrilankansupport.com

EditTextKeyListener

EditTextKeyListener class implement the Android OnKeyListener interface





package com.javasrilankansupport.androidkeylistner;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.Toast;
import android.app.Activity;

public class EditTextKeyListener extends Activity implements OnKeyListener {

 private EditText userName;
 private EditText password;

 private String mUserName;
 private String mPassword;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_keylistner);

  userName = (EditText) findViewById(R.id.txt_name);
  password = (EditText) findViewById(R.id.password);

  // set onkeyListner
  userName.setOnKeyListener(this);
  password.setOnKeyListener(this);

 }

 @Override
 public boolean onKey(View v, int keyCode, KeyEvent event) {

  switch (v.getId()) {

  case R.id.txt_name:
   // keyup and "ENTER"
   if ((event.getAction() == KeyEvent.ACTION_DOWN)
     && (keyCode == KeyEvent.KEYCODE_ENTER)) {
    mUserName = userName.getText().toString();
    if (mUserName.equals("")) {
     Toast.makeText(this, "Enter user name...",
       Toast.LENGTH_SHORT).show();

    } else
     password.requestFocus();
   }
   break;

  case R.id.password:
   // keydown and "ENTER"
   if ((event.getAction() == KeyEvent.ACTION_DOWN)
     && (keyCode == KeyEvent.KEYCODE_ENTER)) {
    mPassword = password.getText().toString();
    if (mPassword.equals(""))
     Toast.makeText(this, "Enter password...",
       Toast.LENGTH_SHORT).show();

    else
     // show Toast Long time
     Toast.makeText(
       this,
       "User name : " + mUserName + "  Password : "
         + mPassword, Toast.LENGTH_LONG).show();
   }
   break;

  }
  return false;
 }

}

activity_keylistener.xml


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".EditTextKeyListener" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world"
        android:textSize="20sp" />

    <EditText
        android:id="@+id/txt_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp"
        android:ems="10"
        android:inputType="textPersonName" 
        android:hint="@string/username"
       >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/txt_name"
        android:layout_below="@+id/txt_name"
        android:layout_marginTop="24dp"
        android:ems="10"
        android:inputType="textPassword"
        android:hint="@string/psass" />

</RelativeLayout>


Download Android KeyListener project

Read more...

Tuesday, March 19, 2013

How to Install Android SDK properly in ubuntu 12.04 amd64

0 comments

Android SDK in ubuntu 12.04 amd64


Android SDK is not working properly in ubuntu 12.04 amd64 , because ubuntu 12.04 64-bit dose not   have  ia32-libs package. So it gives adb error on Eclipse like 

error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

This can solve by installing  the required libraries which is for i386 version 

Open the terminal and execute following command 

sudo apt-get install libncurses5:i386 libstdc++6:i386 libz1:i386 libc6:i386 libsdl1.2debian:i386


NB: 

If you unable to launch Android emulator, execute the following command which will install ia32-libs package

sudo apt-get install ia32-libs




Read more...

Monday, November 26, 2012

How To Add Line Numbers in Eclipse

0 comments
By adding line numbers in eclipse, it makes a little easier to debug , find and fix errors in your project.

  • To add line numbers Eclipse -> Window -> Preferences 
  • Select General -> Editors -> Text Editors and tick on Show line numbers

how to add line numbers in eclipse
Read more...

Tuesday, November 13, 2012

AsyncTask Android example | AsyncTask in Android

13 comments
In this tutorial you will learn how to use AsyncTask in your application. This AsyncTask class perform background operations and update the results on the UI

AsyncTask has three generic type
  • Params, the type of the parameters sent to the task upon execution.
  • Progress, the type of the progress units published during the background computation.
  • Result, the type of the result of the background computation

Private class ShowDialogAsyncTask extends 
        AsyncTask<Params, Progress, Result>{....}


AsyncTask goes through 4 steps

  • onPreExecute(),invoked on the UI thread immediately after the task is executed.
  •  doInBackground(Paaram ...),invoked on the background thread immediately after onPreExecute() finishes executing.
  • onProgressUpdate(Progress...) invoked on the UI thread after a call to publishProgress(Progress...).
  •  onPostExecute(Result), invoked on the UI thread after the background computation finishes. 


Android AcyncTask Example Android ProgressBar

AsyncTaskActivity


package com.javasrilankansupport.asynctask;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;


public class AsyncTaskActivity extends Activity {

 Button btn_start;
 ProgressBar progressBar;
 TextView txt_percentage;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_async_task);
        
        btn_start = (Button) findViewById(R.id.btn_start);
        progressBar =  (ProgressBar) findViewById(R.id.progress);
        txt_percentage= (TextView) findViewById(R.id.txt_percentage);
        
        btn_start.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    
    btn_start.setEnabled(false);
    new ShowDialogAsyncTask().execute();
   }
  });
    }

    
    private class ShowDialogAsyncTask extends AsyncTask<Void, Integer, Void>{

     int progress_status;
     
     @Override
  protected void onPreExecute() {
   // update the UI immediately after the task is executed
   super.onPreExecute();
   
    Toast.makeText(AsyncTaskActivity.this,
            "Invoke onPreExecute()", Toast.LENGTH_SHORT).show();

    progress_status = 0;
    txt_percentage.setText("downloading 0%");
   
  }
     
  @Override
  protected Void doInBackground(Void... params) {
   
   while(progress_status<100){
    
    progress_status += 2;
    
    publishProgress(progress_status);
    SystemClock.sleep(300);
    
   }
   return null;
  }
 
  @Override
  protected void onProgressUpdate(Integer... values) {
   super.onProgressUpdate(values);
   
   progressBar.setProgress(values[0]);
   txt_percentage.setText("downloading " +values[0]+"%");
   
  }
  
  @Override
  protected void onPostExecute(Void result) {
   super.onPostExecute(result);
   
    Toast.makeText(AsyncTaskActivity.this,
            "Invoke onPostExecute()", Toast.LENGTH_SHORT).show();
    
    txt_percentage.setText("download complete");
    btn_start.setEnabled(true);
  }
    }
}


activity_async_task.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:padding="@dimen/padding_medium"
        android:text="@string/async_task"
        tools:context=".AsyncTaskActivity" />

    <ProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="34dp" />

    <Button
        android:id="@+id/btn_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/progress"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:minWidth="120dp"
        android:text="@string/start_btn" />

    <TextView
        android:id="@+id/txt_percentage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/progress"
        android:text="downloading  0%"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>



Download AsyncTask Android example


You may also like 


Read more...

Sunday, October 7, 2012

Android Dialog - Android Custom Dialog

8 comments
In this tutorial I am going to describe how to create Android Custom Dialg which is for user login, you may have any customized android layout.

Android Dialog

Android  Dialog - Custom Dialog for User Login




 Create Android Project  AndroidDialog ;  File -> New -> Android Project

Android Layout

activity_android_dialog.xml


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/btn_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="115dp"
        android:text="Launch Dialog" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="28dp"
        android:layout_marginTop="54dp"
        android:text="@string/app_desc"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    
</RelativeLayout>


Dialog Layout

dialog_layout.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="10sp" >

    <EditText
        android:id="@+id/txt_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="@string/dialog_uname"
        android:singleLine="true" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword" >
    </EditText>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/btn_login"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:text="@string/dialog_submit" />

        <Button
            android:id="@+id/btn_cancel"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/btn_login"
            android:text="@string/dialog_cancel" />
    </RelativeLayout>

</LinearLayout>



AndroidDialog   Activity


Android  Dialog - Custom Dialog


Override both onCreateDialog(int id) and onPrepareDialog(int id, Dialog dialog) methods and add following code which will create your custom Android Dialog.


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;

public class AndroidDialog extends Activity {

 final private static int DIALOG_LOGIN = 1;

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_android_dialog);

  Button launch_button = (Button) findViewById(R.id.btn_launch);

  launch_button.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {
    showDialog(DIALOG_LOGIN);
   }
  });
 }

 @Override
 protected Dialog onCreateDialog(int id) {

  AlertDialog dialogDetails = null;

  switch (id) {
  case DIALOG_LOGIN:
   LayoutInflater inflater = LayoutInflater.from(this);
   View dialogview = inflater.inflate(R.layout.dialog_layout, null);

   AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
   dialogbuilder.setTitle("Login");
   dialogbuilder.setView(dialogview);
   dialogDetails = dialogbuilder.create();

   break;
  }

  return dialogDetails;
 }

 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {

  switch (id) {
  case DIALOG_LOGIN:
   final AlertDialog alertDialog = (AlertDialog) dialog;
   Button loginbutton = (Button) alertDialog
     .findViewById(R.id.btn_login);
   Button cancelbutton = (Button) alertDialog
     .findViewById(R.id.btn_cancel);
   final EditText userName = (EditText) alertDialog
     .findViewById(R.id.txt_name);
   final EditText password = (EditText) alertDialog
     .findViewById(R.id.password);

   loginbutton.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
     alertDialog.dismiss();
     Toast.makeText(
       AndroidDialog.this,
       "User Name : " + userName.getText().toString()
         + "  Password : "
         + password.getText().toString(),
       Toast.LENGTH_LONG).show();
    }
   });

   cancelbutton.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
     alertDialog.dismiss();
    }
   });
   break;
  }
 }
}


Download Android Custom Dialog Eclipse project 
Read more...

Wednesday, July 18, 2012

How to Check Android Network / Internet Connectivity Status

6 comments

It is not complex to Check Android Network / Internet Connectivity Status, bellow DetectConnection class
will help you to check Android Network / Internet Connectivity Status. Here I am going to load Android Wireless & Network Setting if device is not connected to any Network.



check network  internet connection in android



CheckConnectionActivity Activity will load Wireless & Network Setting if your Android device is not connected to the Network.


package com.jsupport;

import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;

public class CheckConnectionActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.check_connection);

  Button check_connection = (Button) findViewById(R.id.btn_checkConnection);

  check_connection.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {
    if (DetectConnection
      .checkInternetConnection(CheckConnectionActivity.this)) {
     Toast.makeText(CheckConnectionActivity.this,
       "You have Internet Connection", Toast.LENGTH_LONG)
       .show();
    } else {
     Toast.makeText(CheckConnectionActivity.this,
       "You Do not have Internet Connection",
       Toast.LENGTH_LONG).show();

     CheckConnectionActivity.this.startActivity(new Intent(
       Settings.ACTION_WIRELESS_SETTINGS));
    }
   }
  });
 }
}


Create DetectConnection class

Context.getSystemService(Context.CONNECTIVITY_SERVICE)
which will gives the Network information, network availability and the connectivity status of the device


package com.jsupport;

package com.jsupport;

import android.content.Context;
import android.net.ConnectivityManager;

public class DetectConnection {

 public static boolean checkInternetConnection(Context context) {

  ConnectivityManager con_manager = (ConnectivityManager) context
    .getSystemService(Context.CONNECTIVITY_SERVICE);

  if (con_manager.getActiveNetworkInfo() != null
    && con_manager.getActiveNetworkInfo().isAvailable()
    && con_manager.getActiveNetworkInfo().isConnected()) {
   return true;
  } else {
   return false;
  }
 }
}


Add following permission to your AndroidManifest.xml to allow internet connection and to access Network Settings


< uses-permission android:name="android.permission.INTERNET" />
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


AndroidManifest.xml



how to check network internet connection in android
launch android wirless and networks seting







You may also like 


Read more...