Add custom android webview error page - android

In my app i want an error activity "NOT A ERROR HTML PAGE". Which contain refresh button and a layout. I have search for it but i found is just a custom html error page from assets folder.
I have created a some code which is below,
i want is that when ever network error occurs it will open an activity like this and user can easily refresh page using button.
I want to make error page like this one..
This is not a html error page. This contains layout with refresh button,
public WebView mWebview ;
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mWebview = new WebView(this);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
mWebview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Do Something Here, I don't know what to do.. :(
}
});
mWebview.loadUrl("google.com");
setContentView(mWebview);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.option, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.refresh:
startActivity(new Intent(this, CeS1.class));
finish();
return true;
case R.id.about:
startActivity(new Intent(this, Credits_activity.class));
finish();
return true;
case R.id.gotomain:
startActivity(new Intent(this, MenuActivity.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
}

call this in your code
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//place you error code here
}
});

You can create a layout with 2 layers. One is WebView, another is your error layout. When your WebView encounters network error, you can hide your WebView and show errorView with retry button.

first, you put your HTML error page on the asset folder, then
You need override onReceivedError according to the following code,
private class MyWebViewClient extends WebViewClient {
.
.
.
// api<23
#Override
public void onReceivedError(WebView view, int errorCode, String description, String url) {
view.stopLoading();
webview.loadUrl("file:///android_asset/error/error.html");
}
// api> 23
#Override
#TargetApi(android.os.Build.VERSION_CODES.M)
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
view.stopLoading();
webview.loadUrl("file:///android_asset/error/error.html");
// super.onReceivedError(view, request, error);
}
.
.
.
}

Related

How to make function back button in actionbar like back button in devices android

I have one activity in which there is a webview. when the webview goes to a few pages and I click the back button on the device runs fine, but if I click the back button in the actionbar then return it wrong.
can I make function back button in action bar like back button in the device?
this is my code :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tes_backbutton);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
view = (WebView)findViewById(R.id.wv_tes);
progressBar = (ProgressBar)findViewById(R.id.prgbarhome);
view.setWebViewClient(new WebViewClient());
view.loadUrl(URL);
view.setWebChromeClient(new WebChromeClient() {
#Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
//Required functionality here
return super.onJsAlert(view, url, message, result);
}
});
view.setWebViewClient(new WebViewClient() {
ProgressDialog progressDialog;
//Show loader on url load
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (progressDialog == null) {
// in standard case YourActivity.this
progressDialog = new ProgressDialog(tes_backbutton.this);
progressDialog.setMessage("Loading...");
progressDialog.show();
}
}
public void onPageFinished(WebView view, String url) {
try {
progressDialog.dismiss();
progressDialog = null;
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Intent myIntent = new Intent(tes_backbutton.this, main_noconnect.class);
tes_backbutton.this.startActivity(myIntent);
}
});
view.canGoBack();
view.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getAction() == MotionEvent.ACTION_UP
&& view.canGoBack()) {
view.goBack();
return true;
}
return false;
}
});
}
#Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
You need to override onOptionsItemSelected method if you want to take any action after back arrow is clicked from action bar like below
#Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed(); //finishes the activity
return true;
}
return super.onOptionsItemSelected(menuItem);
}
The 'back' button in the action bar should act differently than the device's back button. You don't want them both to do the same thing. The button in the action bar should serve as an 'up' button rather than a 'back' button. Please read more about Providing Up Navigation.
I hope this helps you.
you can use onBackPressed(); method
#Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
if(mWebView.canGoBack() == true){
mWebView.goBack();
}else{
onBackPressed(); //finishes the activity
}
return true;
}
return super.onOptionsItemSelected(menuItem);
}
you can use webview.cangoback() method for navigating between different web pages in webview
#Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
if(view.cangoback()){
view.goback();
}
else{
finish();
}
break;
}
return super.onOptionsItemSelected(menuItem);
}

I check all the forum but not find a solution | "Open external links of my webview in browser and not in app" does not work

