Posts

Get Location Using FusedLocationProviderClient Api

Step 1: Add play services location in build.gradle compile 'com.google.android.gms:play-services-location:11.4.2' Step 2: Add Permission in AndroidManifestFile.xml < uses-permission android :name= "android.permission.ACCESS_FINE_LOCATION" /> < uses-permission android :name= "android.permission.ACCESS_COARSE_LOCATION" /> Step 3 : package org . pratap . userlocation ; import android.Manifest ; import android.content.Intent ; import android.content.pm.PackageManager ; import android.location.Location ; import android.net.Uri ; import android.os.Bundle ; import android.provider.Settings ; import android.support.annotation.NonNull ; import android.support.v4.app.ActivityCompat ; import android.support.v4.content.ContextCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Button ; import android.widget.TextView ; import android.widget.Toast ; impo...

Android Take Photo from Camera and Gallery

Image
A Simple example application to capture image/ selecting image from gallery. This application includes sd card permission checking and FileUrilExposedException issue fix.. Step 1: ========= Create an Activity like below package org . pratap . cameraexample ; import android.Manifest ; import android.content.ActivityNotFoundException ; import android.content.Context ; import android.content.Intent ; import android.content.pm.PackageManager ; import android.database.Cursor ; import android.net.Uri ; import android.os.Build ; import android.os.Bundle ; import android.os.Environment ; import android.os.Handler ; import android.os.Message ; import android.provider.MediaStore ; import android.support.v4.app.ActivityCompat ; import android.support.v4.content.ContextCompat ; import android.support.v4.content.FileProvider ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.widget.Button ; import andro...

Android Runtime Permission Example

In Android OS (Marshmallow on wards) , google introduced run time permissions to access Storage, Camera, Location etc.. Let see an example how to ask single permission in android Here is the Link for Dangerous permissions and permission groups. Step 1 : AndroidManifest.xml let us add storage and location permission in manifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "org.pratap.runtimepermissions" > <!-- Permission for writing and reading SD Card --> <uses-permission android:name= "android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name= "android.permission.READ_EXTERNAL_STORAGE" /> <!-- Permission for accessing user's current location --> <uses-permission android:name= "android.permission.ACCESS_FINE_LOCATION" /...