質問

There is a button that redirect the user to the url of Youtube, and I want to know that the user is really browse to the link or just see the chooser in my Android APP?

I tried startactivityforresult() but it doesn't work. Is there any method to do that? thanks!

役に立ちましたか?

解決

If the browser gets opened, The first method that will be called from activity is onPause() followed by onStop() i.e. the activity will be paused and then stopped. Check if method onStop() get called or not alternatively save a Boolean and change its state in onSop() method and check its state in onRestart() method this way you will get to know whether browser is opened or not.

like this

@Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        System.out.println("STOP");
    }


    @Override
    protected void onRestart() {
        // TODO Auto-generated method stub
        super.onRestart();
        System.out.println("onRestart");

             // check the value of boolean here


    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top