1. Are you ready for the Galaxy S20? Here is everything we know so far!

onSensorChange to only run once

Discussion in 'Android Development' started by Nismon8er, Jun 19, 2017.

  1. Nismon8er

    Nismon8er Lurker
    Thread Starter

    Hello,

    I have been searching everywhere but no luck...

    I have something similar to a magic 8 ball app

    Right now when i face the phone downwards it loads a picture from a site, but it runs about 10 times until i face the phone back up.... i have a simple if statement where if the Z value is less that -9.5 then run the code else dont do anything.... but since onSensorChange runs constantly due to gravity it runs over and over.... is there a way to make it run only once, then stop running until user place phone upwards again
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

Loading...
Similar Threads - onSensorChange run once
  1. melani78
    Replies:
    1
    Views:
    191
  2. SrLimon
    Replies:
    1
    Views:
    310
  3. 11235ismofoog
    Replies:
    2
    Views:
    443
  4. Cokdok Studio
    Replies:
    0
    Views:
    506
  5. Irfan Latif
    Replies:
    1
    Views:
    680
  6. Macadoo
    Replies:
    4
    Views:
    866
  7. Gilmour
    Replies:
    1
    Views:
    1,475
  8. App Update
    Replies:
    0
    Views:
    671
  9. MedoliGames
    Replies:
    6
    Views:
    1,478
  10. tinker123
    Replies:
    0
    Views:
    1,080

Share This Page

Loading...