Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.webkit.cts;
     18 
     19 import android.app.Activity;
     20 import android.cts.util.NullWebViewUtils;
     21 import android.os.Bundle;
     22 import android.webkit.CookieSyncManager;
     23 import android.webkit.WebView;
     24 
     25 public class CookieSyncManagerCtsActivity extends Activity {
     26     private WebView mWebView;
     27 
     28     @Override
     29     public void onCreate(Bundle savedInstanceState) {
     30         super.onCreate(savedInstanceState);
     31 
     32         try {
     33             CookieSyncManager.createInstance(this);
     34 
     35             mWebView = new WebView(this);
     36             setContentView(mWebView);
     37         } catch (Exception e) {
     38             NullWebViewUtils.determineIfWebViewAvailable(this, e);
     39         }
     40     }
     41 
     42     @Override
     43     protected void onResume() {
     44         super.onResume();
     45         try {
     46             CookieSyncManager.getInstance().startSync();
     47         } catch (Exception e) {
     48             // May throw on a device with no webview, OK to ignore at this point.
     49         }
     50     }
     51 
     52     @Override
     53     protected void onStop() {
     54         super.onStop();
     55         try {
     56             CookieSyncManager.getInstance().stopSync();
     57         } catch (Exception e) {
     58             // May throw on a device with no webview, OK to ignore at this point.
     59         }
     60     }
     61 
     62     public WebView getWebView(){
     63         return mWebView;
     64     }
     65 }
     66