Wednesday, December 8, 2021

Free LIDAR Data Sources for India

 Indian researchers can use the following providers to download LIDAR Data for India.


1. GEDI: https://gedi.umd.edu/data/products/

2.ICESAT:  https://icesat-2.gsfc.nasa.gov/icesat-2-data


At the moment these organizations have made their historical archives freely available for public.

 

Tuesday, September 21, 2021

How to get current location in android ?

 

Android location API’s are highly metamorphotic.

From their humble beginnings using locationManager widget, today there are a range of options including google fused location, locationServices, GPSwidgets, and NetworkWidgets.

But, as of September 2021, the best stands out to be Geocoder widget. I really found it simple, easy to implement and quit straight-forward, unlike other libraries.


| Geocoder does not use GPS or Networks. It uses Maps Services to reverse geocode information.


 Through this code sample, you will get to call the android device location coordinates and also the street name, location details and pincode.


The example assumes that you have already created an xml layout resource file with textView of EditText placeholders for latitude and longitude. Let us assume the editText android:id for both placeholders as et_lat and et_lon, respectively. Also have a button, that can handle eventListeners, for getting location with android:id btn_getlocation.

 In this code I have implemented View.OnClickListener. However, you can replace this geocoder code within your .setOnClickListener, too.

 Now, here is the Java  code:


public class Your_Activity extends AppCompatActivity implements
       
View.OnClickListener  {

   
private static final int REQUEST_LOCATION = 1;
    FusedLocationProviderClient
fusedLocationProviderClient;


   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView(R.layout.
youractivity);
        ActivityCompat.requestPermissions(
this,
               
new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);


       
//Enter Location
      
btn_location = (Button) findViewById(R.id.btn_location);

       btn_location.setOnClickListener(this);


       
et_lat = (EditText) findViewById(R.id.location);
       
et_lon = (EditText) findViewById(R.id.address);

       
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(Your_Activity.this);

    }

   
@RequiresApi(api = Build.VERSION_CODES.M)
   
@Override
   
public void onClick(View view) {
if (view == btn_location) {


if (ActivityCompat.checkSelfPermission(Contribute_BO.this, Manifest.permission.ACCESS_FINE_LOCATION)== PackageManager.PERMISSION_GRANTED) {
    showLocation();
}
else{
 ActivityCompat.requestPermissions(Your_Activity.
this, new String [] {Manifest.permission.ACCESS_FINE_LOCATION},REQUEST_LOCATION);
            }
    }
    }

   
