Tuesday 26 July 2016

AppMaster Lite - Solution for your mobile memory management


If you’re looking for some nice application tool for your android mobile then AppMaster Lite is here. Manage your apps, storage management, clear cache , move apps to SD and much more with Lite size app. This app contains NO ADS.

1. Are you facing Internal memory full issue?
2. Are you unable to clear unwanted cache data of your mobile?
3. Do you want to store / move your apps in to External SD card?
4. Do you have the clear listings of Installed apps and System apps?

If you’re facing above problems in your android mobile then AppMaster Lite is one solution.






1. View Storage uses in Android 


This is the landing screen of app, where you can see the both internal and SD card memory uses in Pie chart representation. Chart value shows the percentage uses of memory. Below of charts you can see the numerical value of used memory.




2. Clear cache data of Android mobile

This option is available at the bottom of Storage screen tab. Cache memory is the garbage data of the applications which are not at all useful. If you don’t delete cache data at regular intervals then it will full the internal memory and your mobile will face ‘Insufficient Storage’ Message during downloading any app form PlayStore. Cache data also slow down the mobile speed.
If you want to clear cache data then click on given option this will navigate to internal memory setting where you can clear cache by following the guides. Since android os has put restriction to third party app to not clear cache data directly so user should manually clear the cache data (After Marshmallow version).

3. Move apps to SD card


This screen only shows the list of movable apps. All the installed apps can’t be moved to SD card because of properties set in the application by developer. Once you click move icon it will open the storage option and you can move you applications to free some internal storage. 


4. Uninstall application in one tap 


Installed apps contains the list of application which are installed by users. List also shows the occupied memory by app. Delete button uninstalls the app.


5. View only System apps in android


System apps list only contains the already installed apps. User can’t uninstalled the these apps. For more information tap on info icon.


6. Other features in AppMaster Lite

Rate us, share apps, About and other useful features also has been added in side navigation.

7. No Ads

This app doesn’t contain any ads. So users don’t get any disturbance in using time. 
This is an awesome too to manage memory in android mobile and speed up the process speed. Download for free.

Please feel free to comment for any clarification or suggestion.



Tuesday 19 July 2016

Android AD authentication, JNDI Sample to check user in Active Directory (AD)

If you are creating some mobile app to allow only for users who are listed in company Active Directory, then JNDI implementation can be the better approach for login. In this approach user should login with their AD credentials in mobile app. App will send request to AD to check whether user is listed in AD or not. 
This method is more secure and protective. The best advantage is, you don’t need to create separate table in backend database to track users. If you have to block user then just remove from AD. Below is the code sample with JNDI:
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

public class AuthenticationClass {

public static void main(String[] args) {

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION"simple");
env.put(Context.PROVIDER_URL"ldap://AD_IP:port_no");
env.put(Context.SECURITY_PRINCIPAL"username");
env.put(Context.SECURITY_CREDENTIALS"password");
 
DirContext ctx;

try {
    // Authenticate the logon user
    ctx = new InitialDirContext(env);
 
    /**
     * Once the above line was executed successfully, the user is said to be authenticated and the InitialDirContext object will be created. IF user not found then it will throw exception.
     */
    System.out.print("Authenticated");
 
catch (NamingException ex) {
    // Authentication failed, just check on the exception and do something about it.
System.out.print("Authentication failed: "+ex.getMessage());
ex.printStackTrace();
}
}
}
This is very easy to implement and code size is also less.
Please feel free to comment for any clarification or suggestion.
***

Tuesday 12 July 2016

XSSFWorkbook Create CellStyle using POI in java, excel sheet style POI tutorial

We can create custom cell style in excel sheet using POI. We can change text alignment, font color, size etc. Here is my sample design:
 
Steps to create CellStyle
1. Create Row and column (Cell) using XSSFWorkBook.
2. Create CellStyle using XSSFWorkBook.
3. Create Font and set color, size etc.
4. Set CellStyle into Cell.

