eclipse adt - Android unfourtunately project has stopped error -
i'm creating android app in eclipse adt bundle.when clicked button app connecting web service , getting location values in app.i started app in emulator, while i'm receiving "unfourtunately project name has stopped" warning. i'm checking out logcat.but didn't solve problem. i'm sharing down logcat errors. me please.
main activity:
public class mainactivity extends activity { public final static string url = "http://10.0.2.2:8081/webservice/services/sqlservice.sqlservicehttpsoap11endpoint/"; public static final string namespace = "http://services.com"; public static final string soap_action= "http://services.com/locationdata"; private static final string method_name = "locationdata"; string str = null; textview t; string longitude; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (android.os.build.version.sdk_int > 9) { strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build(); strictmode.setthreadpolicy(policy); } t = (textview) findviewbyid(r.id.textview1); soapobject request = new soapobject(namespace, method_name); request.addproperty("message","hello"); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.dotnet=true; envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); try { androidhttptransport.call(soap_action, envelope); } catch (httpresponseexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (xmlpullparserexception e) { // todo auto-generated catch block e.printstacktrace(); } soapprimitive result; try { result = (soapprimitive)envelope.getresponse(); string strres = result.tostring(); string resultarr[] = strres.split("&"); longitude = resultarr[0]; t.settext(resultarr[0]); } catch (soapfault e) { // todo auto-generated catch block e.printstacktrace(); } } public void sendlocation(view v){ intent intent = new intent(mainactivity.this,mappingactivity.class); intent.putextra("longitude",longitude); startactivity(intent); } }
main.xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.abc.mainactivity" android:background="@drawable/background1"> <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="62dp" android:text="textview" /> <button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/textview1" android:layout_below="@+id/textview1" android:layout_margintop="69dp" android:background="#000000" android:onclick="sendlocation" android:text="refresh location" android:textcolor="#ffffff" /> </relativelayout>
manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.abc" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="16" android:targetsdkversion="16" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-permission android:name="com.example.abc.permission.maps_receive" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_mock_location" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <permission android:name="com.example.abc.permission.maps_receive" android:protectionlevel="signature" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.maps.v2.api_key" android:value="map_api_key" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".mapactivity" android:label="@string/title_activity_map" > </activity> <activity android:name=".mappingactivity" android:label="@string/title_activity_mapping" > </activity> </application> </manifest>
mappingactivity:
public class mappingactivity extends fragmentactivity { private googlemap googleharita; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.map); //string longitude = getintent().getextras().getstring("longitude"); //float f = float.parsefloat(longitude); if (googleharita == null) { googleharita = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.haritafragment)) .getmap(); if (googleharita != null) { latlng istanbulkoordinat = new latlng(0,29.004065); googleharita.addmarker(new markeroptions().position(istanbulkoordinat).title("kız kulesi")); googleharita.movecamera(cameraupdatefactory.newlatlngzoom(istanbulkoordinat, 13)); } } }
}
map.xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <fragment android:id="@+id/haritafragment" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment" /> </relativelayout>
web service:
public string insertdata(string longitude,string latitude,string time){ try{ class.forname("com.mysql.jdbc.driver"); connection con = (connection) drivermanager.getconnection("jdbc:mysql://localhost/places","root",""); preparedstatement statement = (preparedstatement) con.preparestatement("insert location (column_longitude,column_latitude,column_time) values ('"+longitude+"','"+latitude+"','"+time+"')"); int result=statement.executeupdate(); con.close(); }catch(exception exc){ system.out.println(exc); } return time; } public string locationdata(){ string locationinfo=""; try{ class.forname("com.mysql.jdbc.driver"); connection con = (connection) drivermanager.getconnection("jdbc:mysql://localhost/places","root",""); preparedstatement statement = (preparedstatement) con.preparestatement("select * location"); resultset result=statement.executequery(); while(result.next()){ locationinfo=locationinfo+result.getstring("column_longitude")+"&" +result.getstring("column_latitude")+ "&" +result.getstring("column_time"); } }catch(exception exc){ system.out.println(exc); } return locationinfo; }
logcat:
you extending fragmentactivity
in mappingactivity instead activity
or appcompatactivity
replace , work.
Comments
Post a Comment