How to make custom share via screen in android

▼魔方 西西 提交于 2019-12-10 11:05:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!