MapView with user and password in XML

805
1
01-08-2013 04:56 AM
silviuMihaita
New Contributor
Hello Everybody!

Happy new year!

I want to use an item id url to load a map with user and password. It worked if I put the code in java as follow.

map = new MapView(this, "http://www.arcgis.com/home/item.html?id=5c57ca58ba8543a7adbcf898bbd805d8", "myuser", "my password");
setContentView(map);

But i see a sample with the url put in the Xml file like this:

<!-- MapView that will fill your device screen with the "Washington, DC" hosted on ArcGIS.com. -->
<com.esri.android.map.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
url="http://www.arcgis.com/home/webmap/viewer.html?webmap=e229d715f7ca4fa980308549fb288165"/>

My question is how to put user and password in xml because without them the map don't load!

Sorry for my english! I hope you understand the message!
Thanks in advance for answers!
0 Kudos
1 Reply
Sharadarya
New Contributor
Create an android XML in /res/values and add the string tag with the name and its value.
<string name="user_name">USERNAME</string>
<string name="user_pwd">PASSWORD</string>

You can get the same from R.string.user_name and R.string.user_pwd.
String myuser= R.string.user_name ;
String mypassword= R.string.user_pwd;

map = new MapView(this, "http://www.arcgis.com/home/item.html?id=5c57ca58ba8543a7adbcf898bbd805d8", myuser,my password);
setContentView(map);

I think, it helps for you.
Happy Coding
0 Kudos