Styling Share Action Provider on Android

enter image description here

This is how I share content through the 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 a style using a window. I want to change the text color and the highlight color of the label from the default blue to my custom color. I use the light Holo theme. I do not know how to style these elements. Can anyone point a link to this?

Is there any way to access android.widget.ShareActionProvider attributes through style?

+4
source share
3 answers

As far as I know, you cannot customize the selection dialog. This activity is at the system level and uses a standard system theme.

+1
source

I don’t know how to set up a dialogue, I saw different layouts on different devices. But you can use PackageManager.queryIntentActivities(Intent intent, int flag) to get all the actions that could handle this intention. And use the list data to create your own selection.

EDIT: 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(); 
+3
source

You can also use 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); } }); 
0
source

All Articles