Create application which support multiple screen(2.2 and up) - android

Blockquote
I am creating my first application with successfully. But now one problem which i facing is when I run my application in android 2.2 then its successfully work. But when I start it with 3.0 or 4.0 its become crash.
I am finding on google but not get perfect idea about this. So that I asking help here.
Please help me to find this.
Thanks in advance.
-Mayank
when run my application in 4.0 version my application stopped and when run 2.2 run successfully... what the problem..
in 4.0 unfortunetely your application has been stopped and application close what the problem help me...

You have to give permission on manifest or not.if not then
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15" />
give this permission.

You first read this for creating application with multiple support. You can declare in menifeast file like
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15" />

This question is of 7 months old. still if some body came to this page by goggling about NetworkOnMainThreadException on android, this is the answer.
If your application have network actions like sending HTTPGet / HTTPPost calls, from Android 3.0 (Honey Comb) sending network calls directly on main thread was not supported as it may stop main thread (UI thread) execution until network call response as the network call may take a long time and UI can't be loaded which is annoying to user experience.
So, sending network calls can be either on separate thread or Android API providing class (AsyncTask).
one more suggestion for android developers is
Start coding on latest version and keep min sdk version to as low as possible (I personally use min SDK- 8 & Target SDK - latest), so that you will get deprecation warnings and your application can run on latest android devices (at least till latest devices at time of development).

Related

ANT+ SDK - requestAccess faild (Other failure)

I'm trying to develop own Android application using ANT+ sensors.
My app is based on (developer's Sampler code and SDK).
However I found the strange thing during tests. I mean when I start to searching devices I immediately receive a message:
W/AntPluginPcc: BBD30600: RequestAccess failed: OTHER_FAILURE
At first I suppose that a reason of this problem is that I have a phone with Marshmallow OS (instead my wife's phone is based on Lollipop OS and all works fine). I tried to find anything in documentation related this but didn't find anything interesting. I add to Manifest some permissions (I mean com.dsi.ant.permission.ANT, android.permission.BLUETOOTH etc.) and set the permissions in code, but it doesn't help to me to solve my issue.
May be anybody received this problem and may be somebody solve it. Could you please share your solution to me?
P.S. I install the ANT+ Plugin services, ANT Radio Service. in App I use the ANT+ SDK from github. May be I should use also the ANT SDK? (I want to connect to HRM and cycle devices which use ANT+ protocol)
If you have the same problem as I you need to realize the AntRadioServiceConnection class.
I found it here.
And you should be sure that you have all services and plugins installed on your phone.

Android Sample Bluetooth chat

I have tried the sample code of Bluetooth chat from Android SDK. The code has no errors, Installed the APK on device, while opening the Bluetooth chat, Force close is thrown.
I used a real device to debug, i.e. Galaxy Nexus S.
Please help me .
. Thanks in advance.
I managed to fix it by:
Changing the AndroidManifest.xml: Basically upgrading the versions where it works <uses-sdk android:maxSdkVersion="17" android:targetSdkVersion="11" android:minSdkVersion="11"/> the 11th version is Android 3.0 (Honeycomb).
Also deleted the line in the AndroidManifest.xml referring to the style android:theme="#android:style/Theme.Holo.Dialog"
The main activity is BluetoothChat, so looking in the logCat I could see what else is throwing exceptions, the method setStatus around 233 is throwing a NullPointerEception due that the onCreate method needs the following code just bellow the super.onCreate call. Thanks to this post
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
I'm not sure if this still applies for you, but i encountered the same problem.
I downloaded the sample, loaded it on a Samsung S3(jellybean) and it kept crashing after the prompt for Bluetooth. There wasn't any error at first. So i tried using your method of removing
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
in the code (on eclipse) and was prompted that it was read only and whether i want to make it writable. Upon doing that a few error came up and that was a prompt to say getDefaultAdapter is for API 5 and current minSdk is 1. Hence i looked up into the manifest file to see why it would be a problem since i put it as minSdkVersion=5.
Upon making the manifest file writable as previously mentioned for the java file, i realized the error was due to this line
android:theme="#android:style/Theme.Holo.Dialog"
it requires an API of 11. Hence i changed to android:minSdkVersion="11" and now it works perfectly.

Example NetworkUsage Android Code Crashes On Startup?

I am trying to run the example application in the networkusage.zip file on the Android Developers website (location: http://developer.android.com/training/basics/network-ops/index.html).
I have not made any changes to the code whatsoever. However, it crashes immediately on startup. I have tried setting a breakpoint in the onCreate method of the main activity, but it never gets there....just crashes right away.
I am just starting with Android, but I been able to complete other training sessions and run other example apps, so I believe my configuration works. I am running Windows 7, with Eclipse Juno and the very latest JDK and Android SDK/ADT (both downloaded about a week ago).
I am using an emulator targeting Android 4.1 (API 16).
The emulator shows a messages that says Unfortunately, NetWork Usage has stopped working.
Any help would be greatly appreciated!!
In AndroidManifest.xml file, for this project, substitute absolute android:name for NetworkActivity with relative one.
In other words, change this line:
android:name="com.example.networkusage.NetworkActivity"
to look like this:
android:name=".NetworkActivity"
The problem was that NetworkActivity is not in com.example.networkusage (as was in AndroidManifest.xml file), but in com.example.android.networkusage package. Thus, Android couldn't find the class on runtime.

Almost finished with my first Android application made with Ice Cream Sandwich and was wondering about backwards comptibility

Hello I have developed my first application for Android using the Ice Cream Sandwich SDK and I was wondering if there was a way to make this compatible for devices also running Gingerbread without having to re-do the entire program. I have tried to find the answer to this from other sources but haven't found anything yet. Thank you for your time.
Congratulations for the development of your first application ;)
It's difficult to answer to your questions without knowing what your application is using. If your application use new features of the Android ICS API, you have to implements some compatibility code (see Support package). If not, you just need to add this in your AndroidManifest.xml :
<uses-sdk
android:targetSdkVersion="14"
android:minSdkVersion="7"
/>
Note that 7 is for Android 2.1
The best way to know if you use specific API of Android 4 (ICS) is to try to launch your project on an emulator under a lower version. If this give you error(s), it's because you have compatibility problems.
Just set your build target in Eclipse to Android 2.3. If you get any compilation errors in Eclipse, than this means that you are using APIs that are not available in 2.3 and your application will crash when it is going to reach at those lines when running on 2.3> .
Just make sure youre using APIs that are there on older versions of Android. Try to read the wahts new for ICS and avoid those :) which pretty much beats the purpose of using a newer SDK that changes alot and breaks lots of things. Beware of the new layouts....

android 2.2 to 1.6?

I have been developing an android app. I had chosen 2.2 as the version. I have not used any advanced features that are specific to 2.2 or above. I want my app to work with 1.6 and above. What should I do?
Thanks.
You should read this http://developer.android.com/guide/publishing/versioning.html
Complement preview answers.
android make upward compatible your code automatically as much as possible (not always).
But lowering the api level of an app. Can be a task from simple to nightmare to execute, all depends if your code use a lot of specific 2.2 ...
That's means changing API level or android.jar in your project may be far to be enough.
good luck
Open the AndroidManifest.xml file and change to :
<uses-sdk android:minSdkVersion="4"/>
At first you should set android:minSdkVersion="4" in the Android Manifest file.
Next step is to do some testing on an android vm with version 1.6.
Even better would be to test on a real device, but the compiler should give you enough hints what to change in your program.

Categories

Resources