tryad1tk

Friday, 19 February 2016

Navigation Drawer Activity with Fragments

Go to Android Studio,start new project and enter the desired name for your app.Then, in the next step Select the Navigation Drawer Activity and click Next.  As shown below



Click next and then press finish.
Now your app will be build, wait and then Continue Your project will look like this-



layout named as content_main.xml is the layout which will be shown first when you open your app

You can either edit this layout or create a new layout and call that layout using savedinstance ==null as the first layout.

Firstly edit your content_main.xml by removing tools:showIn="@layout/app_bar_main" this line and edit the app_bar_main.xml as follows-

we have added Framelayout So that each fragment would be replaced by other

Here what we want to do is open new fragment everytime the user selects an option from navigation drawer.

we have added Framelayout So that each fragment would be replaced by other

create a new layout named as lay1.xml as follows-


Now we will create a new class that will extend Frgaments and will use this new lay1.xml as its View

Create new class named as Frag1.Java-


Similarly create other layout like,lay1.xml and also create seperate Fragment Class like Frag1.Java

Now call this fragment using getSupportFragementManager() Method in MainActivity or any other desired place-


Friday, 12 February 2016

Working With Google Maps For Android App

Get marker to current location and also get the latitude and longitude values

location.getLatitude() and location.getLongitude() are the methods that return the double values of longitude and latitude addmarker() is a method that marks the point at a given latitude and longitude value
Before you run your application, you need a Google Maps API key.

To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=AB:E1:EF:45:3A:73:CD:37:F7:A5:67:6E:C3:F3:0F:D6:9B:07:AE:DE%3Bpbstudies.com.map
You can also add your credentials to an existing key, using this line:AB:E1:EF:45:3A:73:CD:37:F7:A5:67:6E:C3:F3:0F:D6:9B:07:AE:DE;yourpackagename

Alternatively, follow the directions here:https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"string in this file.

in the values folder under resource create a xml file google_maps_api.xml



Follow ,Share and comment for more codes 

Check these apps-
App1

App2

App3