I'm working on MapBox off line. The code was OK, able to download map but after adding some peice of code which have nothing to do with the map, the download stop to work and the give an HTTP401 Error.
I've noticed that depending on where you call MapboxAccountManager.start sometimes it fails.
Here's the code:
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
DB_Handler db_ansb = new DB_Handler(Init_Carte.this,null,null,1);
// Get data from DB, about the map
HashMap<String, String> data_mapbox = db_ansb.do_get_mapbox(0);
the_mapbox_token = data_mapbox.get("tmapbox_token");
the_mapbox_style = data_mapbox.get("tmapbox_style");
the_mapbox_zoom_min = Integer.parseInt(data_mapbox.get("tmapbox_zoom_min"));
the_mapbox_zoom_max = Integer.parseInt(data_mapbox.get("tmapbox_zoom_max"));
the_mapbox_inter = Double.parseDouble(data_mapbox.get("tmapbox_inter"));
OfflineManager offlineManager = OfflineManager.getInstance(this);
MapboxAccountManager.start(this,the_mapbox_token);
setContentView(R.layout.activity_init_carte);
// Menu with APP compat
// https://developer.android.com/training/appbar/setting-up.html
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
// Find our truck GPS position for road map
HashMap<String, String> my_truck = db_ansb.do_get_my_truck();
String str_truck_lagps = my_truck.get("frota_lagps");
String str_truck_logps = my_truck.get("frota_logps");
the_lagps_truck = Double.parseDouble(str_truck_lagps);
the_logps_truck = Double.parseDouble(str_truck_logps);
// Find accident location for road map
HashMap<String, String> my_inter = db_ansb.do_get_inter_resume();
String str_inter_lagps = my_inter.get("inter_lagps");
String str_inter_logps = my_inter.get("inter_logps");
the_lagps_inter = Double.parseDouble(str_inter_lagps);
the_logps_inter = Double.parseDouble(str_inter_logps);
// Compute area to get
HashMap<String, Double> data_gps_inter = db_ansb.do_get_bounds_inter(the_lagps_inter,the_logps_inter,the_mapbox_inter);
final double inter_lagps_ne = data_gps_inter.get("inter_max_lagps"); // Nord Est
final double inter_logps_ne = data_gps_inter.get("inter_max_logps");
final double inter_lagps_so = data_gps_inter.get("inter_min_lagps"); // Sud Ouest
final double inter_logps_so = data_gps_inter.get("inter_min_logps");
// Display what we're doing
tmp_id_msg = (TextView) findViewById(R.id.txt_action);
tmp_id_msg.setText(R.string.str_telechargement_carte);
// Create zone
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(new LatLng(inter_lagps_ne, inter_logps_ne)) // Northeast
.include(new LatLng(inter_lagps_so, inter_logps_so)) // Southwest
.build();
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
the_mapbox_style,
latLngBounds,
the_mapbox_zoom_min,
the_mapbox_zoom_max,
(Init_Carte.this).getResources().getDisplayMetrics().density);
byte[] metadata;
try
{
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, "Carte");
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception e)
{
Log.e("TAG", "Failed to encode metadata: " + e.getMessage());
metadata = null;
}
// Get data
offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback()
{
#Override
public void onCreate(OfflineRegion offlineRegion)
{
offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
// Monitor the download progress using setObserver
offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver()
{
#Override
public void onStatusChanged(OfflineRegionStatus status)
{
Log.i("DBUG","onStatusChanged");
// Calculate the download percentage and update the progress bar
double percentage = status.getRequiredResourceCount() >= 0 ?
(100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
0.0;
long long_pourcentage = Math.round(percentage);
String str_pourcentage = Long.toString(long_pourcentage)+" %";
// Display on screen
tmp_id_valeur = (TextView) findViewById(R.id.val_action);
tmp_id_valeur.setText(str_pourcentage);
Log.i("DBUG",str_pourcentage+"%");
if (status.isComplete())
{
// OK so now, ask the road
do_get_trajet();
}
}
#Override
public void onError(OfflineRegionError error)
{
// If an error occurs, print to logcat
Log.i("DBUG", "onError reason: " + error.getReason());
Log.e("DBUG", "onError message: " + error.getMessage());
}
#Override
public void mapboxTileCountLimitExceeded(long limit)
{
// Notify if offline region exceeds maximum tile count
Log.i("DBUG", "Mapbox tile count limit exceeded: " + limit);
}
});
}
#Override
public void onError(String error)
{
Log.e("TAG", "Error: " + error);
}
});
}
I enter the Aysnc part, get 3 or 4 times
Log.i("DBUG",str_pourcentage+"%");
with a value of 0% then get I get:
I/System.out: [CDS]rx timeout:10000
D/NativeCrypto: ssl=0x619629c8 sslWrite buf=0x41e60068 len=222 write_timeout_millis=0
D/NativeCrypto: ssl=0x619629c8 sslRead buf=0x41e60068 len=8192,timeo=10000
I/DBUG: onError reason: REASON_OTHER
E/DBUG: onError message: HTTP status code 401
D/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request with response code = 401: Unauthorized
I've noticed same strange behaviour on another page: depending on the fact you perform or not, action before of after MapboxAccountManager.start(this,the_mapbox_token); it works or not.
Notice the token is correct.
Any idea?
After changing the token in our DB, it was OK but only for a short time: I was able to download 26% of the map and then, I get again the HTTP 401 message...
Found. In fact there is a small mistake in the code that help me understand: how can this code work sometimes, as I call
OfflineManager offlineManager = OfflineManager.getInstance(this);
MapboxAccountManager.start(this,the_mapbox_token);
so as I call the init after the use of the Lib? In fact all example at Mapbox are made with one activity performing all the jobs. So when you have more than one activity using Mapbox, you quickly believe you need to put a MapboxAccountManager.start in each ones. Which is wrong. In that case (more than one activity), you must call MapboxAccountManager.start at App level. Like that:
public class App_Start extends Application
{
#Override
public void onCreate()
{
super.onCreate();
String the_mapbox_token = "pk.eyJ1IjoiYW5.....";
MapboxAccountManager.start(this,the_mapbox_token);
}
public void customAppMethod()
{
// Custom application method
}
}
and add this class at application level on your Manifest:
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:theme="#style/AppTheme" android:name="net.ansb_brasil.xxxx.App_Start">
Concerning the fact the second activity was performing two times the download, it came from the fact the if (status.isComplete()) part of the onStatusChanged() is always called two times. Seems to be a bug in the Lib. On some example at Mapbox, they use a boolean flag in order to avoid taking two times this call in account.
As my first activity was downloading one map and then call a second activity for a second map, this "double call" had as result two call for the second activity and so many troubles.
Hope this will avoid headaches to others
Related
I am writing an Android App using Xamarin which uses Xamarin.GooglePlayServices.Maps Nuget Package. I need to get to a particular place on the map using the name of the place. For this purpose I loaded Xamarin.GooglePlayServices.Places. I am able to pass a partial place name to the GetAutocompletePredictionsAsync as so:
var autocompletePredictions = await
PlacesClass.GeoDataApi.GetAutocompletePredictionsAsync(
Adapter.googleApiClient, constraint.ToString(),
Adapter.bounds, Adapter.autoCompleteFilter);
The result I get back is basically a collection of IAutocompletePrediction. The only item in this object that has to do with location is the PlaceId. I cannot find any way to use this on the Google Maps API. I tried seeing if I could get any more information by calling the GetPlaceById:
var place = PlacesClass.GeoDataApi.GetPlaceById(googleApiClient, item.PlaceId);
But I didn't see any location information at all in that result. Does anyone know how to get LatLng information from the Google Places API?
Update: I used information from several responses to get the answer:
Task.Run(async () =>
{
PlaceBuffer places = await PlacesClass.GeoDataApi.GetPlaceByIdAsync(googleApiClient, item.PlaceId);
if (places.Status.IsSuccess)
{
foreach (var place in places)
try
{
//IPlace place = (IPlace)places.Get(0);
MarkOnMap(place.NameFormatted.ToString(), place.AddressFormatted.ToString(), place.LatLng);
UpdateCameraPosition(place.LatLng);
}
catch (Exception ex)
{
Log.Error("WhatNow", ex.ToString());
}
}
places.Dispose();
});
The odd thing was when I enumerated the places in the foreach, the place was an IPlace type. However
IPlace place = (IPlace)places.Get(0);
Did not cast to an IPlace. Who knows? I just hope that Dispose() releases the buffer as recommended in the Docs. Xamarin is always just a little different from Java.
Thanks to everyone who helped.
I have used this, you can try this code.
I am using autoCompleteTextView.
dropLocationEt.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final PlaceAutoCompleteAdapter.PlaceAutocomplete item = mAdapter.getItem(position);
final String placeId = String.valueOf(item.placeId);
Log.i(TAG, "Autocomplete item selected: " + item.description);
/*
Issue a request to the Places Geo Data API to retrieve a Place object with additional
details about the place.
*/
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(googleApiClient, placeId);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
#Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
// Request did not complete successfully
Log.e(TAG, "Place query did not complete. Error: " + places.getStatus().toString());
places.release();
return;
}
// Get the Place object from the buffer.
final Place place = places.get(0);
latLngDrop = place.getLatLng();
StaticMethods.hideKeyboard(getActivity());
dropLocationEt.setSelection(0);
}
});
}
});
From the latlngDrop, you can retrieve the lat and lng, eg: latlngDrop.getLatitude, latlngDrop.getLongitude
I want download a particular city in my app. How can do this? There is another problem, too: when I use SDK of Mapbox 4.1.1 I can't add the class BoundingBox.
I have a problem, a code that exists on their site to download the map is not based just once. I have to stop running the program, and when I re-run it the map does not load again.
This is my code :
// Mapbox access token is configured here. This needs to be called either in your application
// object or in the same activity which contains the mapview.
MapboxAccountManager.start(this, getString(R.string.access_token));
// This contains the MapView in XML and needs to be called after the account manager
setContentView(R.layout.activity_offline_simple);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(MapboxMap mapboxMap) {
// Set up the OfflineManager
offlineManager = OfflineManager.getInstance(SimpleOfflineMapActivity.this);
// Create a bounding box for the offline region
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(new LatLng(13.1,32.6)) // Northeast
.include(new LatLng(13.6,32.9)) // Southwest
.build();
// Define the offline region
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
mapView.getStyleUrl(),
latLngBounds,
10,
20,
SimpleOfflineMapActivity.this.getResources().getDisplayMetrics().density);
// Set the metadata
byte[] metadata;
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, "Triopli Libya");
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception exception) {
Log.e(TAG, "Failed to encode metadata: " + exception.getMessage());
metadata = null;
}
// Create the region asynchronously
offlineManager.createOfflineRegion(
definition,
metadata,
new OfflineManager.CreateOfflineRegionCallback() {
#Override
public void onCreate(OfflineRegion offlineRegion) {
offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
// Display the download progress bar
progressBar = (ProgressBar) findViewById(R.id.progress_bar);
startProgress();
// Monitor the download progress using setObserver
offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
#Override
public void onStatusChanged(OfflineRegionStatus status) {
// Calculate the download percentage and update the progress bar
double percentage = status.getRequiredResourceCount() >= 0
? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
0.0;
if (status.isComplete()) {
// Download complete
endProgress("Region downloaded successfully.");
} else if (status.isRequiredResourceCountPrecise()) {
// Switch to determinate state
setPercentage((int) Math.round(percentage));
}
}
#Override
public void onError(OfflineRegionError error) {
// If an error occurs, print to logcat
Log.e(TAG, "onError reason: " + error.getReason());
Log.e(TAG, "onError message: " + error.getMessage());
}
#Override
public void mapboxTileCountLimitExceeded(long limit) {
// Notify if offline region exceeds maximum tile count
Log.e(TAG, "Mapbox tile count limit exceeded: " + limit);
}
});
}
#Override
public void onError(String error) {
Log.e(TAG, "Error: " + error);
}
});
}
});
}
Your offline region specified is exceeding the 6000 tile count limit. You can read more about this on our help pages and use the tile calculator to either reduce the region size or change the zoom levels downloaded.
Or you can use setOfflineMapboxTileCountLimit on newer versions
offlineManager.setOfflineMapboxTileCountLimit(20000000);
Sorry for my bad english, but i have problem and can't figure it out..
I have custom listview in my fragment for getting products from JSON array. And I have 3 ImageButtons in every listview row;
Plus Button(+), Minus Button(-) and Remove Button(X)..
So when i click each button, its calling JSON request for update product's piece number, getting new datas from response and repopulate array list.
Everything ok but, when I click that buttons faster, it seems there is 1 sec delay between multiple requests even first volley request has already done before.
Here is my JSON method in TableAdapter.java
public void JSON(final int position, final int process) {
if (inProgress==false) {
dialog = new ProgressDialog(myContext);
dialog.setMessage("Updating.....");
dialog.show();
inProgress = true;
System.out.println("**** Now request is beginning............");
final int rowID = tableModelList.get(position).getID();
final int treeID = tableModelList.get(position).getAna_dal();
final float price = tableModelList.get(position).getBFiyat();
final int quantity = tableModelList.get(position).getAdet();
final int print = tableModelList.get(position).getYazdimi();
final String insertUrl = "http://"+getServer+"/t6mobilservice/order-piece.php";
Map<String, String> parameters = new HashMap<>();
parameters.put("tableID", "" + getTableId);
parameters.put("rowID", "" + rowID);
parameters.put("treeID", ""+treeID);
parameters.put("process",""+process);
parameters.put("quantity",""+quantity);
parameters.put("price",""+price);
parameters.put("print",""+print);
CustomRequest jsObjRequest = new CustomRequest(Request.Method.POST, insertUrl, parameters, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray getOrders = response.getJSONArray("order");
Gson gson = new Gson();
tableModelList.clear();
for (int i = 0; i < getOrders.length(); i++) {
JSONObject order = getOrders.getJSONObject(i);
TableModel tableModel = gson.fromJson(order.toString(), TableModel.class);
tableModelList.add(tableModel);
}
mAdapter.notifyDataSetChanged();
System.out.println("**** onResponse: Request is done............");
System.out.println("**** JSON: "+response.toString());
dialog.cancel();
inProgress = false;
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError response) {
Log.d("Response: ", response.toString());
inProgress = false;
}
});
requestQueue.add(jsObjRequest);
}
}
Dialog is showing when request beginning and canceling when request is done. But as I said, when I click faster, there is a delay between multiple requests even first request has already done. I'm saying 1 sec, because 2nd request is beginning after 1 sec exactly, no matter how I clicking fast. I can't figure it out..
I tested fast clicks to showing toasts with random numbers and it's working fine. But when I testing with JSON method, there is a weird delay.
I have SwipeRefreshLayout and ScrollView in my fragment.
I'm using Volley with singleton.
EDIT 1. : Here's a video link to showing what my problem is..
EDIT 2. : Here's a LogCat output video for every click
Every fast click has returning success json output, but nothing change instantly..
Thanks for your help.
Alrighty, so I understand that this general question has been asked numerous times here, but I have yet to find an answer that makes sense to me. Almost every answer I've seen just says some blurb like, "hey, just throw this in your method and you're good", but I'm not seeing full examples, and what I've tried is not working either.
Here's the error I receive:
[mono] android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
So, simply put, I have an activity that grabs some information from a web service and then throws the web service results into a couple of TextViews. Could someone please help me figure out where and how I need to use the RunOnUiThread()? Here's the code:
using Android.App;
using Android.OS;
using System;
using System.Web;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Android.Widget;
namespace DispatchIntranet
{
[Activity (Label = "#string/Summary")]
public class SummaryActivity : Activity
{
private static readonly Log LOG = new Log(typeof(SummaryActivity));
private TextView summaryTotalRegularLabel;
private TextView summaryTotalRollover;
private TextView summaryScheduledLabel;
private TextView summaryRemainingRegular;
private string url;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// SET THE LAYOUT TO BE THE SUMMARY LAYOUT
SetContentView(Resource.Layout.Summary);
// INITIALIZE CLASS MEMBERS
init();
if (LOG.isInfoEnabled())
{
LOG.info("Making call to rest endpoint . . .");
if (LOG.isDebugEnabled())
{
LOG.debug("url: " + this.url);
}
}
try
{
// BUILD REQUEST FROM URL
HttpWebRequest httpReq = (HttpWebRequest)HttpWebRequest.Create(new Uri(this.url));
// SET METHOD TO 'GET'
httpReq.Method = GetString(Resource.String.web_service_method_get);
// ASK FOR JSON RESPONSE
httpReq.Accept = GetString(Resource.String.web_service_method_accept);
// INVOKE ASYNCHRONOUS WEB SERVICE
httpReq.BeginGetResponse((ar) => {
HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
using (HttpWebResponse response = (HttpWebResponse)request.EndGetResponse (ar))
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
// PUT RESPONSE INTO STRING
string content = reader.ReadToEnd();
// CONVERT STRING TO DYNAMIC JSON OBJECT
var json = JsonConvert.DeserializeObject<dynamic>(content);
if (LOG.isDebugEnabled())
{
LOG.debug("content: " + content);
LOG.debug("json: " + json);
LOG.debug("TOTAL_REGULAR_PTO_HOURS: " + json.d[0].TOTAL_REGULAR_PTO_HOURS);
}
// ** THIS IS WHAT WILL NOT WORK **
this.summaryTotalRegularLabel.Text = json.d[0].TOTAL_REGULAR_PTO_HOURS;
this.summaryTotalRollover.Text = json.d[0].TOTAL_ROLLOVER_PTO_HOURS;
this.summaryScheduledLabel.Text = json.d[0].TOTAL_USED_PTO_HOURS;
this.summaryRemainingRegular.Text = json.d[0].TOTAL_REMAINING_PTO_HOURS;
}
}
}, httpReq);
}
catch (Exception e)
{
LOG.error("An exception occurred while attempting to call REST web service!", e);
}
}
private void init()
{
// GET GUID FROM PREVIOUS INTENT AND DETERMINE CURRENT YEAR
string guid = Intent.GetStringExtra("guid");
int year = DateTime.Now.Year;
// BUILD URL
this.url = GetString(Resource.String.web_service_url)
+ GetString(Resource.String.ws_get_pto_summary)
+ "?" + "guid='" + HttpUtility.UrlEncode(guid) + "'"
+ "&" + "year=" + HttpUtility.UrlEncode(year.ToString());
// GET THE SUMMARY LABELS
this.summaryTotalRegularLabel = FindViewById<TextView>(Resource.Id.SummaryTotalRegular);
this.summaryTotalRollover = FindViewById<TextView>(Resource.Id.summaryTotalRollover);
this.summaryScheduledLabel = FindViewById<TextView>(Resource.Id.summaryScheduledLabel);
this.summaryRemainingRegular = FindViewById<TextView>(Resource.Id.SummaryRemainingRegular);
}
}
}
When you make a web service call, HttpWebRequest creates a new thread to run the operation on. This is done to keep your user interface from locking up or skip frames. Once your web service call is complete, you need to go back to the UI Thread to update the UI components that live on that thread. You can do that a couple of different ways.
First, you can wrap your code in an anonymous function call like so:
RunOnUiThread(()=>{
this.summaryTotalRegularLabel.Text = json.d[0].TOTAL_REGULAR_PTO_HOURS;
this.summaryTotalRollover.Text = json.d[0].TOTAL_ROLLOVER_PTO_HOURS;
this.summaryScheduledLabel.Text = json.d[0].TOTAL_USED_PTO_HOURS;
this.summaryRemainingRegular.Text = json.d[0].TOTAL_REMAINING_PTO_HOURS;
});
Or you can call a function via RunOnUiThread (jsonPayload is a field on the class):
jsonPayload = json;
RunOnUiThread(UpdateTextViews);
...
void UpdateTextViews()
{
this.summaryTotalRegularLabel.Text = jsonPayload.d[0].TOTAL_REGULAR_PTO_HOURS;
this.summaryTotalRollover.Text = jsonPayload.d[0].TOTAL_ROLLOVER_PTO_HOURS;
this.summaryScheduledLabel.Text = jsonPayload.d[0].TOTAL_USED_PTO_HOURS;
this.summaryRemainingRegular.Text = jsonPayload.d[0].TOTAL_REMAINING_PTO_HOURS;
}
I have been able to pull the Facebook newsfeed for the logged in user using the "me/home" Graph API Call and am displaying the result in an activity.
Now I have been trying numerous methods which will query the post's like column and check if the current user has liked a post to display the status. Essentially, I am setting a drawable to indicate the user has liked a post.
I cannot really post any code that I have tried so far simply because none of them work. And believe me, I have tried literally numerous methods.
I would appreciate if someone could at least prod me in the right direction.
EDIT: This is my latest attempt at querying the likes column and comparing the result with the current user's ID:
This code is where I am checking for likes count and adding them to an ArrayList. This is also where I am running the query to get the likes on the post.
// GET THE POST'S LIKES COUNT
if (json_data.has("likes")) {
JSONObject feedLikes = json_data.optJSONObject("likes");
String countLikes = feedLikes.getString("count");
postLikesCountArrayList.add(countLikes);
// TEST STARTS
// QUERY THE LIKES COLUMN TO CHECK YOUR LIKE STATUS ON A POST
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, Utility.mFacebook.getAccessToken());
Utility.mAsyncRunner.request(finalThreadID + "/likes&limit=200", params, new LikesListener());
// TEST ENDS
} else {
String countLikes = "0";
postLikesCountArrayList.add(countLikes);
}
And this code block is the Listener (a privte class in the same activity) where the results are checked:
private class LikesListener extends BaseRequestListener {
#Override
public void onComplete(final String response, final Object state) {
try {
JSONObject JOLikes = new JSONObject(response);
JSONArray JALikes = JOLikes.getJSONArray("data");
for (int i = 0; i < JALikes.length(); i++) {
JSONObject JOTemp = JALikes.getJSONObject(i);
if (JOTemp.has("id")) {
String getTempID = JOTemp.getString("id");
if (getTempID.equals(initialUserID)) {
Runnable run = new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
ImageView postYourLike = (ImageView) findViewById(R.id.postYourLike);
postYourLike.setBackgroundResource(R.drawable.btn_icon_liked);
}
};
TestNewsFeeds.this.runOnUiThread(run);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
You can use this fql. Replace the post_id
SELECT likes.can_like, likes.user_likes FROM stream WHERE post_id = "1274834235_3976149403543"
response would look like this, if user_likes is true, he has liked it
{
"data": [
{
"likes": {
"can_like": true,
"user_likes": false
}
}
]
}