This question already exists:
How to save form's info last time in webview
Closed 5 years ago.
1.Webview has a goback method , it can save web state when click back.
2.My layout is a Linearlayout and it has a webview on top of two button.
Every button match a url. Also I add webView.goBack() in onKeyDown method
The first url has a form, the second doesn't have a form
I wrote some info at form in first url, after I click the second button
then ,I click the first button,but the url is reload.but if when I click back
the form info is save.
I want to save those form info like when I click back button,it can save last form info
I want to save form info in last time, how to do that?
my code is here
private void checkone(String url) {
if (!Netutils.isNetworkAvalible(MyApplication.mcontext)) {
fl.removeAllViews();
webView.loadUrl(url);
webView.setVisibility(View.GONE);
webView.removeAllViews();
fl.setVisibility(View.VISIBLE);
fl.addView(mErrorView);
} else {
handler.postDelayed(new Runnable() {
#Override
public void run() {
fl.setVisibility(View.GONE);
webView.setVisibility(View.VISIBLE);
fl.removeAllViews();
}
},1000);
Map extraHeaders = new HashMap();
extraHeaders.put("Referer", "www.emiaoqian.com");
webView.loadUrl(url, extraHeaders);
settings = webView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setSaveFormData(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setAppCachePath(MyApplication.mcontext.getCacheDir().getPath());
webView.setWebChromeClient(new ChomeClient(this) {
#Override
public void onProgressChanged(WebView view, int newProgress) {
currentProgress = pg1.getProgress();
if (newProgress >= 100 && !isAnimStart) {
isAnimStart = true;
pg1.setProgress(newProgress);
startDismissAnimation(pg1.getProgress());
} else {
startProgressAnimation(newProgress);
}
}
#Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
if (title.contains("404")) {
showErrorPage();
}
}
});
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);
settings.setDomStorageEnabled(true);
String ua = webView.getSettings().getUserAgentString();
webView.getSettings().setUserAgentString(ua.replace("Android", "emiaoqian"));
webView.setWebViewClient(new WebViewClient() {
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
pg1.setVisibility(View.VISIBLE);
pg1.setAlpha(1.0f);
}
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("weixin://wap/pay?")) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
//startActivityForResult(intent,233);
startActivity(intent);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
#Override
public void onPageFinished(WebView view, String url) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
CookieSyncManager.getInstance().sync();
} else {
CookieManager.getInstance().flush();
}
if (!(url.equals(Constants.LOGIN)) && !(url.equals(Constants.LOGINOUT))) {
if (homeTb != null && supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(false);
supportActionBar.setDisplayShowHomeEnabled(false);
homeTb.setTitle("");
}
radiogroup.setVisibility(View.VISIBLE);
nouserl.setVisibility(View.VISIBLE);
} else if (url.equals(Constants.LOGIN) || url.equals(Constants.LOGINOUT)) {
inittoolbar2();
radiogroup.setVisibility(View.GONE);
nouserl.setVisibility(View.GONE);
}
if (url.startsWith("https://wx.tenpay.com")) {
String newurl = url.substring(url.length() - 12, url.length());
LogUtil.e("--", newurl);
}
}
#Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
showErrorPage();
}
#Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
showErrorPage();
}
});
fixDirPath();
// webParentView = (LinearLayout) webView.getParent();
}
}
You can set :
mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); // WebSettings.LOAD_CACHE_ELSE_NETWORK
Also to Save in Specify the app cache path :
mWebView.getSettings().setAppCachePath(mContext.getCacheDir().getPath());
And tell me the result.
Related
When I tried to login it shows a popup window and asking for email and password
when I entered my correct email and password and click on login it doesn't redirect to my account it only shows the same page
this is my MainActivity
you can also download my application for better understanding my problems https://play.google.com/store/apps/details?id=in.bidforx.bidforx
use email: anup.gorai.9835#gmail.com
password:78907890
private ProgressBar progressBar;
private WebView webView;
#SuppressLint("SetJavaScriptEnabled")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppRate.with(this)
.setInstallDays(0)
.setLaunchTimes(3)
.setRemindInterval(0)
.monitor();
AppRate.showRateDialogIfMeetsConditions(this);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setMax(100);
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClientDemo());
webView.setWebChromeClient(new WebChromeClientDemo(
));
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.loadUrl("https://bidforx.com");
if (Build.VERSION.SDK_INT>=21){
CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true);
}else{ CookieManager.getInstance().setAcceptCookie(true);}
webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
try {
webView.stopLoading();
} catch (Exception e) {
}
if (webView.canGoBack()) {
webView.goBack();
}
webView.loadUrl("about:blank");
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Error");
alertDialog.setMessage("Check your internet connection and try again.");
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Try Again", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
startActivity(getIntent());
}
});
alertDialog.show();
super.onReceivedError(webView, errorCode, description, failingUrl);
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent myIntent=new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
String shareBody="Add World ";
String shareSub="Download the BidForx App and Buy everthing in 1% Download the App now https://play.google.com/store/apps/details?id=in.bidforx.bidforx";
myIntent.putExtra(Intent.EXTRA_TEXT,shareBody);
myIntent.putExtra(Intent.EXTRA_TEXT,shareSub);
startActivity(Intent.createChooser(myIntent,"Share using"));
}
});
}
private class WebViewClientDemo extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
progressBar.setProgress(100);
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(0);
}
}
private class WebChromeClientDemo extends WebChromeClient {
public void onProgressChanged(WebView view, int progress) {
progressBar.setProgress(progress);
}
}
// on back pressed
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack();
return true;
}
else {
finish();
}
return super.onKeyDown(keyCode, event);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
}
When I try to login, I am getting an error
"Uncaught TypeError: Cannot read property 'username' of null", source: https://bidforx.com/js/login.js (2)
There must be some problem in login.js line 2. In line 2 you try to call localStorage, and somehow you can login with browser but not with app.
I haven't tried it yet but you should allow WebView to use HTML5 local storage feature first and see if you can login with app.
webView.getSettings().setDomStorageEnabled(true);
and I think you should do the item checking like this:
if (localStorage.hasOwnProperty("username")) {
//
}
in order to prevent TypeError
I am using WebView for loading a website. But it is very slow and is leaking when specific websites are loaded.
I am loading WebView with the following code.
#Override
protected void onNewIntent(Intent intent) {
if (intent.getStringExtra("url") != null) {
webView.loadurl(intent.getStringExtra("url"));
}
}
But I am calling webView.loadUrl(Config.URL); (Config.URL may contain same url as specified above) in onCreate() method after initializing WebView with the following.
this.webView = (WebView) findViewById(R.id.wv);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.getSettings().setLoadsImagesAutomatically(true);
this.webView.getSettings().setDomStorageEnabled(true);
this.webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
MyClient client = new MyClient(WebActivity.this, (ProgressBar)findViewById(R.id.progressBar));
webView.setWebViewClient(client);
Loading a from onCreate() is working fine (not fine, it's too slow). But
the same URL that is loading from onNewIntent() is not working!!!.
After I did this inonNewIntent() no URLs got loaded using
webView.loadurl() and the current page is getting immovable. ie. the
scrollbars are moving in WebView but page is not scrolling. I tested
the same URL in onCreate() and it is working.
For doing that I am passing url with
intent.putExtra("url", Config.URL+targetUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
with the pending intent from the notifications. Although it is working in some devices i.e Google Nexus. But it is not working on most of the phones.
I have
android:hardwareAccelerated="true"
Myclient
public class MyClient extends WebViewClient{
private Context context;
private Activity activity;
private Handler handler;
private Runnable runnable;
private ProgressBar viewBar;
private String ret,ret2;
public void setFirstLoad(boolean firstLoad) {
this.firstLoad = firstLoad;
}
private boolean firstLoad=false;
public MyClient(Activity activity, ProgressBar bar) {
this.context = activity.getApplicationContext();
this.activity = activity;
viewBar=bar;
handler=new Handler();
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
/*if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
*//*view.setVisibility(View.GONE);
viewBar.setVisibility(View.VISIBLE);*//*
view.loadUrl(url);
}
return true;*/
if (Uri.parse(url).getHost().equals("www.somepage.com")) {
return false;
}
// Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Answers.getInstance().logShare(new ShareEvent()
.putContentId(Build.USER)
.putMethod(shareName(url))
.putContentName(contentDecode(url))
.putContentType("news_share"));
}catch (android.content.ActivityNotFoundException e){
Log.e("Activity not found",e.toString());
Toast.makeText(context,"Application not found",Toast.LENGTH_LONG).show();
}
return true;
}
#Override
public void onReceivedError(final WebView view, int errorCode, String description, final String failingUrl) {
//Clearing the WebView
try {
view.stopLoading();
} catch (Exception e) {
}
try {
view.clearView();
} catch (Exception e) {
}
if (view.canGoBack()) {
view.goBack();
}
view.loadUrl("about:blank");
//Showing and creating an alet dialog
AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
alertDialog.setTitle("Error");
alertDialog.setMessage("No internet connection was found!");
alertDialog.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
view.loadUrl(failingUrl);
}
});
AlertDialog alert = alertDialog.create();
alert.show();
//Don't forget to call supper!
super.onReceivedError(view, errorCode, description, failingUrl);
}
#Override
public void onLoadResource(final WebView view, String url) {
super.onLoadResource(view, url);
//injectScriptFile(view, "js/script.js");
injectCSS(view,"css/style.css");
if (firstLoad){
firstLoad=false;
view.setVisibility(View.INVISIBLE);
viewBar.setVisibility(View.VISIBLE);
runnable=new Runnable() {
#Override
public void run() {
viewBar.setVisibility(View.GONE);
view.setVisibility(View.VISIBLE);
}
};
handler.postDelayed(runnable,2000);
}
// test if the script was loaded
// view.loadUrl("javascript:setTimeout(hideMe(), 200)");
}
/*#Override
public void onPageFinished(final WebView view, String url) {
//System.gc();
}*/
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
System.gc();
}
The question is: What is the problem when using loadurl() method in onNewIntent()?
Try this from where you loads webview
web.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
});
You can use the webclient to handle the webview. Here I include the javascript with loading.
String aboutURL="YOUR URL";
final ProgressDialog pd = ProgressDialog.show(, "", "Please wait", true);
WebSettings settings=Webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setLoadsImagesAutomatically(true);
settings.setDatabaseEnabled(true);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
Webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
pd.show();
}
#Override
public void onPageFinished(WebView view, String url) {
pd.dismiss();
}
});
Webview.loadUrl(aboutURL);
Here Loading is processed based on network
Use Handler to post a delay action as below will fix this, but I don't known why.
new Handler().post(webView.loadurl(url));
enter image description hereI am using a webview on a activity on that webview there is one back button (not a backpress button on keyboard) which is tappable but it's not working.Any Idea how to handle this click of webview buttons.
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
ProgressDialog progressDialog =
ProgressDialog.show(activity, Constants.EMPTY_VALUE, Constants.PLEASE_WAIT, true);
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url, headers);
return true;
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (activity != null && progressDialog != null) {
progressDialog.setCancelable(false);
}
updatePaymentUrl = null;
if (url.contains("callback-data")) {
webView.setVisibility(View.GONE);
showpDialog();
int indexQ = url.indexOf("?");
partUrl = url.substring(indexQ + 1, url.length());
speedOrderUpdateApi();
}
if (updatePaymentUrl != null) {
super.onPageStarted(view, updatePaymentUrl, favicon);
} else {
super.onPageStarted(view, url, favicon);
}
}
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
Logger.logInfo("errorCode = ", String.valueOf(errorCode));
Logger.logInfo("description = ", description);
Logger.logInfo("failingUrl = ", failingUrl);
super.onReceivedError(view, errorCode, description, failingUrl);
}
#Override
public void onPageFinished(WebView view, String url) {
if (activity != null && progressDialog != null) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
// If title not found hide webview
Logger.logInfo("view.getTitle() = ", view.getTitle());
if (view.getTitle() != null && "Not Found".equals(view.getTitle())) {
view.setVisibility(View.INVISIBLE);
Toast.makeText(activity, "Link Not Found", Toast.LENGTH_LONG).show();
}
}
}
});
// Not needed
Random random = new Random(System.currentTimeMillis());
int randomNumber = random.nextInt();
Logger.logInfo("urlTemp = ", url);
webView.loadUrl(url, headers);
}
You can use WebView.addJavaScriptInterface() to communicate from your web page to native code,
For these you will have to create a WebInterface (name it anything you want) and add it as a JavascriptInterface to your WebView,
for e.g
public class YourWebInterface {
private Context context;
public YourWebInterface(Context context) {
this.context = context;
}
#JavascriptInterface
public void goBack() {
if(webView.canGoBack()){
webView.goBack();
} else {
finish();
}
}
}
Now add this interface to your webview as
webView.addJavascriptInterface(new YourWebInterface(context), "Android");
now in your webpage you can call this method using the Android object that we are passing with the Interface,
for exmaple on your button click in webpage you can do something like this :
Android.goBack()
WebView doesn't have OnBackPress by default and we use onKeyDown instead for going to previous page, here is example, you can put this code in your WebView activity
#Override
public boolean onKeyDown (int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack(); // go back in only the web view
return true;
}
return super.onKeyDown(keyCode, event);
}
Update:
put this code in onClick() for that button
if(webView.canGoBack()){
webView.goBack();
} else {
finish();
}
This is the code to my WebView. It works great on every device I have tested so far, even a Samsung S4. However, a certain Samsung S4, which the client insists it doesn't have a modified software, displays a white screen every time the app is resumed from background. Any ideas?
private void setupWebView() {
// hide the no connection imageview
// show the webview
noConnectionImageView.setVisibility(View.GONE);
webView.setVisibility(View.VISIBLE);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient() {
#Override
public void onReceivedSslError(WebView view,
SslErrorHandler handler, SslError error) {
handler.proceed();
}
#Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
showNoConnectionImage();
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// page has started loading
if (mustShowSplashScreen) {
showSplashScreen();
}
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// page has finished loading
if (mustShowSplashScreen) {
hideSplashScreen();
mustShowSplashScreen = false;
}
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// check for Internet connection
if (ConnectionDetector.isConnected(Main.this)) {
// check if link is external
if (isExternalUrl(url) {
// external link
new OpenLink(Main.this, url);
} else {
// internal link
view.loadUrl(url);
}
} else {
showNoConnectionImage();
Main.this.url = url;
}
return true;
}
});
}
I want to load one url "http://connect.mayoclinic.org/discussions" in webview .i tried lots of ways but i am unable to load it.its showing blank page. I am using the following for this.when i use simple load url by removing other functions,then also its giving the blank page.but when i tested on webbrowser its showing the webpage. its showing on iphone also..only unable to show in android webview
this.wb = (WebView) findViewById(R.id.wb);
WebSettings settings = wb.getSettings();
settings.setJavaScriptEnabled(true);
final AlertDialog alertDialog = new AlertDialog.Builder(BrowserViewHealthAlertActivity.this).create();
progressBar = ProgressDialog.show(BrowserViewHealthAlertActivity.this, "", "Loading...");
progressBar.setCancelable(true);
progressBar.setOnKeyListener(new DialogInterface.OnKeyListener() {
#Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
CommonFunction.startTimer(context);
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
return true; // Pretend we processed it
}
if (keyCode == KeyEvent.KEYCODE_MENU && (event.getFlags() & KeyEvent.FLAG_LONG_PRESS) == KeyEvent.FLAG_LONG_PRESS) {
return true;
}
return false; // Any other keys are still
}
});
wb.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
CommonFunction.startTimer(context);
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
alertDialog.setTitle("Error");
alertDialog.setMessage(description);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alertDialog.show();
}
});
wb.loadUrl(link);
I have tried your URL. Its not woring in browser.
might be problem with the URL itself #asiya.
Is it giving black page still??
Check my code with another URL like www.google.com. Its my working code.
A simple Webview goes here displaying loading until URL take to load.
Webview webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// Log.e("in", "onPageStarted" + isInternetPresent);
if (isInternetPresent) {
// Log.e("in", "if" + isInternetPresent);
progressBar.setVisibility(View.VISIBLE);
noconnection.setVisibility(View.INVISIBLE);
retry.setVisibility(View.INVISIBLE);
} else
noconnection.setVisibility(View.VISIBLE);
}
#Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
// Log.e("in", "onloadresoure");
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.INVISIBLE);
}
});
WebSettings webSettings = webview.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
webview.getSettings().setDisplayZoomControls(false);
webSettings.setJavaScriptEnabled(true);
// webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webview.setInitialScale(1);
if (isInternetPresent) {
isInternetPresent = true;
webview.loadUrl("http://your url");
} else {
ExitAlertClass.QuizSelectOptionAlert(ctx, "No Internet Connection"); //here goes your alert code
noconnection.setVisibility(View.VISIBLE);
retry.setVisibility(View.VISIBLE);
};
progressBar is a simple progress:
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar1);
Here, I am getting status of internet usng broadcast receiver. You can make that code.