Android Question Trigger event when clicked on the "cancel" of an Intent view

Meigionel TS

Member
Licensed User
I was trying this code to open a package in playstore:

B4X:
    Dim fURI As String
    fURI = "market://details?id=com.b4a.example"
    Dim Market As Intent
    Market.Initialize(Market.ACTION_VIEW,fURI)
    StartActivity(Market)

However, it gives an option to any of the two android marketplaces. That's fine, but I need to know when the person clicks on the cancel. How to know when the user clicked the cancel button in an Intent activity? Here is a screenshot to better understand what exactly I mean.
 

Attachments

  • WhatsApp Image 2018-08-06 at 7.36.05 PM.jpeg
    WhatsApp Image 2018-08-06 at 7.36.05 PM.jpeg
    16 KB · Views: 388

MarkusR

Well-Known Member
Licensed User
Longtime User
i know for "newer" android there was a function startActivityForResult , maybe if you use this you get any feedback.

or use PackageManager class (from phone lib) if the user had installed this.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
i know for "newer" android there was a function startActivityForResult
startActivityForResult is available in all versions of Android.
However I'm not sure that it will help you in this case. The user doesn't need to choose here. You want that it will be open with Google Play, right?

Use this code:
B4X:
Dim fURI As String = "market://details?id=com.b4a.example"
Dim Market As Intent
Market.Initialize(Market.ACTION_VIEW,fURI)
Dim pm As PackageManager 'Phone library
For Each act As String In pm.QueryIntentActivities(Market)
   If act.StartsWith("com.android") Then
       Market.SetComponent(act)
       Exit
   End If
Next
StartActivity(Market)
 
Upvote 0

Meigionel TS

Member
Licensed User
The user doesn't need to choose here
They will need to choose? :/ Because some audience does not download from Google Play because they often throw low memory exceptions from old devices that's why many users (specially from South East Asia) prefer other android market places? Can you help?
 
Upvote 0
Top