Posts

Showing posts with the label Twitter

Android App - Adding A "share" Button To Share The App On Social Networks

Answer : Solution 1: Launch ACTION_SEND Intent When launching a SEND intent, you should usually wrap it in a chooser (through createChooser(Intent, CharSequence)), which will give the proper interface for the user to pick how to send your data and allow you to specify a prompt indicating what they are doing. Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); # change the type of data you need to share, # for image use "image/*" intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, URL_TO_SHARE); startActivity(Intent.createChooser(intent, "Share")); Solution 2: Use ShareActionProvider If you are just looking to add a Share button in Overflow Menu, also have a look at ShareActionProvider. public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.share, menu); MenuItem item = menu.findItem(R.id.share_item); actionProvider = (ShareActionProvider) item.getActionProvider(); // Cre...