1. Create Row and column (Cell) using XSSFWorkBook.
Get the excel file from your system path and create workbook object. You can call this method where ever you need: 
public void excelDesignWork() {

try {
    FileInputStream input = 
            new FileInputStream(new File("D:\\TestFile.xlsx"));
   
    XSSFWorkbook workbook = new XSSFWorkbook(input);
    XSSFSheet worksheet = workbook.getSheetAt(0); 
                
createCellStyle(workbook, worksheet);   
             
                 input.close(); //Close the InputStream
       System.out.println("Excel Updated.");
    
    //Override the sheet
    exportExcelSheet(workbook);
   
catch (FileNotFoundException e) {
    e.printStackTrace();
catch (IOException e) {
    e.printStackTrace();
}catch (Exception e) {
    e.printStackTrace();
}
}

Create XSSFRow and Cell
public void createCellStyle(XSSFWorkbook workbook, XSSFSheet worksheet) {
Int rowIndex =3;//index of row where you want to create row.
Int cellIndex =2;//index of cell where you want to create cell.
XSSFRow row = worksheet.createRow(rowIndex ); 
Cell myCell = row.createCell(cellIndex );
}
2. Create CellStyle using XSSFWorkBook.
Creating cellStyle, set alignment and forground color: 
//Create Cell Style
CellStyle cellStyleName = workbook.createCellStyle();
cellStyleName.setAlignment(CellStyle.ALIGN_LEFT);
cellStyleName.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
cellStyleName.setFillPattern(CellStyle.SOLID_FOREGROUND);
3. Create Font and set color, size etc.
Creating custom font for cellStyle: 
Font font = workbook.createFont();
font.setFontName("Calibri Light");
font.setFontHeight((short)225);//equivalent to size 11 in MS sheet.
Color color =new Color(1,169,219);//RGB color
((XSSFFont) font).setColor(new XSSFColor(color));
4. Set CellStyle into Cell.
cellStyleName.setFont(font);
myCell.setCellStyle(cellStyleName);
myCell.setCellValue("My Custom Style");

Complete code: 

public void excelDesignWork() {

try {
    FileInputStream input = 
            new FileInputStream(new File("D:\\TestFile.xlsx"));
   
    XSSFWorkbook workbook = new XSSFWorkbook(input);
    XSSFSheet worksheet = workbook.getSheetAt(0); 
                
createCellStyle(workbook, worksheet);   
             
                 input.close(); //Close the InputStream
       System.out.println("Excel Updated.");
    
    //Override the sheet
    exportExcelSheet(workbook);
   
catch (FileNotFoundException e) {
    e.printStackTrace();
catch (IOException e) {
    e.printStackTrace();
}catch (Exception e) {
    e.printStackTrace();
}
}
/**
 * Design CellStyle 
 *
 */
public void createCellStyle(XSSFWorkbook workbook, XSSFSheet worksheet) {
Int rowIndex =3;//index of row where you want to create row.
Int cellIndex =2;//index of cell where you want to create cell.
XSSFRow row = worksheet.createRow(rowIndex ); 
Cell myCell = row.createCell(cellIndex );

//Create Cell Style
CellStyle cellStyleName = workbook.createCellStyle();
cellStyleName.setAlignment(CellStyle.ALIGN_LEFT);
cellStyleName.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
cellStyleName.setFillPattern(CellStyle.SOLID_FOREGROUND);
//Create Font
Font font = workbook.createFont();
font.setFontName("Calibri Light");
font.setFontHeight((short)225);//equivalent to size 11 in MS sheet.
Color color =new Color(1,169,219);//RGB color
((XSSFFont) font).setColor(new XSSFColor(color));
//Set cellStyle
cellStyleName.setFont(font);
myCell.setCellStyle(cellStyleName);
myCell.setCellValue("My Custom Style");
}
/**
 * Export excel sheet into system location
 * @param workbook 
 */
public void exportExcelSheet(XSSFWorkbook workbook) {
try {
    FileOutputStream out = 
            new FileOutputStream(new File("D:\\TestFile.xlsx"));
    workbook.write(out);
    out.close();
    System.out.println("Excel written successfully..");
     
catch (FileNotFoundException e) {
    e.printStackTrace();
catch (IOException e) {
    e.printStackTrace();
}
}
Note: You need to use below jars for above integration :
1. Poi 3.14 or above : download 
2. Commons-io-2.4.jar
Please feel free to comment for any clarification or suggestion.
***