How to add a common share button in Sketchware?


Sharing text contents or URLs from a Sketchware App is possible using intent, but the data can only be shared using individual urls to emails, facebook, twitter, and other sites which provide a sharing option, individually. But in order to implement a common share button for sharing content, some code is to be added in the project using add source directly block.

Follow the steps below to add a share button in Sketchware App.

1. Suppose you want to share the contents of field Edittext1 as title and of field Edittext2​ as main content. For sharing the contents, first insert a button or an imageview with share icon.

2. In LOGIC area, in the onClick event for button, which is to be used as share button, add two string variables a and b.

3. Set string variable a to contents of Edittext1 field, and variable b to contents of Edittext2 field.
4. Add the following code in add source directly block:
Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(android.content.Intent.EXTRA_SUBJECT, a); i.putExtra(android.content.Intent.EXTRA_TEXT, b); startActivity(Intent.createChooser(i,"Share using"));

Note that in the code, i is name of intent, a is name of a string variable, and b is also name of a string variable.

4. Save and run the project.

Here is a video of the same process.

Comments

  1. How to share my application link ?

    ReplyDelete
    Replies
    1. So easy ! Edit text view with your application link and make it invisible

      Delete
    2. Or simply add your app link instead of "a"

      Delete
  2. When I test app and click Facebook messenger to share, nothing happens? :/

    ReplyDelete
  3. how to share audio file or apk file

    ReplyDelete
  4. Add Source Directly Block removed by sketchware developer
    Can I add it as moreblock?

    ReplyDelete
  5. how to paste code in add source directly

    ReplyDelete
  6. How to link Sharing my application link please help me with Source code

    ReplyDelete
  7. tell me about share button for apk 7408052123

    ReplyDelete
  8. I want to send pdf file from internal storage

    ReplyDelete
  9. editview1 does not send. Only editview2 send

    ReplyDelete
  10. How can I share my application using share button?

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware