intrepidkarthi
intrepidkarthi

Reputation: 3102

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?

Upvotes: 6

Views: 2122

Answers (3)

Ram
Ram

Reputation: 1428

You can also use like this

        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT,getString(R.string.app_name));
        intent.putExtra(android.content.Intent.EXTRA_TEXT,getString(R.string.tell_your_frnd));
        PackageManager pm = getPackageManager();
        final List<ResolveInfo> infos = pm.queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        name = new String[infos.size()];
        image=new Drawable[infos.size()];
        for (int i = 0; i < infos.size(); i++) 
        {
            name[i] = (String) infos.get(i).loadLabel(pm);
            image[i]=infos.get(i).loadIcon(pm);
        }


        CustomGrid adapter = new CustomGrid(ShareActivity.this,name,image);
        mGridView.setAdapter(adapter);

        mGridView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
        {

            ResolveInfo info = infos.get(position);

            intent.setClassName(info.activityInfo.packageName,
                    info.activityInfo.name);
            startActivity(intent);
        }
    });

Upvotes: 0

faylon
faylon

Reputation: 7450

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();

Upvotes: 2

Franci Penov
Franci Penov

Reputation: 75981

As far as I know, you cannot style the chooser dialog. It is a system-level actvity, and uses the default system theme.

Upvotes: 1

Related Questions