Android Question How to make my app listed in popup menu of (from) another app for example Chrome?)?

bsnqt

Active Member
Licensed User
Longtime User
Like the title said, how can I make my app listed in the popup menu of another app, for example Chrome (webview?). And when the user click on my app name from that app's popup menu, it will bring him back to my app with the content (or string) that he selected. I am working with a dictionary / translator project.

It is not easy for me to describe in English, but you can watch the short clip attached.

Thank you for any direction / guide / instruction.

PS. I could not make any search in the forum as actually I don't where I should go first. It may be discussed in the forum, but I absolutely have no idea about how I can do it.

It seems that it is not possible to attached an .mp4 file

pic1.jpg
 
Last edited:
Solution
You need to find the correct intent filter.

Might be:
B4X:
AddActivityText(Main,
 <intent-filter> 
   <action android:name="android.intent.action.PROCESS_TEXT" />
   <data android:mimeType="text/plain"/>
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
)

Erel

B4X founder
Staff member
Licensed User
Longtime User
You need to find the correct intent filter.

Might be:
B4X:
AddActivityText(Main,
 <intent-filter> 
   <action android:name="android.intent.action.PROCESS_TEXT" />
   <data android:mimeType="text/plain"/>
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
)
 
Upvote 1
Solution

bsnqt

Active Member
Licensed User
Longtime User
Wow! It works! My app name does appear in the list and when I click it, it bring back to my app.
You make my day :D. Thanks a lot Erel.
Now what I need is just to intercept the received intent to look for the word/string. Am I right.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Appreciate your help. I will learn the examples. Thanks.
(Why I can click the "thank you" button only once? I need to click 10 times for you ? )
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Now I have 2 other new issues.

1) I have inserted the intent filter in the manifest as per your advice. I could intercept the intent in the sub Activity_Resume. But the uri seems always = null. But it does not give any exception. Where I am wrong?

B4X:
Sub Activity_Resume
      Dim in As JavaObject = Activity.GetStartingIntent
      Dim uri As Object = in.RunMethod("getStringExtra", Array("android.intent.extra.TEXT"))
            Try
                  Log("The uri is = " & uri)
            Catch
                  Log(LastException)
            End Try
End Sub

From the log:

The uri is = null

2) The third party app, from where the intent has been sent, will create another instance of my app. In the Recent app list, I can see there are 2 app instances. One is the "previous" when the user may leave it and my app does not completely exit. Another one is "new", called by the third party app. How can I handle it.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Oops, I have solved the 1st question. The correct code should be:

B4X:
    Dim uri As String = in.RunMethod("getStringExtra", Array("android.intent.extra.PROCESS_TEXT"))

Now for the second question, do I need to kill the "old" (first) instance of the app?
 
Upvote 0
Top