Posts

Showing posts from October, 2015

New Navigation View

Image
Navigation Drawer is an important feature of any android app. Its need is when you navigate some particular pages of your app. In new android support design library, Navigation View is officially released, before we used Navigation Drawer. Let's create Navigation View.  First  Create New Project Add this library to app's build.gradle file in dependencies and click sync now : compile 'com.android.support:design:23.1.0' Now change to your layout file's content as below where you want to add drawer: <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"     android:fitsSystemWindows="true"     tools:context=".MainActivity">     <LinearLayout         android:layout_wi

ToolBar

Image
ToolBar is complete replacement of Android ActionBar. It provides greater controls to user to customize its appearance unlike Old ActionBar. Its introduced in Android Lollipop, API 21, hence its available to use in Support Design Library .  I encourage you guys to hiding ActionBar and switch to ToolBar from now since new support design library with wonderful features designed to work together with ToolBar not ActionBar. Let's do that. First Create New Project Its easy to switch to ToolBar. Just hide ActionBar from style.xml <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> Now run your project. You see below output with

Creating New Project in Android Studio

Image
Say good bye to workspace, welcome to modules. From now a days, we will develop any code in Android Studio. For that, today I'll teach you, how to create android project in Android Studio. Download Android Studio  and install in your system with JAVA installed. After installing Android Studio, create new project as shown below: Then you can see below screen: Here there are 4 fields: Application Name: App name that you see when you install an app Company Domain: You can set any domain Package Name: This name will be unique for each app. That is auto-generated as you type Application Name, it refers as per Company Domain. You can manually edit it. Project Location: Source directory of your project. Click Next , you will see below screen. This is screen for asking which types of devices does support your app. By default, its set to Phone and Tablet and set to your minimum SDK Version. Other options are: Wear: For wear devices like Andro

Get Current Location using GPS/Network Provider

Hello to all, Today I teach you that how can we get current location. In android's new SDK tools, LocationManager class does not give any network provider's status. It always gives null value. Still it works in some of the android devices rarely. So that's why I include code for both network provider and gps provider for getting current location. Create one service class name LocationFinder  and implements it LocationListener . All the code which is related to Location, is doing in that service class and from MainActivity , call its method through its instance in onResume() method. The reason you know, why its called in onResume(), because when you enable GPS and come back in activity, then its again check Location's status. In the code, if GPS not enable, I show settings alert pop-up, to go settings menu. When you enable GPS, you will get current location after 2-3 seconds. If not, come again to activity and surely get location. Make sure, must add persmi