Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Monday, 7 November 2016

EcomSample - Sample e-commerce Online Shopping App like flipkart, snapdeal, amazon

When ever I used to open any online shopping app, I wanted to know the the mechanism behind loading items, images, data which are not in some limited size. As an Android developer I can understand that many beginners would be thinking to make android app like flipkart, snapdeal or amazon etc. So here is the EcomSample app with complete source code available in github. Sample app is available on PlayStore. 

Download Source Code

Install App 


This app has below features:
1. Loading and caching images with RecyclerView and CardView.
2. Add to Cart and Wishlist, manage cart and wishlist.
3. Category wise items/products loading and caching in list.
4. Detailed item description.
5. All other options available in side Navigation Drawer.
6. Introslider at starting of application.
6. Material design based app.

Screen shots:




  











































































Note: Please consider the below points

1. The images are downloading from this site: https://www.pexels.com, But you can provide your own server urls to load the image.
2. Item description I have just hard coded only for showcase.

Please feel free to comment for any clarification or suggestion.
***

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.
***

Monday, 4 July 2016

Android get the list of all installed apps with icons

We can get the list of all installed apps by Using PackageManager class. We can get the application name, package name, version no, icon etc using this class. In below example i have checked ApplicationInfo.FLAG_SYSTEM=0 which will exclude system apps. I you want to keep system app also in your list then disable this check. 



Steps to get installed application in Android

1. Create PackageInformation class.
2. Create Custom Adapter to handle list.
3. Design XML layout for list.
4. Access PackageInformation from MainActivity.

1. Create PackageInformation class.
This class has method getInstalledApps, this method is using PackageManager to get all the installed apps excluding system apps.

PackageInformation.java
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by mukeshk on 6/15/2016.
 */
public class PackageInformation {
    private Context mContext;

    public PackageInformation(Context context) {
        mContext = context;
    }

    /*
    * Get all the installed app excluding system apps
    * */
    public ArrayList<InfoObject> getInstalledApps() {
        ArrayList<InfoObject> listObj = new ArrayList<InfoObject>();
        final PackageManager packageManager = mContext.getPackageManager();
        List<ApplicationInfo> packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
        for (ApplicationInfo applicationInfo : packages) {
            if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                InfoObject newInfo = new InfoObject();
                newInfo.appname = applicationInfo.loadLabel(packageManager).toString();
                newInfo.packagename = applicationInfo.packageName;
                newInfo.icon = applicationInfo.loadIcon(packageManager);
                newInfo.launchactivity = packageManager.getLaunchIntentForPackage(applicationInfo.packageName);
                listObj.add(newInfo);
            }
        }
        return listObj;
    }

 
    class InfoObject {
        public String appname = "";
        public String packagename = "";
        public Intent launchactivity;
        public Drawable icon;
    }
}

2. Create Custom Adapter to handle list.
CustomAdapterAppList.java

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by mukeshk on 6/15/2016.
 */
public class CustomAdapterAppList extends BaseAdapter {
    private ArrayList<PackageInformation.InfoObject> mObjectApps;
    private Context mContext;

    public CustomAdapterAppList(Context context, ArrayList<PackageInformation.InfoObject> apps) {
        this.mContext = context;
        this.mObjectApps = apps;
    }

    @Override
    public int getCount() {
        return mObjectApps.size();
    }

    @Override
    public Object getItem(int position) {
        return mObjectApps.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
        convertView = inflater.inflate(R.layout.layout_adapter_custom_app_list, parent, false);
        holder = new ViewHolder();
        holder.appName = (TextView) convertView.findViewById(R.id.text_app_name);
        holder.appIcon = (ImageView) convertView.findViewById(R.id.image_app_icon);
        holder.appOption = (ImageView) convertView.findViewById(R.id.image_option);
        //Set values
        final PackageInformation.InfoObject infoObject = mObjectApps.get(position);
        holder.appName.setText(infoObject.appname);
        holder.appIcon.setImageDrawable(infoObject.icon);
        //Click action for app
        holder.appOption.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Open the specific App Info page:
                String packageName = infoObject.packagename;
                try {
                    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.setData(Uri.parse("package:" + packageName));
                    mContext.startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    //Open the generic Apps manager
                    Intent intent = new Intent(Settings.ACTION_SETTINGS);
                    mContext.startActivity(intent);
                }
            }
        });
        return convertView;
    }

    private class ViewHolder {
        TextView appName;
        TextView appVersion;
        ImageView appIcon;
        ImageView appOption;
    }
}

3. Design XML layout for list.
layout_adapter_custom_app_list.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              tools:context=".MainActivity">

    <!-- list row   -->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="3"
            android:padding="10dp">

                <ImageView
                    android:id="@+id/image_app_icon"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center|left"
                    android:layout_weight=".5"
                    tools:ignore="ContentDescription"/>

                    <TextView
                    android:id="@+id/text_app_name"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:layout_marginLeft="10dp"
                    android:text="App name" />
                    <ImageView
                        android:id="@+id/image_option"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center|left"
                        android:layout_weight=".5"
                        tools:ignore="ContentDescription"/>

            </LinearLayout>
        </LinearLayout>
4. Access PackageInformation from MainActivity.
MainActivity.java
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;


public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ListView listViewApps=(ListView)findViewById(R.id.list_app);

        //Get the information of all the installed application in device
        PackageInformation packageInformation=new PackageInformation(MainActivity.this);
        ArrayList<PackageInformation.InfoObject> apps= packageInformation.getMovableApps();

        CustomAdapterAppList adapterAppList=new CustomAdapterAppList(MainActivity.this,apps);
        adapterAppList.notifyDataSetChanged();
        listViewApps.setAdapter(adapterAppList);

    }
 }

Run the application and you can see the list of applications. 

Please feel free to comment for any clarification or suggestion.
***