Android GraphObject - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GraphObject class.

This code example shows how to use the following methods:getInnerJSONObject, getProperty
     * Acquire the current attribution id from the facebook app. 
     * @return returns null if the facebook app is not present on the phone. 
     */ 
    public static String getAttributionId(ContentResolver contentResolver) {
        String [] projection = {ATTRIBUTION_ID_COLUMN_NAME};
        Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
        if (c == null || !c.moveToFirst()) {
            return null; 
        } 
        String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
        c.close();
        return attributionId;
    } 
 
    /** 
     * Gets the current version of the Facebook SDK for Android as a string. 
     * 
     * @return the current version of the SDK 
     */ 
    public static String getSdkVersion() {

7
CodeRank
This code example shows how to use the following methods:asMap, getProperty
 
        return (result != null) ? result : "";
    } 
 
    protected CharSequence getTitleOfGraphObject(T graphObject) {
        return (String) graphObject.getProperty(NAME);
    } 
 
    protected CharSequence getSubTitleOfGraphObject(T graphObject) {
        return null; 
    } 
 
    protected URI getPictureUriOfGraphObject(T graphObject) {
        String uri = null;
        Object o = graphObject.getProperty(PICTURE);
        if (o instanceof String) {
            uri = (String) o;
        } else if (o instanceof JSONObject) {
            ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
            ItemPictureData data = itemPicture.getData();

6
CodeRank
This code example shows how to use the following methods:getProperty, removeProperty
        final String commentMessage = "It truly is a wonderful status update.";
        comment.setProperty("message", commentMessage);
 
        GraphObject createdComment1 = batchCreateAndGet(session, statusID + "/comments", comment, null,
                GraphObject.class);
        assertNotNull(createdComment1);
 
        String comment1ID = (String) createdComment1.getProperty("id");
        String comment1Message = (String) createdComment1.getProperty("message");
        assertNotNull(comment1ID);
        assertNotNull(comment1Message);
        assertEquals(commentMessage, comment1Message);
 
        // Try posting the same comment to the same status update. We need to clear its ID first. 
        createdComment1.removeProperty("id");
        GraphObject createdComment2 = batchCreateAndGet(session, statusID + "/comments", createdComment1, null,
                GraphObject.class);
        assertNotNull(createdComment2);
 
        String comment2ID = (String) createdComment2.getProperty("id");
        String comment2Message = (String) createdComment2.getProperty("message");
6
CodeRank
This code example shows how to use the following methods:cast
            return null; 
        } 
        if (graphObjectClass == null) {
            throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
        } 
        return graphObject.cast(graphObjectClass);
    } 
 
    /** 
     * The list of graph objects returned for this request, if any. 
     * 
     * @return the list of graph objects returned, or null if none was returned (or if the result was not a list) 
     */ 
    public final GraphObjectList<GraphObject> getGraphObjectList() {
        return graphObjectList;
    } 
 
    /** 
     * The list of graph objects returned for this request, if any, cast into a particular type of GraphObject. 
     * 
6
CodeRank
This code example shows how to use the following methods:cast
        FacebookRequestError error = responses.get(0).getError();
        assertTrue(error.getException() instanceof FacebookServiceException);
        assertTrue(error.getErrorType() != null);
        assertTrue(error.getErrorCode() != FacebookRequestError.INVALID_ERROR_CODE);
    } 
 
    @LargeTest 
    public void testBatchPostStatusUpdate() { 
        TestSession session = openTestSessionWithSharedUser();
 
        GraphObject statusUpdate1 = createStatusUpdate("1");
        GraphObject statusUpdate2 = createStatusUpdate("2");
 
        Request postRequest1 = Request.newPostRequest(session, "me/feed", statusUpdate1, null);
        postRequest1.setBatchEntryName("postRequest1");
        Request postRequest2 = Request.newPostRequest(session, "me/feed", statusUpdate2, null);
        postRequest2.setBatchEntryName("postRequest2");
        Request getRequest1 = new Request(session, "{result=postRequest1:$.id}");
        Request getRequest2 = new Request(session, "{result=postRequest2:$.id}");
 
5
CodeRank
This code example shows how to use the following methods:getProperty
	                public void onCompleted(Response response) {
	                    GraphObject graphObject = response.getGraphObject();
	                    FacebookRequestError error = response.getError();
	                    String s = textViewResults.getText().toString();
	                    if (graphObject != null) {
	                        if (graphObject.getProperty("id") != null) {
	                            s = s + String.format("%s: %s\n", graphObject.getProperty("id"), graphObject.getProperty(
	                                    "name")); 
	                        } else { 
	                            s = s + String.format("%s: <no such id>\n", requestId);
	                        } 
	                    } else if (error != null) {
	                        s = s + String.format("Error: %s", error.getErrorMessage());
	                    } 
	                    textViewResults.setText(s);
	                } 
	            })); 
	        } 
	        pendingRequest = false;
	        Request.executeBatchAndWait(requests);
4
CodeRank
This code example shows how to use the following methods:getProperty, getBirthday, getFirstName, getId, getLastName
				 
				JSONObject location = new JSONObject();
				 
				//must also check if I get all the data! 
				try { 
					me.put("username", user.getUsername());
					me.put("picture", "http://graph.facebook.com/" + user.getId() + "/picture");
					me.put("first_name", user.getFirstName());
					me.put("last_name", user.getLastName());
					me.put("name", user.getName());
					me.put("locale", user.getProperty("locale"));
					me.put("gender", user.getProperty("gender"));
					me.put("email", user.getProperty("email"));
					me.put("birthday", user.getBirthday());
					/*location.put("id", user.getLocation().getProperty("id")); 
					location.put("name", user.getLocation().getProperty("name"));*/ 
					me.put("location", location);
					me.put("timezone", user.getProperty("timezone"));
					me.put("updated_time", user.getProperty("updated_time"));
					me.put("id", user.getId());	

