当前位置: 首页>>代码示例>>Java>>正文


Java Request.Callback方法代码示例

本文整理汇总了Java中com.facebook.Request.Callback方法的典型用法代码示例。如果您正苦于以下问题:Java Request.Callback方法的具体用法?Java Request.Callback怎么用?Java Request.Callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.Request的用法示例。


在下文中一共展示了Request.Callback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publishStory

import com.facebook.Request; //导入方法依赖的package包/类
private void publishStory(Session session) 
{
	Bundle postParams = new Bundle();
	postParams.putString("name", "Você Fiscal");

	// Receber os dados da eleição!!!
	postParams.putString("message", "Eu fiscalizei a seção: "+ this.secao +"\nNa zona eleitoral: " + this.zonaEleitoral + "\nNo município de: " + this.municipio);			
	postParams.putString("description", "Obrigado por contribuir com a democracia!");
	postParams.putString("link", "http://www.vocefiscal.org/");
	postParams.putString("picture", "http://imagizer.imageshack.us/v2/150x100q90/913/bAwPgx.png");

	Request.Callback callback= new Request.Callback() 
	{
		public void onCompleted(Response response) 
		{
			JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
			String postId = "Compartilhado com sucesso!";
			try 
			{
				postId = graphResponse.getString("Compartilhado com sucesso!");
			} catch (JSONException e) 
			{
			}
			FacebookRequestError error = response.getError();
			if (error != null) 
			{
				Toast.makeText(FiscalizacaoConcluidaActivity.this.getApplicationContext(),error.getErrorMessage(),Toast.LENGTH_SHORT).show();
			} else 
			{
				Toast.makeText(FiscalizacaoConcluidaActivity.this.getApplicationContext(),	postId,	Toast.LENGTH_LONG).show();
			}
		}
	};

	Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback);

	RequestAsyncTask task = new RequestAsyncTask(request);
	task.execute();
}
 
开发者ID:vocefiscal,项目名称:vocefiscal-android,代码行数:40,代码来源:FiscalizacaoConcluidaActivity.java

示例2: postImageToFacebook

import com.facebook.Request; //导入方法依赖的package包/类
private void postImageToFacebook() {
    Session session = Session.getActiveSession();
    final Uri uri = (Uri) mExtras.get(Intent.EXTRA_STREAM);
    final String extraText = mPostTextView.getText().toString();
    if (session.isPermissionGranted("publish_actions"))
    {
        Bundle param = new Bundle();

        // Add the image
        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte[] byteArrayData = stream.toByteArray();
            param.putByteArray("picture", byteArrayData);
        } catch (IOException ioe) {
            // The image that was send through is now not there?
            Assert.assertTrue(false);
        }

        // Add the caption
        param.putString("message", extraText);
        Request request = new Request(session,"me/photos", param, HttpMethod.POST, new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                addNotification(getString(R.string.photo_post), response.getGraphObject(), response.getError());

            }
        }, null);
        RequestAsyncTask asyncTask = new RequestAsyncTask(request);
        asyncTask.execute();
        finish();
    }
}
 
开发者ID:b099l3,项目名称:FacebookImageShareIntent,代码行数:35,代码来源:FacebookShareActivity.java

示例3: insertFriends

