중립 버튼을 클릭하면 알림 대화 상자의 이미지가 sdcard에 저장되는 앱을 디자인해야합니다. 그래서 프로그램 적으로 스크린 샷을 찍은 다음 BitmapDecodeRegion 클래스를 사용하여 이미지를 자르기로 결정했습니다.스크린 샷의 알림 대화 상자 표시
그러나 스크린 샷을 찍을 때 창에 첨부되어 있지 않으므로 경고 대화 상자에 나타나지 않습니다. 어떻게 창에 붙일 수 있습니까?
public void btnClick(View v) {
Log.d("", "logger button clicked");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("This is a demo!");
dialog.setMessage("Lets see if this works");
dialog.setCancelable(false);
dialog.setNeutralButton("Take Snap",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bitmap bitmap;
View v1 = findViewById(android.R.id.content)
.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
GlobalObj.screenImg = bitmap;
v1.setDrawingCacheEnabled(false);
Intent i = new Intent(MainActivity.this,
ViewActivity.class);
startActivity(i);
}
});
AlertDialog newDialog = dialog.create();
newDialog.show();
이 친절하게 도와 : 여기
는 코드입니다.
다음 링크를 확인하십시오. http://stackoverflow.com/questions/20136121/android-how-to-take-screenshot-programatically – Priya