Java get MAC address of Computer

    /**
     * This method get the MAC address of a computer
     *
     * @return string of MAC address of computer
     */
    public static String getMacAddres() {
        String macAddress = "";
        try {
            for (Enumeration<NetworkInterface> enm = NetworkInterface.getNetworkInterfaces(); enm.hasMoreElements();) {
                NetworkInterface network1 = (NetworkInterface) enm.nextElement();
                if (null != network1.getHardwareAddress()) {
                    byte[] mac = new byte[50];

                    mac = network1.getHardwareAddress();

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < mac.length; i++) {
                        sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
                    }

                    macAddress = sb.toString();
                }
            }
        } catch (SocketException e) {
            // e.printStackTrace();
        }

        return macAddress;
    }

Java get Taskbar height

    public static int getTaskbarHeight(Component comp) {
        int heightOfTaskbar = 0;
        try {
            Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(comp.getGraphicsConfiguration());
            heightOfTaskbar = scnMax.bottom;
        } catch (Exception e) {

        }
        return heightOfTaskbar;
    }

Java Resize Images

package com.bospp;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import org.imgscalr.Scalr;

public class ImageResize {

    public static void createResizedImage(String imageActualPath, String imagetargetPath, int imgWidth, int imgHeight) {
        try {
            BufferedImage originalImage = ImageIO.read(new File(imageActualPath));
            BufferedImage resizeImagePng = Scalr.resize(originalImage, imgWidth);

            File file = new File(imagetargetPath);
            file.getParentFile().mkdirs();
            String fileName = file.getName();
            String fileExtention = fileName.contains(".")
                    ? fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : "png";
            ImageIO.write(resizeImagePng, fileExtention, file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void createDir(String fileDirStr) {
        File fileDir = new File(fileDirStr);
        if (!fileDir.exists() && !fileDir.mkdirs()) {
            System.out.println("Can't create directory. Check permissions");
        }
    }
   
    public static void main(String args[]){
        createResizedImage("/home/rahul/Documents/assets/photo.jpg", "/home/rahul/Documents/assets/yes.jpg", 100, 100);
    }
}

ionic change android class name

You have to follow following steps:

1. Change in AndroidMnifest.xml

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="SoftwareCostEstimation" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">

2. Change in build.xml

<project name="SoftwareCostEstimation" default="help">

3. Change the name of file and class name

Change the CordovaApp.java to SoftwareCostEstimation.java

and don't forget to change the name of class like:

public class SoftwareCostEstimation extends CordovaActivity

Run ionic build android

Doing this your generated apk name will be changed according to project name.

ionic change application package name

Go to config.xml and change the value of id attribute like:

<widget id="com.bospp.softwarecostestimation" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>SoftwareCostEstimation</name>
  <description>
        An Software Cost Estimation App
    </description>
  <author email="rahul@bospp.com" href="http://bospp.com/">
      Rahul Jain
    </author>

...
...
...

</widget>

After changing values you have to run ionic build android command.

Also you can change other values like email, author etc.