问题
My app has one share feature. So while click on share it should show the list of apps to be shared with. Right now I am using this code
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
and it is showing the dialog like this
But what I need is , I need to show the share dialog like a grid view like this. Is it possible to do so? How can I customize the share dialog window
回答1:
you have to create custom dialog for that. put this listview in some dialog.
refer this :
https://github.com/soarcn/BottomSheet
use this code to get available items of ACTION_SEND
Intent galleryIntent = new Intent(Intent.ACTION_SEND);
List<ResolveInfo> listGel = context.getPackageManager().queryIntentActivities(galleryIntent, 0);
for (ResolveInfo res : listGel) {
Log.e("package",res.activityInfo.packageName);
Log.e("name",res.activityInfo.name);
Log.e("proname",res.loadLabel(context.getPackageManager()).toString());
}
and as other option of bottomSheet you can have custom listview also, which will popup from bottom of screen.
来源:https://stackoverflow.com/questions/32202907/how-to-make-custom-share-via-screen-in-android