Android 截取(截畫面)本身APP 執行畫面
Android 截取(截畫面)本身APP
執行畫面
XML
<LinearLayout android:id=”@+id/button01″ android:text=”截取當前螢幕“ /> android:id=”@+id/textview” android:text=”當前螢幕“ android:textSize=”20.0sp” android:gravity=”center” </LinearLayout> |
Code
package com.example.android_screen; import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Environment; import android.view.Display; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.Toast; public class MainActivity extends private public super.onCreate(savedInstanceState); initView(); m_context=(Context)this; button01.setOnClickListener(new // Inflate the menu; this adds items getMenuInflater().inflate(R.menu.main, return true; Toast.LENGTH_LONG).show(); File if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ sdCardDir } } |