Example usage for android.webkit CookieSyncManager createInstance

List of usage examples for android.webkit CookieSyncManager createInstance

Introduction

In this page you can find the example usage for android.webkit CookieSyncManager createInstance.

Prototype

public static CookieSyncManager createInstance(Context context) 

Source Link

Document

Create a singleton CookieSyncManager within a context

Usage

From source file:com.google.zxing.client.android.book.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    fakeR = new FakeR(this);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();//from ww w  . j  a v a2  s .  co m
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(fakeR.getId("string", "sbc_name")));
    } else {
        setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn);
    }

    setContentView(fakeR.getId("layout", "search_book_contents"));
    queryTextView = (EditText) findViewById(fakeR.getId("id", "query_text_view"));

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(fakeR.getId("id", "query_button"));
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view"));
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"),
            resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:net.evecom.android.web.WebdbActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    temp = HttpUtil.getPageSize(this);
    setContentView(R.layout.message_post_web);
    imageView = (ImageView) findViewById(R.id.image_view_at_web);
    webView = (WebView) this.findViewById(R.id.wv_oauth_message);
    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    CookieManager.getInstance().removeSessionCookie();
    /**//  ww w.  j a  va  2  s .c  o  m
     * WebViewJavaScript
     */
    webView.getSettings().setJavaScriptEnabled(true);
    /**
     * loadUrl()
     */
    HelloWebViewClient client = new HelloWebViewClient();
    webView.setWebViewClient(client);
    dialog = ProgressDialog.show(WebdbActivity.this, null, "..");
    dialog.setCancelable(true);
    // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1
    // webView.loadUrl("http://www.baidu.com");
    // String url = HttpUtil.BASE_PC_URL
    // String url =HttpUtil.BASE_PC_URL+"loginController/messageLogin";
    String url = HttpUtil.BASE_PC_URL + "mobile/loginController/eventlistLogin";
    // post
    // http://wangzy:8081/gssms/mobile/loginController/eventlistLogin?loginname=sysadmin&pwd=888888
    // String postDate = "loginname=sysadmin&pwd=888888";
    String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "")
            + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize="
            + temp;
    // webView.postUrl(url, postData) postDatabyte[] 
    // EncodingUtils.getBytes(data, charset)
    webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64"));
    // 
    webView.setDownloadListener(new MyWebViewDownLoadListener());
    WebSettings webSettings = webView.getSettings();
    webSettings.setSupportZoom(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setBuiltInZoomControls(true);// support zoom
    // webSettings.setPluginsEnabled(true);//support flash
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    // webSettings.setPluginsEnabled(true); //(flash)

    /**  */
    // //
    webSettings.setDatabaseEnabled(true);
    String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    // 
    webSettings.setGeolocationEnabled(true);
    // 
    webSettings.setGeolocationDatabasePath(dir);
    // 
    webSettings.setDomStorageEnabled(true);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    // DebugLog.d(TAG, "densityDpi = " + mDensity);
    if (mDensity == 240) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == 160) {
        webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
    } else if (mDensity == 120) {
        webSettings.setDefaultZoom(ZoomDensity.CLOSE);
        // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){
        // webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == DisplayMetrics.DENSITY_HIGH) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    }
    webView.setWebChromeClient(m_chromeClient);// (flash)
    dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0")
            .setPositiveButton("", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:net.evecom.android.web.Web0Activity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    temp = HttpUtil.getPageSize(this);
    setContentView(R.layout.message_post_web);
    imageView = (ImageView) findViewById(R.id.image_view_at_web);
    webView = (WebView) this.findViewById(R.id.wv_oauth_message);
    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    CookieManager.getInstance().removeSessionCookie();
    /**// w w w.j  av a 2s  .  c  o m
     * WebViewJavaScript
     */
    webView.getSettings().setJavaScriptEnabled(true);
    /**
     * loadUrl()
     */
    webView.setWebViewClient(new HelloWebViewClient());
    dialog = ProgressDialog.show(Web0Activity.this, null, "..");
    dialog.setCancelable(true);
    // http://harlan-pc/fzaj/emergency/mobileWebApp/publicInfo/login.do?userName=zf1&userPwd=1
    // webView.loadUrl("http://www.baidu.com");
    // String url = HttpUtil.BASE_PC_URL
    // String url =HttpUtil.BASE_PC_URL+"loginController/messageLogin";
    String url = HttpUtil.BASE_PC_URL + "mobile/loginController/messageLogin";
    // post
    String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "")
            + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize="
            + temp;
    // webView.postUrl(url, postData) postDatabyte[] 
    // EncodingUtils.getBytes(data, charset)
    webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64"));
    // 
    webView.setDownloadListener(new MyWebViewDownLoadListener());
    WebSettings webSettings = webView.getSettings();
    webSettings.setSupportZoom(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setBuiltInZoomControls(true);// support zoom
    // webSettings.setPluginsEnabled(true);//support flash
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    /**  */
    // //
    webSettings.setDatabaseEnabled(true);
    String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    // 
    webSettings.setGeolocationEnabled(true);
    // 
    webSettings.setGeolocationDatabasePath(dir);
    // 
    webSettings.setDomStorageEnabled(true);

    // webSettings.setPluginsEnabled(true); //(flash)
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    // DebugLog.d(TAG, "densityDpi = " + mDensity);
    if (mDensity == 240) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == 160) {
        webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
    } else if (mDensity == 120) {
        webSettings.setDefaultZoom(ZoomDensity.CLOSE);
        // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){
        // webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == DisplayMetrics.DENSITY_HIGH) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    }
    webView.setWebChromeClient(m_chromeClient);// (flash)
    dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0")
            .setPositiveButton("", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.webview);//from  w w w.ja v a  2  s.c o  m
    CookieSyncManager.createInstance(this);
}

From source file:com.javielinux.facebook.FacebookHandler.java

public void showWebView() {
    if (isWebViewShown) {
        return;// ww  w  .  ja  va  2 s  . c  o m
    }

    CookieSyncManager.createInstance(activity);

    mWebView = new WebView(activity);

    layout.addView(mWebView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    CookieManager.getInstance().removeAllCookie();
    CookieManager.getInstance().removeExpiredCookie();
    CookieManager.getInstance().removeSessionCookie();

    CookieSyncManager.getInstance().sync();

    isWebViewShown = true;
}

From source file:com.cerema.cloud2.ui.dialog.SamlWebViewDialog.java

@SuppressLint("SetJavaScriptEnabled")
@Override//w  w w .jav a 2  s . c o m
public void onCreate(Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreate, savedInstanceState is " + savedInstanceState);
    super.onCreate(savedInstanceState);

    setRetainInstance(true);

    CookieSyncManager.createInstance(getActivity().getApplicationContext());

    if (savedInstanceState == null) {
        mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
        mTargetUrl = getArguments().getString(ARG_TARGET_URL);
    } else {
        mInitialUrl = savedInstanceState.getString(ARG_INITIAL_URL);
        mTargetUrl = savedInstanceState.getString(ARG_TARGET_URL);
    }

    setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Theme_ownCloud_Dialog);
}

From source file:com.synox.android.ui.dialog.SamlWebViewDialog.java

@SuppressLint("SetJavaScriptEnabled")
@Override//  w  w w  .  j  a va 2  s  .c  o  m
public void onCreate(Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreate, savedInstanceState is " + savedInstanceState);
    super.onCreate(savedInstanceState);

    setRetainInstance(true);

    CookieSyncManager.createInstance(getActivity().getApplicationContext());

    if (savedInstanceState == null) {
        mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
        mTargetUrl = getArguments().getString(ARG_TARGET_URL);
    } else {
        mInitialUrl = savedInstanceState.getString(ARG_INITIAL_URL);
        mTargetUrl = savedInstanceState.getString(ARG_TARGET_URL);
    }

    setStyle(DialogFragment.STYLE_NO_TITLE, R.style.synox_Dialog);
}

From source file:com.polyvi.xface.extension.advancedfiletransfer.FileDownloader.java

public FileDownloader(Context context, String url, String localFilePath, FileTransferRecorder recorder,
        FileTransferManager manager, CordovaWebView webView) {
    this.mUrl = url;
    this.mLocalFilePath = localFilePath;
    this.mFileTransferManager = manager;
    this.mFileTransferRecorder = recorder;
    this.mContext = context;
    this.mCookieSyncManager = CookieSyncManager.createInstance(this.mContext);
    mWebView = webView;//from   ww  w  .  j  a v a 2 s  .com
}

From source file:com.citrus.mobile.User.java

public final static boolean logoutUser(Activity activity) {

    CookieSyncManager.createInstance(activity);

    CookieManager.getInstance().setCookie(Config.getBaseURL(), Constants.CITRUS_PREPAID_COOKIE);//remove App Cookie

    new PersistentConfig(activity).clearToken(); //clear stored cookies

    OauthToken token = new OauthToken(activity, "");
    return token.clearToken(); //clear stored oauth token

}

From source file:com.digitalarx.android.ui.dialog.SamlWebViewDialog.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from  w  ww  .  ja  v  a 2 s .c o  m
public void onCreate(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreate, savedInstanceState is " + savedInstanceState);
    super.onCreate(savedInstanceState);

    setRetainInstance(true);

    CookieSyncManager.createInstance(getSherlockActivity().getApplicationContext());

    if (savedInstanceState == null) {
        mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
        mTargetUrl = getArguments().getString(ARG_TARGET_URL);
    } else {
        mInitialUrl = savedInstanceState.getString(ARG_INITIAL_URL);
        mTargetUrl = savedInstanceState.getString(ARG_TARGET_URL);
    }

    setStyle(SherlockDialogFragment.STYLE_NO_TITLE, R.style.Theme_ownCloud_Dialog);
}