Screen 1) When you click this Munch Screen Button the whole view of this Activity will save into BittmapDrawab
Screen 2) Final Screen shots
/** layout */
screen_shots.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/LinearLayout01"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/munch"
android:id="@+id/munchscreen"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/screenshots"
android:contentDescription="@string/app_name"
/>
</LinearLayout>
/** Activity Class */
CaptureScreenShots.java
package com.screen.shots;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class CaptureScreenShots extends Activity {
LinearLayout L1;
ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen_shots);
L1 = (LinearLayout) findViewById(R.id.LinearLayout01);
Button but = (Button) findViewById(R.id.munchscreen);
but.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View v1 = L1.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
image = (ImageView) findViewById(R.id.screenshots);
image.setBackgroundDrawable(bitmapDrawable);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.screen_shots, menu);
return true;
}
}
/** values/strings.xml */
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="app_name">ScreenShots</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="munch">Munch Screen</string>
</resources>
You can download Source code here
Hi... Amit Gupta!
ReplyDeleteon which software ( windows) you running this????????? The screen shots you published herabove........
Using ADT we can run this code
DeleteI'm making a simple app, that takes a photo and saves it in a file, for that I've used this http://stackoverflow.com/questions/649154/save-bitmap-to-location
ReplyDeleteThank you so much! Excellent and simple code.
I have tried so many videos all of them while running giving errors in your code its working fine thanks lot for your code can you give me code for continue to send to mail this screen shot.
ReplyDeleteIt's nice that you write about it
ReplyDeleteLaura
Offshore Development Center is helping companies develop quality software at lower costs. Learn how ODC work, and which countries are best suited to host them.
ReplyDeleteThanks for Sharing
ReplyDeleteplastic and reconstructive operating microscope manufacturers in india
dental operating microscope manufacturers in india
ophthalmic operating microscope manufacturers in india
ent crisp-i operating microscope manufacturers in india
ent lumin pro operating microscope manufacturers in india
I enjoyed reading your blog, and it is both instructional and enjoyable.
ReplyDeleteMobile App Development Company
Website Development Company USA: I would suggest you to have website because it can generate more business than android apps.
ReplyDeleteVery informative post. Keep posting
ReplyDeleteDxminds is Mobile app development Company in Chennai for your business. Very unique and creative mobile app developers. Find more here: https://dxminds.com/top-mobile-app-development-company-in-chennai/#
Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? cursos de ti
ReplyDeleteThis blog is very useful for all mobile app developers and your explanation was simply straight to the point and easy to understand. I will definitely try to implement your idea. Thank you for this information!
ReplyDeleteMobile App Development Companies in Chennai
Mobile App Development Company in Chennai
Android Application Development Company in Dubai
iOS application development company in Dubai
Valuable information about mobile application..keep update..
ReplyDelete"Digital Marketing Agency
Best mobile app development services in us
Best cloud erp software developement company in chennai"
Its very informative and great blog about android taking Screen shots through code..Its excellent blog.!!!!!1
ReplyDelete"best cloud computing service providers in brentford
Top DevOps Service companies in chennai
Best Web development company in hyattsville, US"