使用下面的代码,我已经能够保存cookie,但是一旦我关闭应用程序,cookie就会消失.
这是怎么造成的,我该如何解决?
package com.jkjljkj
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CookieSyncManager.createInstance(getBaseContext());
// Let's display the progress in the activity title bar, like the
// browser app does.
getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int …Run Code Online (Sandbox Code Playgroud) 我试图找出一个单行代码使用map.
这是一个简单的设置.
function Cat(name) {
this.name = name;
// FYI: using __proto__ is discouraged. thanks @KarelG
this.__proto__.mew = function () {
console.log(this.name + " mews");
};
}
var cats = [
new Cat('MB'),
new Cat('503')
];
Run Code Online (Sandbox Code Playgroud)
然后,我可以map()用来调用mew猫的方法.
cats.map(function (cat) {
cat.mew();
});
// MB mews
// 503 mews
Run Code Online (Sandbox Code Playgroud)
call() 在原型上也有效.
cats.map(function (cat) {
Cat.prototype.mew.call(cat);
});
// MB mews
// 503 mews
Run Code Online (Sandbox Code Playgroud)
这是我的最后一行,但它发出错误,我无法理解为什么:
cats.map(Cat.prototype.mew.call);
// Uncaught TypeError: undefined is not a function
// at Array.map …Run Code Online (Sandbox Code Playgroud) <p id="demo"></p>
<script>
//This is the email list
var emailList =["adam@yahoo.edu\n", "henry@yahoo.edu\n", "john@yahoo.edu\n", "sally@yahoo.edu\n", "adam@yahoo.edu\n", "david@yahoo.edu\n", "myhome@yahoo.edu\n", "david@yahoo.edu\n", "david@yahoo.edu\n", "hunger@yahoo.edu\n", "madison@yahoo.edu\n", ];
//I am removing @yahoo.edu
function removeAddress(list){
for (var i = 0; i < list.length; i++) {
list[i] = list[i].replace("@yahoo.edu", " ");
}
}
//Function to remove the duplicates in the list
function removeDuplicates(list)
{
var hash = {};
for (var i = 0; i < list.length; i++)
{
var array = list[i];
for (var j = 0; j …Run Code Online (Sandbox Code Playgroud)