[android-developers] Re: android help
Is that "View.OnClickListener" listener only restricted to Layouts
i.e. button Events etc or it can be used to application click
event…….example when application is double clicked ,dialer gets opened
and when same application is single clicked , should get open...is it
possible…if yes….kindly help me with the code of the same…..
Other problems….
I have done coding to retrieve the latitude and longitude using gps
but its not working....location is showing null value and finally it
do not have any values of latitude and longitude.
I have tried passing the values from Emulator control and also through
command line using "telnet local host 5554(device name)".....
Also same is the case with Google maps ,I have tried to access Google
maps but its not working via coding….i do have registered for Maps
key…..but I am able to access Google maps application from emulator
which is default present on emulator…I think so there is problem with
the code….
im providing u with the code GPS only ,'ll try for Google maps
again.....please go through it and reply sooner….
GPS
1) gps.java
package d.gps;
import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.widget.TextView;
public class gps extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locationManager;
locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateWithNewLocation(location);
}
/** Update UI with a new location */
private void updateWithNewLocation(Location location) {
TextView myLocationText =
(TextView)findViewById(R.id.myLocationText);
String latLongString;
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
} else {
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is:\n" +
latLongString);
}
}
2) main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/myLocationText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
3)String.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, gps!</string>
<string name="app_name">gps</string>
</resources>
4) androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="d.gps"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".gps"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.INTERNET"></uses-
permission><uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
Thanks……
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home