Make Custom Android Launcher

Image
There are thousands of Android Launcher available in Play Store. Each and every Android mobile user loves to customize their mobile with different Android Launcher. If you want to develop your own launcher, this post helps you to fulfill your wish. In this post, you will find a demo launcher with layout and code which include many features like Drag & Drop , rearrange the installed application, change the background wallpaper etc. Here is an example of demo launcher which display all the installed applications in 3*3 Grid View format compatible to all devices. First of all we need to find all the installed applications from device so we should implement a subclass of AsyncTaskLoader that loads the currently installed applications from the package manager. If you want to display all the installed applications in  List View you can use official Android Developer reference .

Broadcast Receiver

In Android, Broadcast Receiver is a process of broadcasting particular event and receiver performs an action related to that event.
When system/application broadcasts event (An event consists of particular message/intent), it triggers the receiver to execute service, activity or other application.
Broadcast Receiver not actively running in memory.
Ex: Create a subclass of the BroadcastReceiver class.
public class ReceiverCls extends BroadcastReceiver  {

         @Override
         public void onReceive(Context context, Intent intent)  {
               Toast.makeText(context, intent.toString(), Toast.LENGTH_LONG).show();
          }
      }
//Here, intent.toString() returns a String like, Intent { act=Custom_Action cmp=com.YourPkgName/.ReceiverCls }
Now, We need to register Receiver class in AndroidManifest file.
<application>
     <receiver android:name="ReceiverCls">
            <intent-filter>
                <action android:name="Custom_Action"/>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
     </receiver>
</application>
As shown in the code, there are two actions for the ReceiverCls class in which "android.intent.action.BOOT_COMPLETED" action provided by Android itself and another is custom action which performs when button clicked.
Now, we add a button in the layout file.
<Button android:onClick="custom_intent" />
Now, Implement the custom_intent() method in a subclass of Activity class.
public void custom_intent(View v) {
  Intent i=new Intent();
  i.setAction("Custom_Action");
  sendBroadcast(i);
}

Comments

Popular posts from this blog

Make Custom Android Launcher

Layouts for Fragment