This code shows default share dialog
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/html");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Message"));
startActivity(Intent.createChooser(sharingIntent,"Share using"));
Question: Instead of showing the list of applications in the default system dialog, I want to get the list of applications and show them in my custom list.
So instead of the usual popup that shows applications in a list you want a custom popup that shows the applications in a grid view?
This is possible by creating a popup with a grid view yourself. Regardless of it being a share action. Then build a list of applications you would like to show. You can get these using the
resolveActivity
method fromIntent
(or see Swayam's answer).Then use that list to populate the grid view.
Use the PackageManager with the Intent to get the list of applications which can listen to the SEND intent. From the list of applications returned, get the details you would like to display, eg. the icon, name, etc. You would need the package name to launch the app when the user clicks on it.
After you have this set of application details, you can use this in the Adapter of your GridView and show the details.