WrapAsIntentChooser doesn't work?

Inman

Well-Known Member
Licensed User
Longtime User
My app has 2 activities. One is the normal main activity that is opened from the launcher by clicking it's icon. The second is the share activity which basically adds my app to the Android "Share" menu. And this works fine as well as I get the data passed from the Share menu, correctly in my share activity.

Now the issue is with the intent chooser. Check the following code:

B4X:
Dim i As Intent
    i.Initialize(i.ACTION_SEND, "")
    i.SetType("text/*")
    i.PutExtra("android.intent.extra.TEXT", "this is the message")
    i.WrapAsIntentChooser("Choose")
    StartActivity(i)

This is a simple code that should show the Android share menu. The above code works fine when given inside the Activity_Create of the main activity. But when I put it inside the Activity_Create of my share activity, nothing happens.

In other words, when I call my app from the Android web browser using share menu, the above code doesn't show the chooser window. Is this some limitation of the Android system?
 

Inman

Well-Known Member
Licensed User
Longtime User
This is how I defined the share activity in the Manifest file.

<activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name="share" android:label="Browser app" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>

And the share part actually works. I can get the url shared by browser, using activity.GetStartingIntent and intent.GetExtra, inside the Activity_Create.

It is just that I cannot get the chooser window for any kind of intent. And no, it doesn't start any other activity. It has an activity.finish given at the end of Activity_Create, but even when I commented that line, the chooser window doesn't show up.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Cool. Timer did the trick. But the following need to be done to get this working:

  1. Timer interval should be at least 100
  2. activity.finish, which is needed to close this activity automatically, should be moved from Activity_Create to Timer_Tick
  3. Timer_Tick should have a DoEvents before the call StartActivity(intent1) (in my case at the beginning itself)
 
Upvote 0
Top