Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling the Share Action Provider in Android

enter image description here

Here is how I share the content through Share Action Provider:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
                    "Check the Link  : " + url);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share with"));

I want to style the share with window. I want to change the text color and highlighter line color from default blue color to my custom color. I am using Holo light theme. I don't know how to style those elements. Can anyone point out a reference to do that?

Is there a way to access attributes of android.widget.ShareActionProvider through styling?

like image 597
intrepidkarthi Avatar asked Oct 05 '22 10:10

intrepidkarthi


1 Answers

I don't know how to style the dialog, i have seen different layouts in different devices. But you can use PackageManager.queryIntentActivities(Intent intent, int flag) to get all activities that could handle this intent. And use the list data to create your own chooser.

EDIT: a demo

    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://www.google.com"));
    PackageManager pm = getPackageManager();
    final List<ResolveInfo> infos = pm.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
    CharSequence[] names = new CharSequence[infos.size()];
    for (int i = 0; i < infos.size(); i++) {
        names[i] = infos.get(i).loadLabel(pm);
    }
    new AlertDialog.Builder(this).setItems(names,
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ResolveInfo info = infos.get(which);
                    intent.setClassName(info.activityInfo.packageName,
                            info.activityInfo.name);
                    startActivity(intent);
                }
            }).show();
like image 108
faylon Avatar answered Oct 10 '22 02:10

faylon