Ok! Seems I've managed to fix it now. I actually had to look at the command line version example to get this to work (I was looking at the Desktop one).
I may still be having an issue with it, but unfortunately lunch is over and I need to get back to paid work :( On Jan 14, 11:38 pm, Tane Piper <[email protected]> wrote: > Hi, > > Sorry to bump this again, but I've looked over the examples again, and > I still cannot see where I am going wrong! I'm still getting an null > body back when i do: > > OAuthMessage result = accessor.newRequestMessage(OAuthMessage.GET, > "http://brightkite.com/places/search.json", > OAuth.newList("q", myLocation.getLatitude() + "," + > myLocation.getLongitude())); > > String result_message = result.readBodyAsString(); > > Any help will be much appreciated, as my app really depends on this! > > On Jan 14, 12:46 am, Tane Piper <[email protected]> wrote: > > > Hi there, > > > I've re-written my app a bit and have completed the token exchange > > stuff. Now on app loadup, I check to see if there is a stored key, I > > go right into the activity. However, whats now happening is I'm > > getting an NullPointerException on this line: > > > Log.i("Response", result.readBodyAsString().toString()); > > > It seems I am not getting a response body. This is the OAuthMessage I > > am sending, with some stuff changed in the values TOKEN_HASH and > > CONSUMER_KEY - but I can assure you these values are here: > > > 01-14 00:37:15.341: INFO/Request(4818): > > OAuthMessage(GET,http://brightkite.com/places/search.json, > > [q=55.9588086605072%2C-3.1632739305496216, oauth_token=TOKEN_HASH, > > oauth_consumer_key=CONSUMER_KEY, oauth_signature_method=HMAC-SHA1, > > oauth_timestamp=1231893434, oauth_nonce=28181971054305, > > oauth_version=1.0, oauth_signature=V6MxRdUHwUUZZBgbZjo7PW4ZQc8%3D]) > > > package org.ifies.brightroid; > > > import java.io.IOException; > > import java.net.URISyntaxException; > > import java.util.ArrayList; > > import java.util.List; > > > import com.google.android.maps.GeoPoint; > > import com.google.android.maps.ItemizedOverlay; > > import com.google.android.maps.MapActivity; > > import com.google.android.maps.MapController; > > import com.google.android.maps.MapView; > > import com.google.android.maps.OverlayItem; > > > import android.content.Context; > > import android.content.Intent; > > import android.graphics.Canvas; > > import android.graphics.drawable.Drawable; > > import android.location.Criteria; > > import android.location.Location; > > import android.location.LocationListener; > > import android.location.LocationManager; > > import android.os.Bundle; > > import android.os.Handler; > > import android.util.Log; > > import android.view.Menu; > > import android.view.MenuItem; > > import android.widget.Toast; > > > import net.oauth.OAuth; > > import net.oauth.OAuthAccessor; > > import net.oauth.OAuthConsumer; > > import net.oauth.OAuthException; > > import net.oauth.OAuthMessage; > > import net.oauth.OAuthServiceProvider; > > import net.oauth.client.OAuthClient; > > import net.oauth.client.httpclient4.HttpClient4; > > > import org.json.JSONException; > > import org.json.JSONObject; > > import org.json.JSONTokener; > > > public class BrightroidMap extends MapActivity { > > > private final OAuthServiceProvider provider = new > > OAuthServiceProvider > > ( > > > > org.ifies.brightroid.oauth.Request.OAUTH_REQUEST_TOKEN_URL, > > > > org.ifies.brightroid.oauth.Request.OAUTH_AUTHORIZE_URL, > > > > org.ifies.brightroid.oauth.Request.OAUTH_ACCESS_TOKEN_URL); > > private final OAuthConsumer consumer = new OAuthConsumer(null // > > callback URL > > , org.ifies.brightroid.oauth.Request.CONSUMER_KEY // > > consumer key > > , org.ifies.brightroid.oauth.Request.CONSUMER_SECRET // > > consumer secret > > , provider); > > private final OAuthAccessor accessor = new OAuthAccessor(consumer); > > private final OAuthClient client = new OAuthClient(new HttpClient4 > > ()); > > > @SuppressWarnings("unchecked") > > private class myLocationOverlay extends ItemizedOverlay { > > > private List<OverlayItem> items=new ArrayList(); > > private Drawable marker=null; > > > public myLocationOverlay(Drawable defaultMarker) { > > super(defaultMarker); > > this.marker = defaultMarker; > > > GeoPoint point = new GeoPoint( > > (int) (myLocation.getLatitude() * > > 1E6), > > (int) (myLocation.getLongitude() * > > 1E6)); > > items.add(new OverlayItem(point, "Me", "My > > Location")); > > populate(); > > } > > > @Override > > protected OverlayItem createItem(int i) { > > // TODO Auto-generated method stub > > return (OverlayItem) items.get(i); > > } > > > public void draw(Canvas canvas, MapView mapView, boolean > > shadow) { > > super.draw(canvas, mapView, shadow); > > > boundCenterBottom(marker); > > } > > > @Override > > protected boolean onTap(int i) { > > Toast.makeText(BrightroidMap.this, "Your Location", > > Toast.LENGTH_SHORT).show(); > > > return(true); > > } > > > @Override > > public int size() { > > // TODO Auto-generated method stub > > return(items.size()); > > } > > > } > > > private class myLocationListener implements LocationListener { > > > @Override > > public void onLocationChanged(android.location.Location > > location) { > > // TODO Auto-generated method stub > > if (location != null) { > > myLocation = location; > > Toast.makeText(getBaseContext(), "Location > > changed to " + > > location.getLatitude() + " " + location.getLongitude(), > > Toast.LENGTH_SHORT).show(); > > Log.i("Location", location.getLatitude() + > > ", " + > > location.getLongitude()); > > > GeoPoint point = new GeoPoint( > > (int) > > (location.getLatitude() * 1E6), > > (int) > > (location.getLongitude() * 1E6)); > > controller_Mapview.animateTo(point); > > controller_Mapview.setZoom(16); > > Drawable > > marker=getResources().getDrawable(R.drawable.icon); > > marker.setBounds(0, 0, > > marker.getIntrinsicWidth(), > > marker.getIntrinsicHeight()); > > view_Mapview.getOverlays().add(new > > myLocationOverlay(marker)); > > view_Mapview.invalidate(); > > > > locationManager.removeUpdates(myLocationListener.this); > > } else { > > Log.e("Location", "There was no position > > returned"); > > } > > Log.i("Activity", "We tried to update loaction"); > > } > > > @Override > > public void onProviderDisabled(String provider) { > > // TODO Auto-generated method stub > > > } > > > @Override > > public void onProviderEnabled(String provider) { > > // TODO Auto-generated method stub > > Log.i("Provider", provider.toString()); > > } > > > @Override > > public void onStatusChanged(String provider, int status, > > Bundle > > extras) { > > // TODO Auto-generated method stub > > > } > > } > > > public static final int MY_LOCATION = Menu.FIRST; > > public static final int SUBMIT_LOCATION = Menu.FIRST + 1; > > public static final int EXIT_ID = Menu.FIRST + 2; > > > public Drawable marker; > > > private final int GPS_TIMEOUT = 5000; > > > private LocationManager locationManager; > > private LocationListener locationListener; > > protected Location myLocation = null; > > private String accessToken; > > > private MapView view_Mapview; > > private MapController controller_Mapview; > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.location); > > > Bundle extras = getIntent().getExtras(); > > if(extras != null) { > > accessToken = (String) > > extras.getString("accessToken"); > > } > > accessor.accessToken = accessToken; > > Log.i("Token", accessor.accessToken); > > > > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "OAuth" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/oauth?hl=en -~----------~----~----~----~------~----~------~--~---
