Issue
In my first view, where i have 4 icons like facebook, twitter etc. When i press on one of them, it takes me to the related site. But when i press back button, it first shows me one blank activity and then again i have to press back button to reach my first activity.
Any Help? Thanks in Advance
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.button1:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 1);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button2:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 2);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button3:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 3);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
case R.id.button4:
web_bundle=new Bundle();
web_bundle.putInt("icon_position", 4);
web_intent=new Intent(Recipe.this,WebViewActivity.class);
web_intent.putExtras(web_bundle);
startActivity(web_intent);
break;
}
}
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webview=(WebView)findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
Intent get_icon=getIntent();
Bundle get_bundle=get_icon.getExtras();
int icon_id=get_bundle.getInt("icon_position");
if(icon_id==1){
webview.loadUrl("http://www.facebook.com");
}
if(icon_id==2){
webview.loadUrl("http://www.twitter.com");
}
if(icon_id==3){
webview.loadUrl("http://www.plus.google.com");
}
if(icon_id==4){
webview.loadUrl("http://www.blogger.com");
}
}
Solution
As i face this same problem as per my knowledge When you first time press back button it first stops loading that URL or we can say that facebook site. Then again press back button it gets you back to your application.
Answered By - Hardik Joshi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.