How to take a screenshot on android 4.0+ - android

I heard that Android 4.0+ support user to capture screenshot without root. So, I think that It must provide some APIs that help developers build this feature to their app, Right? If it have, Could you please tell me what they are?

There is no API for an app to take a screenshot. The screenshot is placed into a standard folder, but some devices use different folders, and there is no API to get the correct folder name.
Users can take screenshots by pressing volume-down and power on most phones. On Some devices it is done by power+home, on some by hand swipe. There is no API to tell how to take a screenshot on the current device.

Related

How do I ensure that the layout on android studio matches the output on the emulator?

I don't know the answer to the question posted at https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=155879.
How do i sort it out please as I was kindly asked to refer this and other questions here?
For one, your emulator is using a Nexus 5 layout, and your preview is using a nexus 4. This is causing the difference
For two, please don't link to external sites with your question, but posting it directly on SO it ensures that others who come in the future will be able to see the question (what happens if the external site goes down, or changes it's link structure)
For three, please make your layout flexible to different screen sizes as you will not be able to control what devices your users will be running your app on. (unless you are only using this app in a controlled environment, and not releasing it to the public)

How to take a good quality screenshot on emulator?

I don't have a tablet but I wanted to take screenshots from the emulator for display in Google Play. I did that using Eclipse (using the method given in the top answer here How to take emulator screenshots using Eclipse?) but the screenshots are not good quality: the image is broken (some areas are kind of shifted) in at least one spot each time I take a screenshot.
Is there any better way to do it?
According to this answer that is an emulator issue. To solve this, you need to enable the 'use host GPU' setting when creating an emulator, according to another answer.
I would use the DDMS shipped with ADT (also listed as Debug monitor) and choose the device and app, then click that camera icon. It creates very good looking screenshots.
I also got some rendering errors with the emulator... It's best with actual devices. You can also try if other images/emulators perform better.

How to make sure that your application will be compatible with range of devices?

In Google play (app market), if an application is not compatible to your device (for some reason, say small screen size, etc). Then it is not even shown in the list.
Now, as an app developer I never want to unintentionally add a limitation in my app that forbids it from a range of devices.
So, while developing how can I make sure that the application will be able to run on atleast the type of devices that I intend.
Also, right now I'm developing an app & testing it in on my phone with version 2.3.5. And every now & then Google changes some method names & flags.
For newer android releases, I CAN test it on emulator, but testing it on phone/tabs/etc. is a different thing.
Please suggest.
how can I make sure that the application will be able to run on atleast the type of devices that I intend.
In manifest file you can mention, which type of device you want to run your app. And for testing you can create emulators for different devices to test your app. Try to make app UI such that it runs on all devices.
Google changes some method names & flags
Whenever Android changes any thing it will always be upward compatible means if you have made app for 2.2 it will run on 2.2 and above (screen size or resolution is other thing)
Regarding UI see my answer here
Layout for 720*1280 devices
By default apps will be available to as wide a range of users as possible.
There are certain limitations you can define in your manifest file, such as not being available on small screen sizes, but they are at your discretion.
The only limitation Google imposes on you is that any user who has a lower Android version than your minimum SDK version cannot see your app. To get around this, you can either design the app for lower SDK versions (I believe building for 2.2 and up gives you access to about 95% of the user base) or maintain multiple versions of the APK.
Read this. It will really help. Next Eclipse will help you a lot, firstly you can define what you wish to support (screen sizes and hardware requirements or even if they're not necessary but may be used) in the manifest. You can run a version check and implement APIs dependent on which version of Android you're running on. That's personally what I do, I check the API level and if it's greater than or equal to the API I wish to run I run it, otherwise I attempt to find compatible code (often using the compatibility library) or alternatively drop support for that feature, for example JellyBean notifications there's not really any work around for expanded notifications but I can use the NotifcationCompat builder.

Android: How to get all the displays of a device

Is it possible to enumerate all the displays supported by an Android device? The APIs currently support getting the default display, but don't appear to support getting any other displays.
I did not find any official API for multiple device displays, even if it looks like it will support it in the future.
No, it is not, I think you're confused about what getDefaultDisplay does, it gets the display of the current device, not the global Android default, which does not exist! For information about screen sizes/densities look at the documentation.

change image of phone on emulator

I need to make a screencast of an app to present to a client, but need it to look better than the ugly red phone or the various other incarnations of the emulator. Is there a way to swap out that image?
Also would be great to get rid of the keyboard that displays next to it and make the window borders go way (since I have to capture it full screen on a mac, unfortunately, I can't crop it tight).
When you create an AVD, you can specify a different skin to use. Besides the ones available by default, there are also a bunch on the web for various devices. You can search for "[phone name] emulator skin" to find a variety, but here are a couple of examples:
Nexus One
Nexus S
The Motorola MOTODEV site (http://developer.motorola.com/docstools/tools/) has addons for nearly every one of our released phones. Registration is required. Most of the addons are full system images, which should work or you could extract out the skin for your own uses. There is a "skin only" addon for the upcoming XOOM tablet that uses Gingerbread for the runtime.
Good luck

Categories

Resources