thanks for read my question :) I am not able to solve this problem after check all the forum. I am working on my first webview. Nothing special. It's a webview with progress bar. My code in "shouldOverrideUrlLoading" method is not working. I want that all external links of my site open in browser and not in app, but it does not work. Can anyone please check my code?
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private WebView wv;
private ProgressBar progressBar;
private FrameLayout frameLayout;
SwipeRefreshLayout swipe;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setMax(100);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
String webUrl = wv.getUrl();
wv.loadUrl(webUrl);
}
});
LoadWeb();
}
public void LoadWeb(){
wv = (WebView)findViewById(R.id.webView);
WebSettings settings = wv.getSettings();
settings.setJavaScriptEnabled(true);
wv.loadUrl("example.com");
swipe.setRefreshing(true);
wv.setWebViewClient(new HelpClient());
wv.setWebViewClient(new MyAppWebViewClient());
wv.setWebChromeClient(new WebChromeClient(){
public void onProgressChanged(WebView view, int progress){
frameLayout.setVisibility(View.VISIBLE);
progressBar.setProgress(progress);
if (progress == 100){
frameLayout.setVisibility(View.GONE);
}
super.onProgressChanged(view, progress);
}
});
progressBar.setProgress(0);
wv.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url){
swipe.setRefreshing(false);
}
});
}
private class HelpClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
frameLayout.setVisibility(View.VISIBLE);
return true;
}
}
private class MyAppWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(Uri.parse(url).getHost().endsWith("example.com")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
}
#Override
public void onBackPressed() {
if(wv.canGoBack()) {
wv.goBack();
} else {
super.onBackPressed();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
return super.onOptionsItemSelected(item);
}
#SuppressWarnings("StatementWithEmptyBody")
#Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_home) {
wv.loadUrl("example.com");
} else if (id == R.id.nav_facebook) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/idfbpage"));
startActivity(intent);
} catch (Exception e) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/idfbpage"));
startActivity(intent);
}
} else if (id == R.id.nav_instagram) {
Uri uri = Uri.parse("http://instagram.com/_u/idinstapage");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/idinstapage")));
}
} else if (id == R.id.nav_star) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=idpackage"));
startActivity(intent);
} else if (id == R.id.nav_informazioni) {
wv.loadUrl("example.com/info-app");
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
In your method LoadWeb() there is an error because your WebView should have only one WebViewClient and only one WebChromeClient. So what happens is, if you use the method wv.setWebViewClient(new YourWebViewClient()); more than once what happens is that all other methods set before that are ignored because you can set it only once.For your case:
You set the WebViewClient Three (3) times:
wv.setWebViewClient(new HelpClient()); //First time
wv.setWebViewClient(new MyAppWebViewClient()); //Second time
And the last time you set it down in your same method you set another like:
wv.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url){
swipe.setRefreshing(false);
}
});
So what happens is that the two previous methods were ignored and the only method that was working was the last one (the third) only. That's why I asked you to put the second method down to setWebClient((new MyAppWebViewClient()); so as to ignore the previous!
THE SOLUTION
Now you know we have to set only one WebViewClient for your webView we have to make only ONE Class that will be used to and do the job of all three other WebViewClient by overriding all the required methods. Make this class inside your activity but oustide your any method (just like how you have done when making in HelpClient() Class). Here is Our Class Please make sure you read the Comments in it!
private class NewWebViewClient extends WebViewClient {
//Now we have only one class to do a job of all the other three!
#Override
public void onPageFinished(WebView view, String url) {
/*I here do whatever you want to do when the page has finished loading! Do it here inside this method and it will work may be control the framelayout visibility For example lets setRefreshing false to our swipe()*/
swipe.setRefreshing(false);
//.....add more methods you want here when the page loading is finished
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
/*In this method we are going to tell the android system what kind of link we want and what kind of link we dont want for that what we want we will handle for the extra the browser should do so!*/
if (Uri.parse(url).getHost().endsWith("example.com")) {
//if the code gets here this is your link then right? Lets do whatever we want with our link and logic for example lets set framelayout visible or doing anything this link's host is example.com!
frameLayout.setVisibility(View.VISIBLE);
return false;
} else {
//Ooops This link is not yours lets just open browsers right
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
}
}
After your class is beautiful then lets just set our WebViewClient only ONCE.
wv.setWebViewClient(new NewWebViewClient());
You can just ignore the WebChromeClient because you set it only once you are good. Comment below if you find any difficulties!
I hope removing the this line
wv.setWebViewClient(new MyAppWebViewClient());
will solve the problem for you.
You are using two instances of WebViewClient ,remove one ,
private class MyAppWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d("TAG",url);
if(Uri.parse(url).getHost().equals("example.com")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);//add the brakpoint here
Log.d("TAG","Starting activity");
return true;
}
}
just use this

WebView detect button click event