3
CodeRank
This code example shows how to use the following methods:getInnerJSONObject
 
	@Override 
	public void onCompleted(Response response) {
		progressDialog.dismiss();
		GraphObject obj = response.getGraphObject();
		Log.d("", "response: " + obj.getInnerJSONObject());
		 
		String txt = "Publicado com sucesso!";
		Toast.makeText(this, txt, Toast.LENGTH_SHORT).show();
		goBack(null); 
	} 
 
	public static void setSolicitationName(String name, String pronoum) {
		solicitationName = name;
		solicitationPronoum = pronoum;
		 
	} 
	 
} 
3
CodeRank
This code example shows how to use the following methods:cast
            return null; 
        } 
        if (graphObjectClass == null) {
            throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
        } 
        return graphObject.cast(graphObjectClass);
    } 
 
    /** 
     * The list of graph objects returned for this request, if any. 
     * 
     * @return the list of graph objects returned, or null if none was returned (or if the result was not a list) 
     */ 
    public final GraphObjectList<GraphObject> getGraphObjectList() {
        return graphObjectList;
    } 
 
    /** 
     * The list of graph objects returned for this request, if any, cast into a particular type of GraphObject. 
     * 
3
CodeRank
This code example shows how to use the following methods:cast
 
		if (session == null) {
			return; 
		} 
 
		List<String> permissions = session.getPermissions();
		if (!permissions.containsAll(PERMISSIONS)) {
			requestPublishPermissions(session);
			return; 
		} 
 
		// progressDialog = ProgressDialog.show(getApplicationContext(), 
		// "progress", "progress", true); 
 
		// Run this in a background thread since we don't want to 
		// block the main thread. Create a new AsyncTask that returns 
		// a Response object 
		AsyncTask<Void, Void, Response> asyncTask = new AsyncTask<Void, Void, Response>() {
 
			@Override 
3
CodeRank

Related Android GraphObject Questions & Answers:

See Code Examples for Android GraphObject Methods: