App sharing button in sketchware | tutorial

App sharing button in sketchware | tutorial

How to add a app sharing button in sketchware ?

Hi friends welcome to another sketchware tutorial. Today I will show you, how to create a button that shares your app ina apk format. This tutorial is going to be very short and interesting. The coding part is very less and not very complex. Before that you can check this tutorial to share any text of your app. A common sharing button in sketchware.

Remember do not mess or change this codes. Unless you know coding. Editing code without proper knowledge may crash your app.

Follow this below steps

Step No. 1 : setup your main.xml file or the view

In sketchware you can use a image or any button to act as a button. I have used imageView to make the app sharing button in sketchware. You can can go with any option.

Now go to the ImageView on click event and set this code using the add source directly block. Code:


Step No. 2 : create the required more blocks

Create a more block called share and paste the below code using the add source directly block.

}private void shareApplication() { app
String appLoc = app.sourceDir;
Intent intent = new
intent.setType("/"); originalApk = new;
try { tempFile = new + "/ExtractedApk");
if (!tempFile.isDirectory())
if (!tempFile.mkdirs())
tempFile = new + "/" +"your app name.apk");
if (!tempFile.exists())
if (!tempFile.createNewFile()){
return; }
catch ( e){}
} in = new (originalApk); out = new;
byte[] buf = new byte[1024];
int len;
while ((len = > 0) {
out.write(buf, 0, len);
startActivity(Intent.createChooser(intent, "Share app via"));
catch ( e)
{ showMessage(e.toString());

You can replace the name.apk with your app’s name. This name will be shown when you will share the app

Step No. 3 : setup on create event

Go to on create event and paste this code.

StrictMode.VmPolicy.Builder builder
new StrictMode.VmPolicy.Builder();
java.lang.reflect.Method m =
catch(Exception e){

Now just run the application. Hope every thing will go fine. if you got any error, then try to remove the spaces from the codes. Maybe while coping the codes. spaces are also gets copied. And shows you error.

Also note that it will also save the application as an apk file in your local cached directory.

For me it is Storage/emulated/0/Android/data/


Let me know your views, suggestions and problems in the comment section.

Thanks for reading.

This Post Has 5 Comments

  1. Adebisi-Lawal

    It brought out error asking me to add “;” to complete block statement.

    1. Kaushik

      Hi there please remember while coping code, check that whether you have copied the whole code or not. Sometimes when you long press and try to copy the code, the “;” symbol may not get copied.
      I think when copied this part “shareApplication();” you have missed that “;”. Please recheck and confirm whether you still get errors or not. Thank you

  2. Adebisi-Lawal

    I have done it. But when I built the apk. I was told no app cam perform the action

    1. Kaushik

      Ooo that’s good. You can share it here so that Other users can get benifit of it. Thanks.

Leave a Reply