One of the keys to building a viral app is the ability to share content. This tutorial will guide you through the process of creating a common share button. Please note that this method is for sharing text based content only
Start by creating a new project. If you're not sure how to create a new Sketchware project click here.
Step 1.
Start by dragging your widget onto the screen. This is what the user clicks to share text from your app.
Step 2.
Create a more block with a string variable. The string variable name is "text"
Step 3.
Go to the moreBlock event and add an Add Source Directly block. In the ASD block, place the following code
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT,_text); sendIntent.setType("text/plain"); Intent shareIntent = Intent.createChooser(sendIntent,null); startActivity(shareIntent);
Step 4.
Once that is done, navigate to the event where you want the text to be shared. Add the more block and place the text, textview or an edittext with the text to be shared inside the blank space. This is what will be shared whenever the button is clicked. In the example below, I used an imageview which I renamed "shareicon"
You can now run your app. Whenever you click the button it will allow you to share text.
Comments