import com.facebook.Request; //导入方法依赖的package包/类
public void insertFriends(final Activity activity, final FacebookSettingActivity.ToastHelper th) {
    final Set<String> facebookIds = getContactsFacebookIds(activity);
    
    String fql = "SELECT uid, name, username, pic, pic_big FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";

    Bundle params = new Bundle();
    params.putString("q", fql);
    final FacebookIdSaver fbs = new FacebookIdSaver();
    Session session = Session.getActiveSession();
    Request request = new Request(session, "/fql", params, HttpMethod.GET,
            new Request.Callback() {
              public void onCompleted(Response response) {
                try {
                  GraphObject go = response.getGraphObject();
                  if (go == null) {
                    th.showToast(activity.getString(R.string.unable_to_update_fb_contact));
                    return;
                  }
                  JSONObject jso = go.getInnerJSONObject();
                  JSONArray arr = jso.getJSONArray("data");
                  int count = arr.length();

                  // display some statistics
                  Date start = new Date();
                  int toastInterval = 20;
                  long nextToast = start.getTime() + toastInterval * 1000;
                  Resources res = activity.getResources();
                  for (int i = 0; i < count; i++) {
                    // count statistics
                    String timeleftStr = "";
                    if (new Date().getTime() > nextToast) {
                      int diff = (int) (new Date().getTime() - start.getTime());
                      int timeLeftInSec = (int) ((diff / (i + 1)) * (count - i)) / 1000;
                      Log.d("rgai", "remaining synctime -> " + timeLeftInSec);
                      int timeLeftInMin = timeLeftInSec / 60;
                      if (timeLeftInMin > 0) {
                        timeLeftInSec -= timeLeftInMin * 60;
                      }
                      String min = timeLeftInMin > 0 ? res.getQuantityString(R.plurals.minutes, timeLeftInMin, timeLeftInMin) : "";
                      String sec = timeLeftInSec > 0 ? res.getQuantityString(R.plurals.seconds, timeLeftInSec, timeLeftInSec) : "";
                      timeleftStr = min + " " + sec;
                      String toastStr = String.format(activity.getString(R.string.still_updating_xtime_left), timeleftStr);
                      th.showToast(toastStr);
//              Toast.makeText(activity, timeleftStr + , Toast.LENGTH_LONG).show();
                      nextToast += toastInterval * 1000;
                    }
                    JSONObject json_obj = arr.getJSONObject(i);

                    if (!(facebookIds.contains(json_obj.getString("uid")))) {

                      //ezek adják vissza a szükséges adatokat
                      String uid = json_obj.getString("uid");
                      String name = json_obj.getString("name");
                      String username = json_obj.getString("username");

                      FacebookIntegrateItem fbii = new FacebookIntegrateItem(name, username, uid, json_obj.getString("pic"), json_obj.getString("pic_big"));
                      fbs.integrate(activity, fbii);

                    } else {
//                      Log.d("rgai", "ez a contact id mar bennevan: " + json_obj.getString("uid") + ": " + json_obj.getString("name"));
                    }

//            Log.d("rgai", "Integrating user ("+ (i+1) +"/"+ arr.length() +") -> " + name);
                  }
                } catch (JSONException e) {
                  Log.d("rgai", "json exception", e);
                }
              }
            });

    Request.executeAndWait(request);
  }
 
开发者ID:k-kojak,项目名称:yako,代码行数:73,代码来源:FacebookFriendProvider.java

示例4: onClickPickQuery

import com.facebook.Request; //导入方法依赖的package包/类
public void onClickPickQuery() {

    String fqlQuery = "{"
        + "'notifications':'SELECT unread, unseen,recent_authors, thread_id FROM thread where folder_id=0 AND unseen > 0 ORDER BY thread_id DESC ',"
        + "'messages':'SELECT author_id, created_time, body FROM message WHERE thread_id IN "
        + "(SELECT thread_id FROM #notifications)',"
        + "'users':'SELECT uid, name, pic_square FROM user WHERE uid IN "
        + "(SELECT author_id FROM #messages)',"
        + "}";

    Bundle params = new Bundle();
    params.putString("q", fqlQuery);

    Session session = Session.getActiveSession();
    Request request = new Request(session, "/fql", params, HttpMethod.GET,
        new Request.Callback() {
          @Override
          public void onCompleted(Response response) {

            try {

              GraphObject go = response.getGraphObject();
              JSONObject jso = go.getInnerJSONObject();
              JSONArray arr = jso.getJSONArray("data").getJSONObject(1)
                  .getJSONArray("fql_result_set");
              JSONArray arr2 = jso.getJSONArray("data").getJSONObject(2)
                  .getJSONArray("fql_result_set");

              if (arr.length() != 0) {
                String name = "";
                for (int i = 0; i < (arr.length()); i++) {

                  JSONObject json_obj = arr.getJSONObject(i);
                  JSONObject json_obj2;

                  for (int j = 0; j < (arr2.length()); j++) {

                    json_obj2 = arr2.getJSONObject(j);

                    if (json_obj.getString("author_id").contains(json_obj2.getString("uid"))) {
                      name += json_obj2.getString("name");
                      name += " : ";

                    }

                  }

                  name += json_obj.getString("body");
                  name += "\n";
                  Log.i("FONTOS", name.toString());

                }

              } else {

                Log.i("FONTOS", "Nincs adat!");
              }

        } catch (JSONException e) {
          Log.d("rgai", "", e);
        }

          }
        });
    Request.executeAndWait(request);

  }
 
开发者ID:k-kojak,项目名称:yako,代码行数:68,代码来源:FacebookMessageProvider.java


注:本文中的com.facebook.Request.Callback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。