0
votes

I have a situation : 1. Create activity A with webview and from onCreate open another activity B. 2. On backpress/skip of B load a url in A.

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

//this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_wap_launcher);

WebView webView = (WebView) findViewById(R.id.webView1);
final String url = "http://http:google.com";
webView.loadUrl(url);

Intent intent = new Intent(this, BManager.class);
this.startActivityForResult(intent,1);

}

Activity B opens on top of A but then suddenly it opens A with url.

Even i tried to use

@Override
   protected void onNewIntent(Intent intent) {
    final String url = "http://m.dittolite.com";
    webView.loadUrl(url);
   }

but it calls as soon as oncreate gets call.

Please suggest me a solution.

2

2 Answers

0
votes

i have a suggestion

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

//this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_wap_launcher);

Intent intent = new Intent(this, BManager.class);
this.startActivityForResult(intent,1);
}

@override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode  == 1)
{
WebView webView = (WebView) findViewById(R.id.webView1);
final String url = "http://www.google.com";
webView.loadUrl(url);
  }
        super.onActivityResult(requestCode, resultCode, data);

}
0
votes

AFAIK, it is not possible to achieve this scenario 100% using Activity, unless you handle both activity's functionality in one.

So suggest you to redesign using Fragments