I am loading a web URL in webview. Like below :-
mWebView = (WebView)findViewById(R.id.id__web_view);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl("http://www.google.com");
How can I detect a button click event inside the loaded page. Say for example I want to show a toast "Clicked" when user clicks on "Images" tab after the search is done.(Please note that the detection of button click is one page ahead of the page that I loaded).
What I have tried:-
I did some research on how to do this, but none of these were fruitfull.
Below is one among them :-
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
wv.addJavascriptInterface(new Object()
{
public void performClick()
{
// Deal with a click on the OK button
}
}, "ok");
<button type="button" onclick="ok.performClick();">OK</button>
But this requires adding onclick in the html, I am not sure is it possible to do it on a 3rd party website. Please throw some light into the problem if any one has any clue.
Checkout below code.. its working fine for me
#SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
private WebView mWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView)findViewById(R.id.webView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setLoadsImagesAutomatically(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mWebView.setWebViewClient(new MyBrowser());
mWebView.loadUrl("file:///android_asset/index.html");
}
private class myWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
view.addJavascriptInterface(new Object()
{
#JavascriptInterface
public void performClick() throws Exception
{
Log.d("LOGIN::", "Clicked");
Toast.makeText(MainActivity.this, "Login clicked", Toast.LENGTH_LONG).show();
}
}, "login");
return true;
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Progress bar doesn't show up while webview is loading

I have written sample webview code by looking at examples found from internet. I want to show progressbar till webview loads a page in my fragment.
My activity contains toolbar, frame that shows fragments and navigation drawer. When i select an entry from navigation drawer, new fragment is shown which contains progress bar and webview and the fragment simply tries to load the page below is the code for fragment
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_full_page, container, false);
//int view_num = getArguments().getInt(ARG_SECTION_NUMBER);
progressBar = (ProgressBar)rootView.findViewById(R.id.webviewProgress);
progressBar.setVisibility(View.VISIBLE);
webView = (WebView) rootView.findViewById(R.id.webView1);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setAppCacheEnabled( true );
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(true);
//webView.getSettings().setSupportZoom(true);
webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT );
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
String urlString = getArguments().getString("URLSTRING");
final Boolean clickable = getArguments().getBoolean("CLICKABLE");
Boolean networkAvailable = Utils.isNetworkAvailable(super.getActivity().getApplicationContext());
if(networkAvailable == true) {
webView.loadUrl(urlString);
} else {
webView.loadUrl(Utils.DEFAULT_URL_PAGE);
}
webView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//progressBar.setVisibility(View.VISIBLE);
if (clickable) {
view.loadUrl(url);
return false;
} else {
return true;
}
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
});
webView.setOnKeyListener(new View.OnKeyListener() {
#Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView = (WebView) v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (webView.canGoBack()) {
webView.goBack();
return true;
}
break;
}
}
return false;
}
});
return rootView;
}
Below is fragment_full_page.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentFullPage" >
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center|top"
android:id="#+id/webviewProgress"
/>
<WebView
android:id="#+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
web page is taking time to load (tried with wifi and 3g) but progress bar is not showing any time.
To test if progressbar actually shows in the middle of the fragment_full_page, I removed webview code and just kept progress bar then it is showing.
made something wrong with the code that is not showing progress bar while webview is loading which i am unable to figure out.

Set sharing intent using icon in action bar

I want to share the website that the user is viewing in the webview in my app, however any of the tutorials I have followed, it just isn't working. I can get the icon to load in the action bar but it doesn't click. I have had onclick listeners implemented and nothing so far. The app is only meant for ICS or higher so it doesn't need to be backwards compatible with older androids. The code I am putting up is before any share icon is implemented as I want to do it from scratch or to see if anyone has any ideas to what I can do
public class WebActivity extends Activity {
private WebView mWebView = null;
private EditText mInputUrl = null;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
super.onCreate(savedInstanceState);
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
setContentView(R.layout.activity_web_view);
Intent intent = getIntent();
String thesite = intent.getStringExtra(MainPage.EXTRA_MESSAGE);
mInputUrl = (EditText)findViewById(R.id.input_url);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String baseurl = "http://";
String url = baseurl + mInputUrl.getText().toString();
mWebView.loadUrl(url);
}
});
mWebView = (WebView) findViewById(R.id.webview);
mWebView.loadUrl(thesite);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setGeolocationEnabled(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
final Activity MyActivity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, android.webkit.GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
}
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
WebView myWebView = (WebView) findViewById(R.id.webview);
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
Edit
I have used this code to try and get it working, however when I go to click the icon it doesn't do anything at all.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_menu, menu);
return true;
}
#Override
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_share:
shareURL();
}
return super.onOptionsItemSelected(item);
}
private void shareURL() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, mWebView.getUrl());
startActivity(Intent.createChooser(shareIntent, "Share This!"));
}
I have found the answer. It was rather simple in the end.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_menu, menu);
return true;
}
#Override
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_share:
shareURL();
}
if(item.getItemId() == R.id.menu_item_refresh){
mWebView.reload();
return true;
}
return super.onOptionsItemSelected(item);
}
private void shareURL() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, mWebView.getUrl());
startActivity(Intent.createChooser(shareIntent, "Share This Website!"));
}
}
This also allowed me to have a refresh button too.
I don't see any override for onCreateOptionsMenu(..), are you sure you have added your ActionItems? Take a look at http://developer.android.com/guide/topics/ui/actionbar.html.
Ali.

Categories

Resources