Skip to main content

Posts

Showing posts with the label Android

Android: Current Location Using Fused APi on Google Maps

This tutorial gives us the simple implementation of "Fused API" to fetch the current location on google map in android. Fused API is latest among all techniques to get the location. It provides you very precise results and also uses less battery of your device. It chooses GPS or Network provider to get to your current location. And it helps your device remember about the last saved location. Let's implement the Fused API to fetch/get the current location. Step 1: Create a new project in Android studio. and select Maps Activity.

Navigation Drawer sample source Code in Android Studio

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context="com.example.johnwick.navigation_drawer.MainActivity">     <FrameLayout         android:id="@+id/content_frame"         android:layout_width="match_parent"         android:layout_height="match_parent"/>     <ListView         android:id="@+id/left_drawer"         android:layout_width="240dp"         android:layout_height="match_parent"         android:layout_gravity="start"   ...

Android: Login Screen using Fragments

In this tutorial, our focus is on making a User/Member login activity using fragments. With the help of Fragments we will use the same activity to show User login area and also Members Login area. Prerequisite for this tutorial: You should be know how to make an Activity And most importantly you should have prior Knowledge of Fragments. For practising basic Fragment implementation refer to Android Simple Fragment Example      We have used only three activities for this: MainActivity(which represents the Login Screen) Fragments for Members area Fragment for New Users

Android Activity Life Cycle

This is the most important and basic concept in Android. In Android, every activity has its on life cycle. An activity encountered the following methods in its life cycle. 1. onCreate() 2. onStart() 3. onResume() 4. onPause() 5. onStop() 6. onResume() 7. onDestroy()

Android : Activity

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.[1] http://developer.android.com/guide/components/activities.html [1 ] An Activity is a screen in which user perform some task. It might be capturing image, dialing phone number, typing text message etc. These all are the activities. Almost every screen with which users interact is an activity.

Android Simple Fragment Example

For creating a fragment we only use two things:- Fragment class Fragment xml layout In the below discussed example we need to show different fragments on button click event. So, we will be creating two layout files and two different classes. Here goes the code for first Fragment: FirstFragment.java package com.example.fragementdemo; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class FirstFragment extends Fragment {

Android App Using External font face(Custom)

Create a new Project. Make a new folder named ‘Font’ into your assets folder Paste the font file into this folder Now add the below written lines into your Java file.        textview =(TextView)findViewById(R.id. text1 );        Typeface font = Typeface. createFromAsset (getAssets(), "font/Maximum.ttf" );        textview .setTypeface(font);

Simple Login/Register Example using SQLite database

MainActivity.java(login Screen) package com.AndroidDevelopmentGuru.database_new; import java.util.List; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity {                                 EditText user, pass;                 Button login, not_reg;                 DatabaseHandler db;           ...

Divide Layouts into Two Parts Programmatically(without using xml)

For this we just need a class and we will programmatically create the Layouts. And after this we will add Buttons in each layout. package com.AndroidDevelopmentGuru.progmatic; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.widget.Button; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; public class progmmatic extends Activity {     @Override     protected void onCreate(Bundle savedInstanceState) {         // TODO Auto-generated method stub         super.onCreate(savedInstanceState);                 //creating a Linear Layout         LinearLayout parent_layout = new LinearLayout(this);        

CheckBox in Listview Using Custom Adapter

 In this Application we just need to add a CheckBox along with the TextView. This Tutorial is an extension of ListView Using Custom Adapter  We need the following things: 1. CustomAdapter class 2. DataModel Class 3. MainActivity Class and with these classes we need only two xml files 1. activity_main.xml(xml file for MainActivity.java) 2. row.xml(To hold listview components) Here is your Code : MainActivity.java package com.AndroidDevelopmentGuru.checkbox; import java.util.ArrayList;

What is UTF? and comparision of UTF-8, UTF-16, UTF-32

Before we start discussing about UTF we need to know few basic elements. As we know that we have to encode the human understandable language into machine understandable language. To achieve this objective there are various encoding systems. Few famous encoding systems are enlisted below: ASCII: American Standard Code for information interchange(For United States) ISO 8859-1: Western European Languages KOI-8: for Russian Language

List View And GridView Layout example in Android

Listview Layout MainActivity.java package com.example.layouts; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class MainActivity extends Activity {

Custom Toast in Android

MainActivity.java package com.AndroidDevelopmentGuru.custom_toast; import android.app.Activity; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity {     Button btn;     @Override

SignUp Form with Email Validation

You can use intents to transfer the data from one activity to another using. Below is an example to implement a signup form in Android MainActivity.java package com.AndroidDevelopmentGuru.registeration_form; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity {     EditText text1,text2,text3,text4,text5;     Button btn;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);    

ListView Using CustomAdapter with setter getter method

For this we need following three classes Main Class where we would be implementing listview using custom Adapter(CustomAdapterExample.java) Second Class for designing our Custom Adapter(CustomAdapter.java) And the last one for getter setter method for data transfer(User.java) Along with these three java classes we need two xml file one would be default xml file (activity_custom_adapter_example.xml) for main class and another one for making Listview layout (simple_list_items.xml)  In activity_custom_adapter_example.xml, take a ListView element from the Widgets and in simple_list_items.xml, take two textviews.

ListView Using SqLite Database

MainActivity.Java package com.example.nikk.nikkukaushik; import android.app.DatePickerDialog; import android.app.Dialog; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; import android.widget.ImageButton; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import java.util.Calendar; import java.util.List; public class MainActivity extends ActionBarActivity implements View.OnClickListener,AdapterView.OnItemSelectedListener{     MyDataHelper data1=new MyDataHelper(this);     int pos;     private ImageButton ib;     private Calendar cal; ...

Action Bar with Back press Enabled Button

Action bar With Back Press Enabled Button There are only three things we need to do, to achieve this objective.    Create action Bar with back button    Coding on Back button       And few changes in Manifest file 1.      Create action Bar with Button: In OnCreate() method write below given lines: getActionBar().setDisplayHomeAsUpEnabled(true);

ListView Example in Android

To create a simple listview in android as shown in below image, we generally need three things. 1. ListView 2. ArrayAdapter 3. Simple String array. Image 1 activity_main.xml

DropDown List in Android using Spinner

Usually we use drop down list in forms. In android we could achieve this using Spinner. Here goes the Code: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/LinearLayout1"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context=".MainActivity" >

SET ENVIRONMENT VARIABLES FOR JAVA INSTALLATION

Goto MyComputer ->> Properties ->> Advanced System Settings->> Enviornment Variables After that In user variable Make a folder Named JAVA_HOME  and set its value: C:\Program Files\Java\jdk1.7.0_45\lib and click ok if that doesn't work try this: In user Variable, click on new at bottom of tab give JAVA_HOME in variable name in value : \ProgramFiles\java\jdkk1.8.0_05