Question

Answered and trusted look comments ! Thank sania

  public class Test extends Activity {

HTML5WebView mWebView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWebView = new HTML5WebView(this);
    Intent i = getIntent();
    String url = i.getStringExtra("url");  // retrieve the value you passed

    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {    
        mWebView.loadUrl(url);  // use that value
    }

setContentView(mWebView.getLayout());
}

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mWebView.saveState(outState);
    }

    @Override
    public void onStop() {
        super.onStop();
        mWebView.stopLoading();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
       onBackPressed();

   }

   return super.onKeyDown(keyCode, event);
   }

    public void onBackPressed() {
   Intent myIntent = new Intent(Test.this, fragment_main.class);
   myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);// clear back stack
   startActivity(myIntent);
   finish();
   return;


    }  
}

how can I stop last activity when clicked back button ? I was made a vimeo app working with listview how can I stop and close (vimeo videoplayer.class) that activity.when I click back button its going first activity or showing message Application was stopped :/

Was it helpful?

Solution

Add ondestroy () or video.stop() methods in backkey method

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top