No se pueden obtener las solicitudes de entrada de facebook
Estoy tratando de implementar enviar datos y aceptar que los datos en mi aplicación de juego de Facebook android. Estoy siguiendo https://developers.facebook.com/docs/android/send-requests/#notifications tutorial para eso. Puedo enviar la solicitud sin embargo no puedo aceptar los datos en el lado del destinatario.
Mi intentUri
devolver null cada vez, así que es que no puedo obtener requestIds.
- Integración de FaceBook, Twitter, Redes sociales en Android
- twitter4j alcanza la longitud máxima cuando envía la imagen con texto en android
- Twitter Android App - Código fuente
- Crear un "Tweet este botón" para compartir información sólo en Twitter no es tan fácil
- Twitter4J + Android: El desafío de autenticación es una excepción nula
Mi código para obtener los datos en el lado del destinatario:
intentUri = MainActivity.this.getIntent().getData(); if (intentUri != null) { String requestIdParam = intentUri.getQueryParameter("request_ids"); if (requestIdParam != null) { String array[] = requestIdParam.split(","); requestId = array[0]; Log.i("Request id: ", "Request id: " + requestId); }else{ Log.i("Request id: ", "null" ); } } else { Log.i("intentUri", "null"); //**Always printing this part** }
Método onSessionStateChange () para llamar al método requestData
private void onSessionStateChange(Session session, SessionState state,Exception exception) { if (state.isOpened() && requestId != null) { getRequestData(requestId); requestId = null; } }
Estoy enviando solicitud utilizando el siguiente método:
private void sendRequestDialog() { Bundle params = new Bundle(); params.putString("message", "Learn how to make your Android apps social"); params.putString("data", "{\"badge_of_awesomeness\":\"1\"," + "\"social_karma\":\"5\"}"); WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder( MainActivity.this, Session.getActiveSession(), params)) .setOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { if (error != null) { if (error instanceof FacebookOperationCanceledException) { Toast.makeText(MainActivity.this, "Request cancelled", Toast.LENGTH_SHORT) .show(); } else { Toast.makeText(MainActivity.this, "Network Error", Toast.LENGTH_SHORT) .show(); } } else { final String requestId = values .getString("request"); if (requestId != null) { Toast.makeText(MainActivity.this, "Request sent", Toast.LENGTH_SHORT) .show(); } else { Toast.makeText(MainActivity.this, "Request cancelled", Toast.LENGTH_SHORT) .show(); } } } }).build(); requestsDialog.show(); }
Código para aceptar la Solicitud como se indica a continuación:
private void getRequestData(final String inRequestId) { // Create a new request for an HTTP GET with the // request ID as the Graph path. Request request = new Request(Session.getActiveSession(), inRequestId, null, HttpMethod.GET, new Request.Callback() { @Override public void onCompleted(Response response) { // Process the returned response GraphObject graphObject = response.getGraphObject(); FacebookRequestError error = response.getError(); // Default message String message = "Incoming request"; if (graphObject != null) { // Check if there is extra data if (graphObject.getProperty("data") != null) { try { // Get the data, parse info to get the // key/value info JSONObject dataObject = new JSONObject( (String) graphObject .getProperty("data")); // Get the value for the key - // badge_of_awesomeness String badge = dataObject .getString("badge_of_awesomeness"); // Get the value for the key - social_karma String karma = dataObject .getString("social_karma"); // Get the sender's name JSONObject fromObject = (JSONObject) graphObject .getProperty("from"); String sender = fromObject .getString("name"); String title = sender + " sent you a gift"; // Create the text for the alert based on // the sender // and the data message = title + "\n\n" + "Badge: " + badge + " Karma: " + karma; } catch (JSONException e) { message = "Error getting request info"; } } else if (error != null) { message = "Error getting request info"; } } Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); deleteRequest(inRequestId); } }); // Execute the request asynchronously. Request.executeBatchAsync(request); }
Nota: Sólo estoy usando la actividad simple, no estoy usando fragmentos
- No se puede establecer devolución de llamada al cargar la línea de tiempo del usuario con Fabric Twitter Kit en la aplicación de Android
- Cómo instalar el kit de twitter con el plugin de tejido en el estudio de Android
- La integración de twitter en la aplicación para Android
- Message - Sus credenciales no permiten el acceso a este recurso. Código - 220
- Conexión / autenticación de Twitter en Android Fragment
- Faltan credenciales de autenticación de Twitter4j
- Android envía mensajes directos de Twitter a través de la intención
- Cómo obtener la imagen de perfil en android con Twitter kit,
El método getIntent()
devuelve la intención que inició la actividad. Puede intentar reemplazar el método Activity
protected void onNewIntent(Intent intent)
Y llama
setIntent(Intent intent)
desde allí.
También puede intentar solicitar sus datos utilizando:
Intent intent = MainActivity.this.getIntent(); Bundle bundle = intent.getExtras(); intentUri = (Uri)bundle.get(Intent.EXTRA_TEXT);
Aparte de eso, ¿dónde y cómo se llama intent.putExtra("request_ids", data)
?
No estoy seguro si he entendido completamente su problema,
De todos modos, te deseo buena suerte.
EDITAR:
Es posible que desee utilizar Intent.EXTRA_STREAM en lugar de Intent.EXTRA_TEXT, dependiendo de cómo almacene los datos
- Android.view.InflateException (Error inflar clase) sólo en la producción
- Vista del temporizador android (al igual que la barra de progreso) actualizando con colores en Lienzo