2016-05-19 9 views
0

私はそれに対して相対レイアウトとテキストビューを持っています。次に、その相対レイアウトをビットマップイメージに変換し、ディレクトリに保存します。androidのwhatsapp共有中に共有のインテントデータをクリアする


私は私が閉じるまで、共有画像のプレビューは私に古いものを見せているのWhatsAppを通じて共有していたとき、私はアプリのほとんどで、画像を共有していたときに問題がある、私は正しいイメージが見つかりましたがのWhatsAppの場合アプリ。なぜ更新されないのですか?whatsappで画像を共有すると、プレビューは古いもので、画像は正しく表示されます。これはFBは、Gmailなどで正常に動作します...


これはこれはDirecoryを作成するためのファイルシステムに変換されたビットマップイメージに変換して保存するため、以下のコード(ディレクトリ)

です:

File dir = null; 
String directorySubPath = "Android/data/com.domainname.appname/sharedResource/"; 
String imageNameForSave = "/qqq.png"; 

if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) 
     { 
      Toast.makeText(this, "Your device doesn't have external storage.", Toast.LENGTH_SHORT).show(); 
      return; 
     } 
     else 
     { 
      Log.d("SD", "YES", null); 
      dir = new File(Environment.getExternalStorageDirectory()+File.separator+directorySubPath); 
      if (!dir.exists()){ 
       dir.mkdirs(); 
      } 
      else { 
       Log.d("Q-Design:", "Already created", null); 
      } 
     } 

これはビットマップイメージ&を保存するコードを変換するためのものです。

rLayout.setDrawingCacheEnabled(true); 
Bitmap bmp = Bitmap.createBitmap(rLayout.getDrawingCache()); 
FileOutputStream out = new FileOutputStream(dir+imageNameForSave); 
bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); 
out.flush(); 
out.close(); 
rLayout.setDrawingCacheEnabled(false); 

これはインテントを介してその画像を共有するためのものである:

Uri uri = Uri.parse("file:///" + dir + imageNameForSave); 

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); 
shareIntent.setType("image/jpg"); 
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test Mail"); 
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Data Shared with you..."); 
shareIntent.putExtra(Intent.EXTRA_STREAM, uri); 
startActivity(Intent.createChooser(shareIntent, "Share via:")); 

答えて

0

ストリングimageNameForSave 例で動的な名前を使用します。文字列imageNameForSave = "/ qqq" + mydate + ext;

関連する問題