mirror of
https://github.com/jlengrand/jlengrand.github.io.git
synced 2026-03-10 08:31:22 +00:00
Highlights Java code
This commit is contained in:
@@ -50,7 +50,7 @@ But whatever I was trying, my location was never set, and <a title="java doc onl
|
||||
|
||||
Here is what my Activity would look like :
|
||||
|
||||
[java]
|
||||
{% highlight java %}
|
||||
|
||||
public class DisplayGPSInfoActivity extends BaseActivity implements LocationListener {
|
||||
private static final String TAG = "DisplayGPSInfoActivity";
|
||||
@@ -91,7 +91,7 @@ Log.d(TAG, "Received GPS request for " + String.valueOf(lat) + "," + String.valu
|
||||
}
|
||||
}
|
||||
|
||||
[/java]
|
||||
{% endhighlight %}
|
||||
|
||||
You can forget about the <a title="viewFlipper javadoc" href="http://developer.android.com/reference/android/widget/ViewFlipper.html" target="_blank">ViewFlipper</a>, that is here only to show something to the user.
|
||||
Basically, I am letting android decide which provider he wants to use (GPS or Network), and request for the last known location.
|
||||
@@ -112,7 +112,7 @@ correctly defined in my manifest, and that yes, other GPS based apps were workin
|
||||
As stupid as it seems,<strong> I had forgotten to request the updates. . .</strong>
|
||||
Something like that would do the job :
|
||||
|
||||
[java]
|
||||
{% highlight java %}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@@ -121,7 +121,7 @@ Log.v(TAG, "Resuming");
|
||||
locationManager.requestLocationUpdates(provider, 400, 1, this);
|
||||
}
|
||||
|
||||
[/java]
|
||||
{% endhighlight %}
|
||||
|
||||
I was somehow expecting that is was automatic, implied by the fact that my activity implements <a title="Location listener javadoc" href="http://developer.android.com/reference/android/location/LocationListener.html" target="_blank">LocationListener</a>.
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ This gives me two lines of code to integrate into the website of my choice :
|
||||
|
||||
Then, I simply created a new Activity in my Application, that contains a webview.
|
||||
|
||||
[java]
|
||||
{% highlight java %}
|
||||
package fr.lengrand.brestram;
|
||||
|
||||
import fr.lengrand.brestram.activities.BaseActivity;
|
||||
@@ -84,7 +84,7 @@ public class TimeLineActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
[/java]
|
||||
{% endhighlight %}
|
||||
|
||||
The background color method is needed to avoid the ugly white background behind the timeline. I use a transparent background in this case.
|
||||
<strong>It is not possible to set the background directly in the xml layout for webviews; you will have to do it in the activity directly.</strong>
|
||||
|
||||
Reference in New Issue
Block a user