Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:40:29+00:00 2026-06-15T16:40:29+00:00

My app has a 3-tabbed ActionBar layout. The 3 tabs are Dashboard , Feed

  • 0

My app has a 3-tabbed ActionBar layout. The 3 tabs are Dashboard, Feed and Messages.

When you click any of the three, the application is supposed to create a WebView of http://www.flyalaskava.org/incog/mobile/ which – if you do not have an active session for – will display an image and a “log-in with facebook” button.

The problem is, when I load the first tab (Dashboard) and cliek Log-In with Facebook, it logs me in – but as soon as I click onto another tab, I lose my session and am re-prompted.

Please keep in mind that currently all of these are using the same php file and that the log-in system works perfectly outside of Android. Sorry if this is a newbie question – any help is appreciated.

package com.example.testing;

import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;

import com.handmark.pulltorefresh.library.PullToRefreshWebView;

public class Main extends FragmentActivity implements ActionBar.TabListener {

    PullToRefreshWebView mPullRefreshWebView;
    WebView mWebView;

    /**
     * The serialization (saved instance state) Bundle key representing the
     * current tab position.
     */
    private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mPullRefreshWebView = (PullToRefreshWebView) findViewById(R.id.pull_refresh_webview);
        mWebView = mPullRefreshWebView.getRefreshableView();

        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new SampleWebViewClient());
        mWebView.loadUrl("http://www.google.com");

        // Set up the action bar to show tabs.
        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // For each of the sections in the app, add a tab to the action bar.
        actionBar.addTab(actionBar.newTab().setText(R.string.title_section1)
            .setTabListener(this));
        actionBar.addTab(actionBar.newTab().setText(R.string.title_section2)
            .setTabListener(this));
        actionBar.addTab(actionBar.newTab().setText(R.string.title_section3)
            .setTabListener(this));
    }

    private static class SampleWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        // Restore the previously serialized current tab position.
        if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
            getActionBar().setSelectedNavigationItem(
                savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM)
            );
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        // Serialize the current tab position.
        outState.putInt(STATE_SELECTED_NAVIGATION_ITEM, getActionBar()
            .getSelectedNavigationIndex());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_settings:
                displayAlert();
                break;
            case R.id.menu_exit:
                displayExit();
                break;
            default:; 
        }
        return(super.onOptionsItemSelected(item));
    }

    public  void displayAlert() {
        new AlertDialog.Builder(this)
            .setMessage("This Application was created by Grant Adkins")
            .setTitle("About")  
            .setCancelable(false)  
            .setNeutralButton(android.R.string.ok,  
                new DialogInterface.OnClickListener() {  
                    public void onClick(DialogInterface dialog, int whichButton){
                        dialog.cancel();
                    }  
                }
            )  
            .show(); 
    }

    public  void displayExit() {
        new AlertDialog.Builder(this).setMessage("Exit the application")  
            .setTitle("Are you sure?")  
            .setCancelable(false)  
            .setNeutralButton(android.R.string.no,  
                new DialogInterface.OnClickListener() {  
                    public void onClick(DialogInterface dialog, int whichButton){
                        dialog.cancel();
                    }  
                }).setPositiveButton(android.R.string.yes,  
                    new DialogInterface.OnClickListener() {  
                        public void onClick(DialogInterface dialog, int whichButton){
                            finish();
                        }  
                    }
                ) 
            .show(); 
    }
    public boolean isOnline() {
        ConnectivityManager cm = 
            (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnectedOrConnecting()) {
            return true;
        }
        String summary = "<html><body>No Network Connection.</body></html>";
        mWebView.loadData(summary, "text/html", null);
        return false;
    }

    @Override
    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
        // When the given tab is selected, show the tab contents in the
        // container view
        int page = tab.getPosition() + 1;
        if(page == 1) {
            /// eventually is going to load index.php?content=dashboard
            mWebView.loadUrl("http://www.flyalaskava.org/incog/mobile/");
            isOnline();
        } else if (page == 2) {
            /// eventually is going to load index.php?content=messages
            mWebView.loadUrl("http://www.flyalaskava.org/incog/mobile/");
            isOnline();
        } else if (page == 3) {
            /// eventually is going to load index.php?content=feed
            mWebView.loadUrl("http://www.flyalaskava.org/incog/mobile/");
            isOnline();
        } else {
            mWebView.loadUrl("http://www.google.com");
            isOnline();
        }
    }

    @Override
    public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    }

    @Override
    public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    }

    /**
     * A dummy fragment representing a section of the app, but that simply
     * displays dummy text.
     */
    public static class DummySectionFragment extends Fragment {
        /**
         * The fragment argument representing the section number for this
         * fragment.
         */
        public static final String ARG_SECTION_NUMBER = "section_number";

        public DummySectionFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            // Create a new TextView and set its text to the fragment's section
            // number argument value.
            TextView textView = new TextView(getActivity());
            textView.setGravity(Gravity.CENTER);
            textView.setText(
                Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER))
            );

            return textView;
        }
    }
}`

*\\\\\\\\UPDATE\\\\\\*

I found this article which seems to be a similar problem, maybe because im using mWebView.loadUrl("http://www.flyalaskava.org/incog/mobile/"); it is acting like a new browser, is there any way to change urls without using that method.

Here is a picture of the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:40:29+00:00Added an answer on June 15, 2026 at 4:40 pm

    Add the following lines after having created your WebView :

    CookieSyncManager.createInstance(mWebView.getContext()).sync();
    CookieManager.getInstance().acceptCookie();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an App that has a 2-tabbed activity, where tab1 has
My app has four tabs: A , B , C and D . Their
I'm creating android app that has table layout for the main activity, and that
Using core data on a on an application that has tabbed views. The second
The app has an Action Bar, the action bar has several navigation tabs on
In a new tabbed app application when two more views are added, views which
My app has 3 categories of buttons, I want to have a tabbed panel
My app has an options menu that is available in almost all Activities, which
My app has the ability to store passwords. But these are important passwords, so
My app has started throwing errors when I try to save a particular class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.