Intent - Share Text

Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "*Contents*"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "*title*"); startActivity(Intent.createChooser(shareIntent, "*Window name*"));



//Example 2


// Add edittext1 and edittext2

try { java.io.File myFile = new java.io.File(getExternalCacheDir() + "/" + edittext1.getText() + ".txt"); myFile.createNewFile();
java.io.FileOutputStream fOut = new java.io.FileOutputStream(myFile);
java.io.OutputStreamWriter myOutWriter = new java.io.OutputStreamWriter(fOut);
myOutWriter.append(edittext2.getText());
myOutWriter.close();
fOut.close();

Intent email = new Intent(Intent.ACTION_SEND);
email.setType("*/*");
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new java.io.File(getExternalCacheDir() + "/" + edittext1.getText() + ".txt")));
startActivity(Intent.createChooser(email, "Save or Share"));

Toast.makeText(getBaseContext(), "Save As: " + edittext1.getText() + ".txt", Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to enable download in webview in Sketchware apps?

Create Stopwatch App in Android using Sketchware

A Flash Light App in Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Firebase Login/Register with email verification

Codes for modifying Action Bar in Sketchware

Code for implementing Notifications in Sketchware