How to use onActivityResult method from other than Activity class

前端 未结 7 1207
鱼传尺愫
鱼传尺愫 2020-12-05 23:53

I am creating an app where i need to find current location of user .

So here I would like to do a task like when user returns from that System intent, my task shou

7条回答
  •  臣服心动
    2020-12-06 00:41

    Create an inner class in the non Activity class and define your activity results handler therein:

    class singletonActivity extends Activity{
      protected void onActivityResult(...){
        // do whatever ..
      }
    }
    

    intantiate it to call startActivityForResult

    Activity actv = new singletonActivity(..)
    actv.startActivityForResult(intent ..)
    

    your handler will be called. :)

    ps: you may have to include some overrides. just leave them empty.

    pps: this is old school java mouseListenerAdapter style ~Oo>

提交回复
热议问题