Skip to main content

Posts

Showing posts from July, 2019

Auto Close Dialog Using Timer In Android

Here i will show you how to use auto close dialog after a particular time using timer class in android .So lets start with coding part :- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Auto-closing Dialog"); builder.setMessage("After 7 second, this dialog will be closed automatically!"); builder.setCancelable(true); final AlertDialog dlg = builder.create(); dlg.show(); final Timer t = new Timer(); t.schedule(new TimerTask() { public void run() { dlg.dismiss(); // when the task active then close the dialog t.cancel(); // also just top the timer thread, otherwise, you may receive a crash report } }, 7000); // after 7 second (or 7000 miliseconds), the task will be active.                 

How to use SQLite Database to perform database operations in Android

We all know that the SQLite is use in Android to Local Storage .SQLite is an opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. Lets Understand this using Code Snippets :- First Create a Class named DatabaseHelper.Java  which extends SQLiteOpenHelper Class  public class DatabaseHelper extends SQLiteOpenHelper { public static final String DB_NAME = "AnyNameDB"; public static final String TABLE_NAME = "Key"; public static final String COLUMN_ID = "id"; public static final String COLUMN_NAME ="keyword"; public static final String COLUMN_ADD = "url"; private static final int DB_VERSION = 1; public DatabaseHelper(Context context) { super(context,DB_NAME,null,DB_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String sql =

How to Generate QR code from Text

In this article i will share you the code snippet to generate the QR code from any Text. Before this i want to brief you about QR code. QR Code:  QR code is the trademark for a type of matrix barcode first designed in 1994 for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. So lets Start with the Coding Part : Bitmap TextToImageEncode(String Value) throws WriterException { BitMatrix bitMatrix; try { bitMatrix = new MultiFormatWriter().encode( Value, BarcodeFormat.DATA_MATRIX.QR_CODE, QRcodeWidth, QRcodeWidth, null ); } catch (IllegalArgumentException Illegalargumentexception) { return null; } int bitMatrixWidth = bitMatrix.getWidth(); int bitMatrixHeight = bitMatrix.getHeight(); int[] pixels = new int[bitMatrixWidth * bitMatrixHeight]; for (int y = 0; y <