Android Question Problem with contentchooser and activity_create

Discussion in 'Android Questions' started by Sub7, Feb 7, 2015.

  1. Sub7

    Sub7 Active Member Licensed User

    Hi,
    it randomly happens that when i pick and image from gallery using the contentchooser the activity is destroyed. How i can prevent this?

    I have tried to start a service in foreground when launching the contentchooser and stop the service on success but this does not works for me, it still happends.

    Anyone has some working example please? i'm getting frustrated :€

    Thanks.
     
  2. Sub7

    Sub7 Active Member Licensed User

    I have read this from @Erel
    I call this service before executing the contentchooser but my activity still get killed time by time

    Code:
    #Region  Service Attributes
        
    #StartAtBoot: False
    #End Region

    Sub Process_Globals
    Dim nb As Notification
    End Sub

    Sub Service_Create
        nb.Initialize
        nb.Icon=
    ""
        nb.OnGoingEvent = 
    False
        nb.Vibrate=
    False
        nb.Sound = 
    False
        nb.Notify(
    0)
        
    Service.StartForeground(0, nb)
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    End Sub


    Sub Service_Destroy
    'Service.StopForeground(0)
    End Sub
    Contentchooser

    Code:
    Sub btnUpload_Click

    Dim q As Int
    q= 
    Msgbox2("Upload picture?","Choose","","Cancel"Null)
    If q = DialogResponse.POSITIVE Then

        
    StartService(busyService)
        ImageChooser.show(
    "image/*""Choose image")

        
    Else If q = DialogResponse.NEGATIVE Then
           
    ToastMessageShow("Operation cancelled"True)

        
    Else If q = DialogResponse.CANCEL Then
            
    ToastMessageShow("Operation cancelled"True)
        
    End If
    End sub
    I load the bitmaps using loadbitmapsample.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Do you see the service notification icon when you select the image?
     
    Sub7 likes this.
  4. Sub7

    Sub7 Active Member Licensed User

    Hello, i changed service_Create in

    Code:
    Sub Service_Create
        nb.Initialize
        nb.Icon=
    ""
        nb.OnGoingEvent = 
    True
        nb.Vibrate=
    False
        nb.Sound = 
    False
        nb.Notify(
    1)
        
    Service.StartForeground(1, nb)
    End Sub
    I see the icon popping out, it seem to work now, no activity_Create in 40 tries.

    Thanks =)
     
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