Back to project page FlashAndroid.
The source code is released under:
GNU General Public License
If you think the Android project FlashAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package flash.android.singlehand; /*from w ww . ja va 2s. c o m*/ import android.app.ActivityGroup; import android.content.Intent; import android.graphics.Bitmap; import android.view.View; import android.view.Window; import android.widget.RelativeLayout; public class ActivityContainer extends ActivityGroup { private RelativeLayout m_layout; public void setLayout(RelativeLayout p_layout) { this.m_layout = p_layout; } public void launchActivity(String id, Class<?> activityClass) { m_layout.removeAllViews(); Intent intent = new Intent(ActivityContainer.this, activityClass); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); Window window = getLocalActivityManager().startActivity(id, intent); View view = window.getDecorView(); m_layout.addView(view); } public Bitmap getScreenshot(View p_view) { p_view.clearFocus(); // ?????? p_view.setPressed(false);// ???????????? boolean willNotCache = p_view.willNotCacheDrawing(); // ????????????????????? p_view.setWillNotCacheDrawing(false); // Reset the drawing cache background color to fully transparent // for the duration of this operation //?????????????? int color = p_view.getDrawingCacheBackgroundColor(); // ?????????????? p_view.setDrawingCacheBackgroundColor(0); // ???????? if (color != 0) { // ???????????????????????? p_view.destroyDrawingCache(); // ????????????? } p_view.buildDrawingCache(); // ??????????????????? Bitmap cacheBitmap = p_view.getDrawingCache(); // ????????,???????????????????? if (cacheBitmap == null) { return null; } Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ??????? // Restore the view //??????? p_view.destroyDrawingCache();// ??????? p_view.setWillNotCacheDrawing(willNotCache);// ????????? p_view.setDrawingCacheBackgroundColor(color);// ???????????? return bitmap; } }