Android Question Unable to load Image in last version of Instagram

asales

Expert
Licensed User
Longtime User
Since I updated the Instagram (v.133), I get this error "Unable to load image" in the intent.
With the previous version of Instagram (v.132) works fine.
What could be happening?
Thanks in advance for any tip.
B4X:
Dim inten As Intent
inten.Initialize(inten.ACTION_SEND,"")
inten.SetType("image/*")
inten.PutExtra("android.intent.extra.STREAM", CreateFileProviderUri(Starter.SharedFolder, "myimage.jpg"))
    
Dim IntentInstagram As String
Dim pm As PackageManager
For Each cn As String In pm.QueryIntentActivities(inten)
    If (cn.SubString2(0,21) = "com.instagram.android") And (cn.Contains("ShareHandlerActivity")) Then
        IntentInstagram = cn
        Exit
    End If
Next
inten.SetComponent(IntentInstagram)
    
StartActivity(inten)
 

asales

Expert
Licensed User
Longtime User
Better to use FileProvider class.
- I tried with FileProvider code, but don't work:
B4X:
  intent.PutExtra("android.intent.extra.STREAM", Starter.Provider.GetFileUri("myimage.jpg"))
- I tried with the FileProvider example and it didn't work too.
- The problem is only with the new version of Instagram
- The problem is to share in the feed of Instagram. Share in Direct and Stories it's ok.
- The problem is with the type = image (image/* , image/jpeg). With "video/*" works

I don't know what changed in Instagram and how to fix this issue.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
The documentation still the same:

I found this:
He says: "I searched and found a solution. I do not know this is right way but solved my problem"
B4X:
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
How I can put this lines in the intent?

Thanks for your help.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
These lines do not go into the intent. This also doesn't look like the best solution if it really works.
B4X:
Dim StrictMode As JavaObject
StrictMode.InitializeStatic("android.os.StrictMode")
Dim builder As JavaObject
StrictMode.RunMethod("setVmPolicy", Array(builder.InitializeNewInstance("android.os.StrictMode$VmPolicy$Builder", Null).RunMethod("build", Null)))

To further debug it you need to connect to the device with USB debug mode and check the unfiltered logs. This will allow you tread instagram logs.
 
Upvote 0
Top