2015-06-23 2 views
6

Ich verwende eine Sharing-Funktionalität zu sozialen Anwendung mit Intent.Instagram Sharing-Problem: manchmal bekomme ich die Meldung "Kann Bild nicht laden"

Ich habe ein Problem mit der Freigabe eines Bildes in Instagram.

Einige Male erhalte ich die Meldung

Bild kann nicht geladen werden.

Hier ist mein Code:

String path="content://media/external/images/media/32872"; 

Intent shareIntent = new Intent(); 
shareIntent.setType("image/jpeg"); 
shareIntent.setAction(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path)); 
shareIntent.setPackage("com.instagram.android"); 
startActivity(shareIntent); 

Wie kann ich dieses Problem beheben?

Antwort

3

wenn Sie Datei dann unter Code verwenden Bild zu teilen,

private void shareIntagramIntent(String path) { 
     Intent intent = getActivity().getPackageManager() 
       .getLaunchIntentForPackage("com.instagram.android"); 
     if (intent != null) { 
      Intent shareIntent = new Intent(); 
      shareIntent.setAction(Intent.ACTION_SEND); 
      shareIntent.setPackage("com.instagram.android"); 
      try { 
       shareIntent.putExtra(Intent.EXTRA_STREAM, 
         Uri.parse("file://" + path)); 
      } catch (Exception e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 
      shareIntent.setType("image/jpeg"); 

      startActivity(shareIntent); 
     } else { 
      // bring user to the market to download the app. 
      // or let them choose an app? 
      intent = new Intent(Intent.ACTION_VIEW); 
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      intent.setData(Uri.parse("market://details?id=" 
        + "com.instagram.android")); 
      startActivity(intent); 
     } 
    } 
+1

Dank für Ihre Antwort danken. Ich habe diesen Code auch benutzt, aber es hat nicht funktioniert. –

+2

Heute hatte ich das selbe Problem mit Instagram, aber über Code funktionierte für mich. das ist wichtig Uri.parse ("file: //" + path). – NullByte

+0

Das ist gut. Aber welcher Weg warst du in Uri? Kannst du deinen Weg teilen? @NullByte –

0

Try this:

File filepath = Environment.getExternalStorageDirectory(); 
cacheDir = new File(filepath.getAbsolutePath() + "/LikeIT/"); 
cacheDir.mkdirs(); 
Intent intent = new Intent(); 
intent.setType("image/*");  
intent.setAction(Intent.ACTION_SEND); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filepath.getAbsolutePath())); 
activity.startActivity(intent);   
Verwandte Themen