Identify task Sample

2186
7
10-04-2012 12:09 PM
ShaneCarey
New Contributor
Hi,

I am trying to use the identify task sample from the ArcGIS for Android SDK samples. When I load my own Mapserver, It displays correctly. However, when I click on the polygon to identify its features, the app closes. Can anyone provide any asssistance on this?

Thanks
Shane
0 Kudos
7 Replies
AndyGup
Esri Regular Contributor
Shane, make sure to run the app in debug mode. When an app exits or crashes there is almost always a fatal error logged in logcat. Once you have the error info you should be able to narrow down the problem with something like a null pointer exception, etc.

-Andy
0 Kudos
ShaneCarey
New Contributor
Hi Andy,

There is no errors in the code, so Im not sure what the problem is. This is the log cat. Thanks for your help.
10-05 20:50:29.359: E/AndroidRuntime(8191): FATAL EXCEPTION: main
10-05 20:50:29.359: E/AndroidRuntime(8191): java.lang.NullPointerException
10-05 20:50:29.359: E/AndroidRuntime(8191):  at com.esri.arcgis.android.samples.identifytask.Identify$MyIdentifyTask.onPostExecute(Identify.java:223)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at com.esri.arcgis.android.samples.identifytask.Identify$MyIdentifyTask.onPostExecute(Identify.java:1)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.os.AsyncTask.finish(AsyncTask.java:417)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.os.AsyncTask.access$300(AsyncTask.java:127)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.os.Looper.loop(Looper.java:130)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at android.app.ActivityThread.main(ActivityThread.java:3687)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at java.lang.reflect.Method.invokeNative(Native Method)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at java.lang.reflect.Method.invoke(Method.java:507)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
10-05 20:50:29.359: E/AndroidRuntime(8191):  at dalvik.system.NativeStart.main(Native Method)


Shane
0 Kudos
AndyGup
Esri Regular Contributor
It looks like you have a null pointer exception in your AsyncTask onPostExecute event handler.

Use your debugger and check the IdentifyTask input parameters as well as the result value that comes back in onPostExecute. If you need to view your HTTP REST requests with ArcGIS Server for troubleshooting then here's a post that may help: http://www.andygup.net/?p=695

-Andy
0 Kudos
ShaneCarey
New Contributor
Hi Andy,

How are you and thanks for your help to date. I am very much a newbie to app development with very little java experience so I'm unsure of how to overcome this problem.My layer is a dynamic layer and is a polygon. I checked what you outlined in the forum and this is the code that is there:

private class MyIdentifyTask extends AsyncTask<IdentifyParameters, Void, IdentifyResult[]> {

IdentifyTask mIdentifyTask;
Point mAnchor;
MyIdentifyTask(Point anchorPoint) {
mAnchor = anchorPoint;
}

Why would there be an issue with the HTTP REST requests with ArcGIS Server?

Thanks
0 Kudos
AndyGup
Esri Regular Contributor
Shane, for your questions not directly related to the ArcGIS Android SDK, such as your questions about debugging in Eclipse, feel free to ping me: agup at esri dot com.

Why would there be an issue with the HTTP REST requests with ArcGIS Server?


There are a few ways that HTTP REST requests can go wrong, such as:
- Some attribute was set incorrect in your code and ArcGIS Server couldn't interpret it properly
- There was a problem in the configuration of the REST Service within ArcGIS Server that causes an error
- The HTTP request was blocked by a firewall

You will typically find out about these problems by inspecting the HTTP Request response that is sent back from the web server. Here are some common examples:
- 404 Not Found > when a file is not found, typically the GIS service didn't get published correctly
- 401 Unauthorized > you might need additional permissions to access the service
- 500 Internal Server Error > there was an internal problem with your web server or ArcGIS Server configuration.

-Andy
0 Kudos
deleted-user-ATjHIWsdQYmT
Regular Contributor
If you are familiar with Fiddler you can configure Java/Android to send HTTP requests through Fiddler's HTTP Proxy.
In Java go to "Run Configurations". Then click the "Target" tab.  Under "Additional Emulator Command Line Options" add: -http-proxy 127.0.0.1:8888
Hope this helps..
[ATTACH=CONFIG]18297[/ATTACH]
0 Kudos
JohnAllen
New Contributor III
careyshan,

I used the identify code pretty much exactly as it was provided in the sample.
I modified the code to use my dynamic map service layer under the onCreate and to identify on.
I tested the app on my phone and the app would crash when I tried to identify on a point from my map service.
Note: My map service only contained one layer (point).

This is what I did to fix the app from crashing and actually get it working:

When setting up the parameters under onCreate at the start of the activity. I changed:

params.setLayers(new int[]{4});

--to--

params.setLayers(new int[]{0});

I think my parameters where looking for layer (4) of my map service and there was no layer four, because I had one layer published with my map service. So I changed it to (0) and it worked.

Hope this helps.
0 Kudos