View Full Version : کد برای گرفتن اسکرین شات از برنامه
EDRIS0131
سه شنبه 07 اردیبهشت 1395, 18:26 عصر
با عرض سلام
دوستان متاسفانه با سرج به نتیجه ای نرسیدم
(سرچ انگلیسی مطلب زیاد بود ولی خوب چون موبایل ندارم تا تسکت کنم دیدم بهتره کد ها رو تست نکنم مخصوصا با این پی سی عذاب آورم)
------------------------
چطور میشه مثل عکس زیر یه دکمه گذاشت که اسکرین شات بگیره از برنامه ؟؟
140145
اینم لینک تاپیک مربوط به برنامه
http://barnamenevis.org/showthread.php?469134-%D9%86%D8%B4%D8%A7%D9%86-%D9%86%D8%AF%D8%A7%D8%AF%D9%86-%D9%82%D8%B3%D9%85%D8%AA%DB%8C-%D8%A7%D8%B2-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D8%AF%D8%B1-%D8%A7%D8%B3%DA%A9%D8%B1%DB%8C%D9%86-%D8%B4%D8%A7%D8%AA (http://barnamenevis.org/showthread.php?469134-%D9%86%D8%B4%D8%A7%D9%86-%D9%86%D8%AF%D8%A7%D8%AF%D9%86-%D9%82%D8%B3%D9%85%D8%AA%DB%8C-%D8%A7%D8%B2-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D8%AF%D8%B1-%D8%A7%D8%B3%DA%A9%D8%B1%DB%8C%D9%86-%D8%B4%D8%A7%D8%AA)
با تشکر
hamed9090
سه شنبه 07 اردیبهشت 1395, 18:43 عصر
private void takeScreenshot() { Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString () + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
hamed9090
سه شنبه 07 اردیبهشت 1395, 19:08 عصر
private void takeScreenshot() {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString () + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
hamed9090
سه شنبه 07 اردیبهشت 1395, 19:16 عصر
private void takeScreenshot() { Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString () + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
} }
EDRIS0131
سه شنبه 07 اردیبهشت 1395, 19:35 عصر
همه ی این کدها هستش؟؟؟؟
فرقشون با هم چیه؟
EDRIS0131
سه شنبه 07 اردیبهشت 1395, 19:42 عصر
بعد مثلا باید اینطوری بنویسم ؟
Button GIVESCREEN = (Button) findViewById(R.id.button1);
// کد مورد نظر برای اسکرین شات
.....
یا اینطوری
Button GIVESCREEN = (Button) findViewById(R.id.button1);
GIVESCREEN.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// کد مورد نظر برای اسکرین شات
------------------
حالا اگه بخوام این کار فقط با زدن دکمه ی سخت افزاری عکاسی خود موبایل انجام بشه راهی هست که دیگه نیاز نباشه یه دکه تعیین کنم براش؟؟؟؟
hamed9090
سه شنبه 07 اردیبهشت 1395, 19:45 عصر
نه از آخری استفاده کن اونا یکی هست مشکل پیدا کرد چندبار زدم
فقط پرمیزن نوشتن تو حافظه هم اضافه کن
EDRIS0131
سه شنبه 07 اردیبهشت 1395, 19:52 عصر
نوشتن تو حافظه چطوری اضافه کنم؟؟؟؟؟؟؟
باید تو مانی فست اضافه کنم؟؟؟؟
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.