CODE FOR SCREEN CAPTURING IN ANDROID

General Android Books.
Also feel free to comment, improve and contribute to AndBook, the free Android Learners book.

CODE FOR SCREEN CAPTURING IN ANDROID

Postby V!j! Neelu » Thu Jul 22, 2010 6:47 pm

Hi all,
Can anybody tell me wats d code for capturing the screen of android mobiles, while we run an application. I need the code for capturing both the application screen and the background screen.
V!j! Neelu
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 22, 2010 6:11 pm

Top

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby jonbonazza » Thu Jul 22, 2010 6:51 pm

1) Why is this in the book section?

2) In order to take screenshots, the phone must be rooted.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby gokberks » Sun Jul 25, 2010 9:20 pm

Code: Select all
private void captureScreen() {
      RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main);
                File root = Environment.getExternalStorageDirectory();
                File file = new File(root,"androidlife.jpg");
      Bitmap b = Bitmap.createBitmap(mainLayout.getWidth(), mainLayout
            .getHeight(), Bitmap.Config.ARGB_8888);
      Canvas c = new Canvas(b);
      mainLayout.draw(c);
      FileOutputStream fos = null;
      try {
         fos = new FileOutputStream(file);

         if (fos != null) {
            b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
            fos.close();
         }
      } catch (Exception e) {
         e.printStackTrace();


can you try this code?
this code create androidlife.jpg on your sdcard folder
gokberks
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Jun 10, 2010 3:22 pm

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby V!j! Neelu » Wed Jul 28, 2010 8:04 am

Thanks for the reply. But i need it without SD card. And in specific i need how to capture for the key events.
Last edited by V!j! Neelu on Wed Jul 28, 2010 8:30 am, edited 1 time in total.
V!j! Neelu
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 22, 2010 6:11 pm

CODE FOR PLAYBACK OF VIRTUAL KEY EVENTS IN ANDROID

Postby V!j! Neelu » Wed Jul 28, 2010 8:08 am

Hi,
I want to know how to code the monkey in android. Am using eclipse software to build it, so i cannot use monkey code directly in to make the application. So how to translate monkey code into pure java… Or else is there any plugins/ special activation needed for monkey in eclipse to use it????

And i want the code for the playback of
1.menu button, 2.call, 3.call end, 4.home, 5.back, 6.up , 7.down, 8.left, 9.right key.

please respond asap..
V!j! Neelu
Freshman
Freshman
 
Posts: 5
Joined: Thu Jul 22, 2010 6:11 pm

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby Charles Elena » Tue Aug 23, 2011 12:35 pm

gokberks wrote:
Code: Select all
private void captureScreen() {
      RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main);
                File root = Environment.getExternalStorageDirectory();
                File file = new File(root,"androidlife.jpg");
      Bitmap b = Bitmap.createBitmap(mainLayout.getWidth(), mainLayout
            .getHeight(), Bitmap.Config.ARGB_8888);
      Canvas c = new Canvas(b);
      mainLayout.draw(c);
      FileOutputStream fos = null;
      try {
         fos = new FileOutputStream(file);

         if (fos != null) {
            b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
            fos.close();
         }
      } catch (Exception e) {
         e.printStackTrace();


can you try this code?
this code create androidlife.jpg on your sdcard folder


Since long time I am looking for same code. Thanks a lot for sharing. My application was stucked behind this.
Charles Elena
Developer
Developer
 
Posts: 33
Joined: Thu May 26, 2011 11:43 am

Top

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby roopa » Thu Sep 15, 2011 10:18 am

You cannot do this from an android app except on a rooted phone, as you don't have permission to access the framebuffer device.
roopa
Developer
Developer
 
Posts: 27
Joined: Wed Sep 14, 2011 6:46 am

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby hgft » Wed Feb 29, 2012 9:59 am

Coach Outlet Online Sale is with imperfections which consist of cuts, scars, and scratches will exist, the grain in its organically grown problem has between one of the most considerable dietary fibers strength, and getting a last end result between one of the most considerable durability. The grain also has organically grown breathability, resulting in increased comfort using the path from the wearer.

Louis Vuitton Outlet could possibly be one of the most well-known is not necessarily one of the most ideal for you! possibly the most current quarter round shoulder bag with fluorescent color provides you a shine in the moment, desire to possess the urge to it immediately; But possibly your pores and skin color could possibly be the earth beside the handbag could possibly be one of the most make you fondle admiringly joker choice.

Louis Vuitton Outlet supply reduce, the weakening from the role, tiny haystack in slender whole body once more and again. the right way to purchase Louis Vuitton bags That's between the powerful cohesion when Cunningham lancelet find yourself isolated point, allow wind and bad weather insulation, yr pursuing year, pile of grass system earlier short increased grass blanketed with it or bi erosion.

Jennifer Garner and Ben Affleck are the proud parents of a newborn son! The 39-year-old actress gave birth to the couple's third child in Santa Monica, Calif., a source tells Us Weekly. The family's newest addition joins older sisters Violet, 6, and Seraphina, 3. “I would have thought [Ben] wanted a boy]. At first … I really thought so,” Jen, who kept the baby's gender under wraps, told Jay Leno last month.
hgft
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Feb 28, 2012 9:11 am

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby sampath_sl » Wed Mar 21, 2012 7:53 am

V!j! Neelu wrote:Thanks for the reply. But i need it without SD card. And in specific i need how to capture for the key events.


Where are you going to save the captured screenshot if not in the sd card.
sampath_sl
Developer
Developer
 
Posts: 35
Joined: Sun Apr 11, 2010 4:45 pm
Location: Colombo

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby aguswgs » Thu Mar 22, 2012 4:33 am

You cannot do this from an android app except on a rooted phone, as you don't have permission to access the framebuffer device.

You can however do it over adb from the DDMS window of your development machine, as adb runs in the graphics group which has permission to the framebuffer.

If you want to do something similar in native code on a rooted device, look at the sources to the adb daemon.

EDIT: It appears this may be changing and there may be non-root capability in more recent android releases, but I'm not sure of the details.
aguswgs
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue Mar 20, 2012 10:08 am
Location: indonesian

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby nobelboy » Sun Jun 09, 2013 1:45 pm

Your article shows you have a lot of background in this topic. Can you direct me to other articles about this? I will recommend this article to my friends as well. Thanks
grammar checker online
nobelboy
Freshman
Freshman
 
Posts: 8
Joined: Sat May 04, 2013 2:27 am

Re: CODE FOR SCREEN CAPTURING IN ANDROID

Postby Strickland » Mon Jul 29, 2013 11:53 am

Google marketed the platform to handset makers and carriers on the promise of providing a flexible, upgradable system. Google had lined up a series of hardware component and software partners and signaled to carriers that it was open to various degrees of cooperation on their part. Thank you.
dissertation editing service
Strickland
Freshman
Freshman
 
Posts: 5
Joined: Mon Jul 29, 2013 11:41 am

success

Postby killop » Thu Oct 24, 2013 10:14 am

This initial-tariff screenwriting book gives a elliptical debut of screenwriting elementarys, beside along ask notes, useful worksheets, checklists, test locales besides again to alleviate you crack toward screenplay book.
dissertation editing
killop
Freshman
Freshman
 
Posts: 6
Joined: Thu Oct 24, 2013 10:10 am

Top

Return to Android Books

Who is online

Users browsing this forum: No registered users and 4 guests