First , using function take screen shot..in current activity.
using :
private void takingScreenshot()
{
content = findViewById(R.id.layoutroot);
Bitmap bitmap = content.getDrawingCache();
File file = new File( Environment.getExternalStorageDirectory() +"test.png"); try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
Toast.makeText(GameOver.this, "Take sceen shot", Toast.LENGTH_SHORT).show();
}
//remember: using name of image to share : like "test.png"
And then..using this function to share image....
2 | private void shareImage() { |
You can share your URL .. follows function below ....
private void shareTextUrl() {
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
share.putExtra(Intent.EXTRA_SUBJECT, "Title Of The Post");
share.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/developer?id=ThanhCS94");
startActivity(Intent.createChooser(share, "Share text to..."));
}
No comments:
Post a Comment