I created android app its working find and view of that app is perfect with my emulator,but when I install it in different devices layout or view is not showing properly,can any one give good suggestion for that,so that app can work same in all devices..
#Johnsan don't worry have not you ever set any property before?..here you can set either true or false...supports-screens android:resizeable="true" for more check this answer
Optimizing Android manifest file for largest number of supported devices
Related
Sooo... I've come across a rather odd issue...
I am creating an app and need different versions of the layout for different devices. The default layout was made for my Nexus 7, so you can imagine it is quite large.
As recommended by the documentation, I created a layout-small folder in which I designed every Activity layout for a small device. So far so good, everything goes smoothly. I decide to change some buttons on my default layout as it will look better, but whenever I try to open it, it's display is of the 2.7''QVGA and whenever I try to change it back to the Nexus 7, Eclipse opens up my file from the layout-small folder! Damn it Eclipse! Let me choose what I open! When I run it, it still looks fine but this issue isn't allowing me to make any changes on what I have!
I already tried closing it and everything, but the damn small version of the layout keeps opening, over the default one!
Hope the issue is clear enough... I can see how it would be hard to understand.
Thank you very much for your time!
In your manifest, try letting the os know what sizes are supported by adding:
<supports-screens
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
Once you have this in your manifest, you can also use it to switch the use of various sizes on and off by toggling between true and false, to help test and debug your code.
Also, make sure that the changes you've made to your default layout are valid. If the changes make your default xml un-useable then one of the others may be used instead.
I have an application that just designed for handsets. I want this application be visible to just handsets in Play market. Based on my research I found that it's impossible. So the solution that I found is adding <support-screen> into manifest.
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/>
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="false"
android:requiresSmallestWidthDp="320"
android:largestWidthLimitDp="360"/>
Based on what supports-screens says for largestWidthLimitDp:
This attribute allows you to force-enable screen compatibility mode by
specifying the maximum "smallest screen width" for which your
application is designed. If the smallest side of a device's available
screen is greater than your value here, the application runs in screen
compatibility mode with no way for the user to disable it.
Since size of GS3 is 720*1080px then I found 720px = 360dp.
However, the problem is Note from document:
Note: Currently, screen compatibility mode emulates only handset
screens with a 320dp width, so screen compatibility mode is not
applied if your value for android:largestWidthLimitDp is larger than
320.
Therefore it shows android:largestWidthLimitDp is useless at the moment.
I think I have two ways:
1- Filter out phablet/tablets from Play console which is not easy (it says your app is compatible with 3030 devices).
2- Displaying gentle apologies! - to say sorry we don't support your device at the moment - in run time. I think this is horrible and brings us 1 starts :(
What you think?
Any suggestion would be appreciated.
Thanks
When you list your apk in the play store (developer console, you don't have to publish it yet) you can select what devices your app is compatible with. It may be a pain, but you can run through that list and only select the phones you'd like. This is the best way for what you are trying to do.
Otherwise you'd have to resort to options that you listed above such as telling the user "Hey, we don't support your screen size". And no one wants to see that.
I need to make sure my Android app works on all Android phones. How would I go about making sure that it works on all of them?
In my xml files I only use fill_parent and wrap_content and for layout I use LinearLayout. In my app I download some images from the web, save them to sdcard, and then display them. When an image is selected I play a video from the sdcard.
That's my app. Will it look the same on all android phones?
If not, what should I do?
The only thing you can do to check this is test your application on as many devices/emulator-configurations as possible.
If you are concerned if you app will look good on all Smart-Phones and Tablets, you can create multiple Android-Emulators to test it.
Further information about how to optimize your app for multiple screens can be found in the docs.
Be aware that not all the android devices have an sdcard, an surely lot of them have the sdcard almost full.
I think the application must work and see alright in all the devices (be sure to test with the emulator all the pixel densities) and also take care in the cases that the android doesn't have the sdcard.
For this condition there are two things
1) you have to write small code in you manifest file after ending of application tag
</application>
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true">
</supports-screens>
2) If you are giving height and width of any widget (i.e. button or layout) in size such as 40px or 40 px etc change this thing into DIP(Device independent pixels). Use Layout:weight to make layout fixable to every screen. android:gravity or android:layout_gravity to fix layout to any place. and if you want to make fix it at particular position and linear layout in not help full use relative layout
Relative layout and always use DIP is way to make it work on all devices. However one warning, don't always trust the emulator, I designed and tested my app all on the emulator, however when I moved it to phone and my workmates, it was different on both our phones, so be careful
You need to define supports-screen inside the AndroidManifest.xml file.
And if you are selecting a version you could use android:minSdkVersion &
android:targetSdkVersion.
Is it possible to restrict sales of an app on the Android Market by specific devices, or by features of a device (screen resolution, processor, diskspace etc..)?
I know that I'm going to be bombarded by people saying that if you design your app well, it should be able to run on any size device. That's all fine and well, but there are reasons that you might still want to restrict by feature set.
One reason that comes readily to mind is screen resolution. Clearly, not all apps work on all screen sizes, especially if you have a lot of images that have been crafted to take full advantage of a larger screen resolution. To belabor the point, imagine that tomorrow a new Android device comes out with a screen resolution of 100x100. Clearly there are apps that will not work optimally on this device. As a developer, I want to ensure that my application runs only on devices that have the features I require to support the best possible experience.
I don't want to sell it to users with certain devices to prevent negative ratings and reviews that I frequently see on other apps. I'd rather ship a perfect experience on a smaller number of devices than allow imperfect experiences on all of them.
Does Android Market offer any means of dealing with this?
I think you can do what you need in your AndroidManifest file. For example, you can choose to only support extra large screens resolution like this:
<supports-screens android:resizeable="false"
android:smallScreens="false"
android:normalScreens="false"
android:largeScreens="false"
android:xlargeScreens="true"
android:anyDensity="true" />
These sizes are defined in the link below, for example "normal" is HVGA at medium density. Read the link below for more details.
http://developer.android.com/guide/topics/manifest/supports-screens-element.html
"If your application does not support small screens, then there isn't much the system can do to make the application work well on a smaller screen, so external services (such as Android Market) should not allow users to install the application on such screens."
You may also need to set the element, although I've not tried that myself, it seems to be in-line with what you want:
http://developer.android.com/guide/topics/manifest/compatible-screens-element.html
"The Android system does not read the manifest element (neither at install-time nor at runtime). This element is informational only and may be used by external services (such as Android Market) to better understand the application's compatibility with specific screen configurations and enable filtering for users. Any screen configuration that is not declared in this element is a screen with which the application is not compatible. Thus, external services (such as Android Market) should not provide the application to devices with such screens."
You'll want to read up more here as well to see what the Market does with all this info:
http://developer.android.com/guide/appendix/market-filters.html
Since I've not tried this, it's not clear to me whether your app should use both the elements I mentioned above, but the market filter page probably explains which to use.
This is covered fairly well in the developer documentation, particularly the pages linked to in the "See Also" box.
I want to publish an application that specifically runs only on 800x480 or higher screens.
I don't want users with 480x320, 320x240 etc devices to get it from Android Market. How do I configure it?
Market Filters seems to have the answer but I still don't get it.
Unfortunately, in the current state of the Market, you aren't able to do this. According to the <supports-screens> reference doc - you can only filter by the "screen size", and as you noted, the WVGA/FWVGA resolutions are "normal."
You can have your app detect it programatically using the DisplayMetrics class using heightPixels and widthPixels but that's only after it's been purchased/installed, which is what I assume you want to avoid.
I havent tried this on Android but I think this should work:
Make your app a trial app, so that it is free to download but not free say after one day.
Now in your app do one of the two things, on app start either detect the screen size and just display a generic message saying this screen resolution is not supported and display the exit button. Another way to do this is is to have layout-480x320 folder display the same message and provide an exit button to exit the app. This way you can have all non supported screen sizes display this message and have no functionality. The default layout folder will have the UI for your supported screen sizes of course. This way on non supported devices you can also say what all handsets are supported in the message.
Dont forget to have <supports-screens android:anyDensity="false" /> in your manifest file.
Now when user downloads your app on non supported devices he/she will not be charged because of one day trial and also will be clearly shown that his/her device is not supported and can exit and uninstall the app.
This wont make your app invisible on non supported resolutions but allows for clean and simple mechanism to communicate to user.
after hitting google hard i found as manifest config:
<compatible-screens>
<screen android:screenSize=["small" | "normal" | "large" | "xlarge"]
android:screenDensity=["ldpi" | "mdpi" | "hdpi" | "xhdpi"] />
...
like described here.
in your case you can reduce downloads to the following sizes:
WVGA800 (480x800)
WVGA854 (480x854)
600x1024
those screens have 71% share of the market.
scroll down on the following links to find market shares and resolution "names".
market share
scroll down to find resolution names
Hope that's helpin' out. Cheers
UPDATE: This does not work (see comments below)
In your manifest:
<supports-screens
android:largeScreens="true"
android:normalScreens="false"
android:smallScreens="false"/>
As far as an android app is concerned, I'm not sure. Good question.
However if you're writing a browser app in HTML/Javascript, you can check in Javascript using a combination of the screen.width/height, document.documentElement.clientWidth/Height, and a few other methods. If you really wanted to, this would be a way of blocking your site from low-res machines.
You can also specify CSS to react differently according to the screen size using media queries, although that would be less about blocking and more about adapting to suit the environment.
The Quirksmode website has a good article about the intricacies of dtermining screen size and other attributes in a mobile browser environment.