2015-04-12 90 views
1

我是android Java中的新成員。 我想在使用Phonegap的android應用程序中共享圖像。我得到新的類「分享」爲CordovaPlugin,代碼就是按照...無法在android中共享圖像

Intent share = new Intent(Intent.ACTION_SEND); 
share.setType("image/*"); 
Uri uri = Uri.parse("file:///android_asset/www/sharethis.png"); 
share.putExtra(Intent.EXTRA_STREAM, uri); 
cordova.getActivity().startActivityForResult(share, 0); 

上面的代碼是不工作的,它顯示是這樣的...

enter image description here

是覺得我不能讓精確的圖像文件位置。 我的文件位置

enter image description here

我試圖婁代碼還可以,但不行,

String imagePath = Environment.getExternalStorageDirectory() 
       + "/assets/www/sharethis.png"; 

回答

0

的Android資源文件夾是專用於您的應用程序,所以你不能從那裏直接共享文件。您需要將文件從資產複製到文件系統中的公用目錄,然後發送指向公用文件的共享意向