
El método más comentado para hacer este truquito consiste tan sólo en mandar por Whatsapp una imagen sin conexión a Internet, de tal forma que se quede en reintentar. Luego, mediante un explorador de archivos, sustituirla por otra con el mismo nombre (sdcard/whatsapp/media/whatsapp image/) y finalmente volverse a conectar a Internet y darle a reintentar. Sencillo, ¿verdad?. Por otra parte, la aplicación Android Magiapp lo hará de una forma más elegante, añadiendo la sorpresa ("magiapp.png") al enviar el fichero (android.intent.action.SEND).
Os dejo la función principal (si queréis el resto el código ya debéreis saber obtenerlo ;)):
public void createSurprise() { if(bit_big != null) { bit_big.recycle(); bit_big = null; } getCroppedBitmap(decodeSampledBitmapFromPath(selectedImagePathBig, size_big, size_big), size_big, 2); if(bit_big != null) goto _L2; else goto _L1 _L1: tostada(getString(0x7f040009)); // msg_error_loading_image _L9: return; _L2: if(bit_final != null) { bit_final.recycle(); bit_final = null; } if(bit_big.getHeight() >= 1 && bit_big.getWidth() >= 1) goto _L4; else goto _L3 _L3: tostada(getString(0x7f040015)); // msg_error_quality goto _L5 _L4: step = size_big / size_small; const_whatsapp = (-100 + size_big) / 200; bit_final = Bitmap.createBitmap(bit_big); if(bit_final != null && bit_small != null) goto _L7; else goto _L6 _L6: tostada(getString(0x7f040016)); // msg_error_leak_memory goto _L5 _L7: int i; int j; int k; i = bit_big.getHeight(); j = bit_big.getWidth(); k = const_whatsapp; _L10: if(k < i) break MISSING_BLOCK_LABEL_301; label0: { File file = new File(Environment.getExternalStorageDirectory().toString(), "magiapp.png"); FileOutputStream fileoutputstream; Intent intent; Uri uri; int l; int i1; int j1; try { fileoutputstream = new FileOutputStream(file); } catch(Exception exception1) { break label0; } try { bit_final.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fileoutputstream); fileoutputstream.flush(); fileoutputstream.close(); } catch(Exception exception) { } } bit_final.recycle(); bit_final = null; intent = findWhatsAppClient(); if(intent == null) { tostada(getString(0x7f040019)); // msg_no_whatsapp new Intent("android.intent.action.SEND"); } else { uri = Uri.fromFile(file); intent.setType("image/png"); intent.putExtra("android.intent.extra.STREAM", uri); startActivity(Intent.createChooser(intent, getString(0x7f04000e))); // send_whatsapp quality_selected = false; } _L5: if(true) goto _L9; else goto _L8 _L8: l = const_whatsapp; _L11: label1: { if(l < j) break label1; k += step; } goto _L10 i1 = (k - const_whatsapp) / step; j1 = (l - const_whatsapp) / step; bit_final.setPixel(l, k, bit_small.getPixel(j1, i1)); l += step; goto _L11 }
No hay comentarios:
Publicar un comentario