private void showLocation() {
       
fusedLocationProviderClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<Location>() {
           
@Override
           
public void onComplete(@NonNull Task<Location> task) {
                Location location = task.getResult();
               
if (location != null){
                    Geocoder geocoder =
new Geocoder(Your_Activity.this, Locale.getDefault());
                   
try {
                        List<Address> addressList = geocoder.getFromLocation(location.getLatitude(),location.getLongitude(),
1);
                       
et_location.setText("Lat: "+addressList.get(0).getLatitude());
                       
et_address.setText("Lon: "+addressList.get(0).getLongitude());
                    } 
catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }
}

You can further drill down the Location details like:

Street Name = addresses.get(0).getAddressLine(0);

City Name = addressList.get(0).getLocality() ;

State Name = addressList.get(0).getAdminArea();

Country Name = addressList.get(0). getCountryName ();
Postal Code = addressList.get(0). getPostalCode();

 

To know more about Geocoder API refer the official documentation here.


At the moment, as of 2021, there are no usage limits for this Geocoder API. However, as with any other android widget, the Google's Geocoder API could be subject to change! So, try to use Android Studio's Location API's with discretion. 


Monday, September 20, 2021

Steps to create Menu on Activity Android (Navigation Drawer)


 Adding Menu on your Activity in Android can be a simple three step process:

Step 1: Create your Menu Resource Files

Step 2: Create your android activity’s layout resource file. drawerlayout.widget should be your parent element for your menu resources to be rendered on the app.

Step 3: Create your Java Class file and activate your menu widget programmatically,

 Here is the code:

Step 1: Start out by creating two menu resource file under menu tab:

First File:  menu_main.xml

 <menu xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"
   
xmlns:tools="http://schemas.android.com/tools"
   
tools:context="com.example.epbr.Second_Activity">
    <
item
       
android:id="@+id/action_settings"
       
android:orderInCategory="100"
       
android:title="@string/action_settings"
       
app:showAsAction="never" />
</
menu>

 

SeSecond File: navigation_menu

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:tools="http://schemas.android.com/tools"
   
tools:ignore="HardcodedText"
>
    <item
       
android:id="@+id/nav_account"
      
android:title="My Account"
/>
    <item
       
android:id="@+id/nav_custom"
       
android:title="My Contribution"
       
/>
    <item
      
android:id="@+id/nav_settings"
      
android:title="Settings"
/>
    <item
       
android:id="@+id/nav_logout"
       
android:title="Logout"
/>
</menu>
String Resources: Set Open/Close navigation drawer in String Resource File. 
Add the following code to string.xml:
<!--to toggle the open close button of the navigation drawer-->
<string name="nav_open">Open</string>
<string name="nav_close">Close</string>
 
Step 2: Adding menu on your android activity
 
<?xml version="1.0" encoding="utf-8"?>
<!--the root view must be the DrawerLayout-->
<androidx.drawerlayout.widget.DrawerLayout
   
xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:app="http://schemas.android.com/apk/res-auto"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:id="@+id/my_drawer_layout"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
tools:context=".Second_Activity"
   
tools:ignore="HardcodedText"
>
    <com.google.android.material.navigation.NavigationView
       
android:layout_width="wrap_content"
       
android:layout_height="match_parent"
       
android:layout_gravity="start"
      
app:menu="@menu/navigation_menu"
/>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:app="http://schemas.android.com/apk/res-auto"
      
xmlns:tools="http://schemas.android.com/tools"
      
android:layout_width="match_parent"
       
android:layout_height="match_parent"
       
android:orientation="vertical"
       
tools:context=".YOUR_Activity"
>
        //YOUR LAYOUT ELEMENTS WILL GO HERE
    </LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>

Step 3: Activate the Menu elements on Java Class file.

public class YOUR_Activity extends AppCompatActivity {
    public DrawerLayout drawerLayout;
    public ActionBarDrawerToggle actionBarDrawerToggle;
     @Override
   
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.your_activity);
        if(savedInstanceState == null) {
               // If you are using fragments you can call them here
         }
        // drawer layout instance to toggle the menu icon to open
        
drawerLayout = findViewById(R.id.my_drawer_layout);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
                                          R.string.nav_open, R.string.nav_close);
        // pass the Open and Close toggle for the drawer layout listener
       
drawerLayout.addDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();
        // to make the Navigation drawer icon always appear on the action bar
       
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
// drawer when the icon is clicked
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
}
 
 

Tuesday, August 31, 2021

How to make curved layout in Android

 

Creating a linear layout with curved or rounded bottom is pretty simple.  While it is possible to play around with layer-lists or card-view, I’m going to show you a way to get this done, purely through XML.

 

Step 1: Create my_shape.xml drawable resource file under res->drawable.

Define an oval shape and give it some solid colors.

 

Drawable Code: 
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <solid android:color="#00b300"/>
        </shape>
   </item>
</selector>
 
Step 2: tag the drawable resource file just created to your imageview element.
Give it some Linear and Relative Layout containers. 
Your res->layout file will look like:

Layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
android:orientation="vertical" android:layout_width="match_parent"
   
android:layout_height="match_parent" android:gravity="center"
>
    <RelativeLayout
       
android:layout_width="match_parent"
       
android:background="#fefefe"
       
android:layout_height="match_parent"
>
        <RelativeLayout
           
android:layout_width="match_parent"
           
android:background="#00b300"
           
android:layout_height="150dp"
>
        </RelativeLayout>

        <ImageView
           
android:layout_width="match_parent"
           
android:layout_height="120dp"
           
android:layout_marginTop="85dp"
            
android:src="@drawable/my_shape"
/>
    </RelativeLayout>
</LinearLayout>

Play around with the Relativelayout and ImageView heights to test your results….




 

Tuesday, March 9, 2021

Published with Outlook India (November, 2020)

 My travel article published with  


A more detailed article (Raw Draft) can also be viewed from: https://spiritofchennai.com/travel/best-places-to-see-in-ooty/


All publications can be viewed from label #MediaPublications





Published with an Asia's leading technology Magazine (October, 2020)

 My Article published with one of Asia's leading Technology Magazine @opensourceforyou August 2020 issue.

Thrilled about this piece making it to print, in spite of the hectic lockdown woes!

Full Article from the link below:







Tuesday, September 15, 2020

Article Published with Reader's Digest

 My Article 'Chase,' published with The Reader's Digest-India September, 2020 issue.


This is a decade old personal story that made it to print this year! :-)









All publications can be viewed from label #MediaPublications