java - project stopped unexpectedly -


i trying write code getting cords on mobile.

i tried debug code , guess error in locationlistener ll=new mylocationlistener();

trackmobileclass

package prakash.work.trackmobile;  import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.app.activity; import android.content.context; import android.widget.textview;  public class getcords extends activity {  textview longi; textview lat; textview tv=(textview) findviewbyid(r.id.tv); @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.get_cords);      longi=(textview) findviewbyid(r.id.longi);     lat=(textview) findviewbyid(r.id.lat);      locationmanager lm=(locationmanager) getsystemservice(context.location_service);     locationlistener ll=new mylocationlistener();     lm.requestlocationupdates(locationmanager.gps_provider, 0, 0, ll);   } class mylocationlistener implements locationlistener{      public void onlocationchanged(location arg0) {         if(arg0 != null)         {             tv.settext("working");             double plongi=arg0.getlongitude();             double plat=arg0.getlatitude();              longi.settext(double.tostring(plongi));             lat.settext(double.tostring(plat));         }      }      public void onproviderdisabled(string arg0) {         // todo auto-generated method stub      }      public void onproviderenabled(string arg0) {         // todo auto-generated method stub      }      public void onstatuschanged(string arg0, int arg1, bundle arg2) {         // todo auto-generated method stub      }  } } 

##xml layout file##

<linearlayout 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:orientation="vertical">  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="latitude"     android:textappearance="?android:attr/textappearancemedium" />  <textview     android:id="@+id/lat"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text=""     android:textappearance="?android:attr/textappearancemedium" />  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="longitude"     android:textappearance="?android:attr/textappearancemedium" />  <textview     android:id="@+id/longi"     android:text=""     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textappearance="?android:attr/textappearancemedium" />  <textview     android:id="@+id/tv"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textappearance="?android:attr/textappearancelarge" />  </linearlayout> 

##manifest##

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="prakash.work.trackmobile" android:versioncode="1" android:versionname="1.0" >  <uses-sdk     android:minsdkversion="8"     android:targetsdkversion="15" /> <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_location_extra_commands" /> <uses-permission android:name="android.permission.access_mock_location" /> <uses-permission android:name="android.permission.control_location_updates" /> <uses-permission android:name="android.permission.internet" />  <application     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name=".getcords"         android:label="@string/title_activity_get_cords" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application>   </manifest> 

or there else need how work listeners

textview tv=(textview) findviewbyid(r.id.tv);

you need put in public void oncreate(bundle savedinstancestate) { method after setcontentview(r.layout.get_cords);

textview longi; textview lat; textview tv; @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.get_cords);     tv=(textview) findviewbyid(r.id.tv);     longi=(textview) findviewbyid(r.id.longi);     lat=(textview) findviewbyid(r.id.lat); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -