Android Question Can Activity.GetStartingIntent be reset or cleared?

Discussion in 'Android Questions' started by Gregg Homan, Feb 19, 2014.

  1. Gregg Homan

    Gregg Homan Member Licensed User

    Hello,

    I use the code (below) within Activity_Create to process starting intents stemming from multiple images selected via Gallery app's share menu. I also added intent filters (below) to my manifest file so that my app is visible and 'selectable' from Gallery app's share menu. Everything works fine except that the code below keeps seeing the same starting intent each time Activity_Create() is invoked by successively pausing and resuming of my app. I added a string variable named strStartingIntent (below) to 'strong-arm' a solution, but, I am looking for a more elegant way to reset or clear 'something' within the starting intent so that successive calls to Activity.GetStartingIntent do not keep returning the same intent.

    Q1) Can anyone suggest a way to reset or clear 'something' within the starting intent?

    Q2) Also, I am aware of the ContentChooser module for single file selections; but, can anyone suggest a B4A module/library that mimics gallery app's functionality that enables multiple file selection via share menu?

    Thanks,
    Gregg

    Code used withing Activity_Create() to process multiple image intents
    Code:
    Sub Process_Globals
       
    Dim strStartingIntent As String
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
        
    Dim Intent1 As Intent
        Intent1 = 
    Activity.GetStartingIntent
        
    If  Intent1.HasExtra("android.intent.extra.STREAM"Then
            
    Dim str As String = Intent1.ExtrasToString.ToLowerCase
            
    If str <> strStartingIntent Then
                strStartingIntent = str
                
    'Process Intent
            End If
        
    End If
    End Sub
    Intent filters that I added to the manifest file
    Code:
    AddActivityText(Main,
    <
    intent-filter>
        <action android:name=
    "android.intent.action.SEND" />
        <category android:name=
    "android.intent.category.DEFAULT" />
        <data android:mimeType=
    "image/*" />
    </
    intent-filter>
    <
    intent-filter>
        <action android:name=
    "android.intent.action.SEND_MULTIPLE" />
        <category android:name=
    "android.intent.category.DEFAULT" />
        <data android:mimeType=
    "image/*" />
    </
    intent-filter>)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Make Intent1 a process global variable. Now add this check:
    Code:
    If Activity.GetStartingIntent = Intent1 Then
     
    'intent already handled
    Else
     Intent1 = 
    Activity.GetStartingIntent
     ...
    End If
     
    Kwame Twum likes this.
  3. Francisco Barbosa

    Francisco Barbosa Member Licensed User

    Thanks a lot!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice