小编Ami*_*yal的帖子

将Cookie设置为Android中的webView

HttpResponse在检查用户名或密码是否正确时从服务器获取.当我加载url一个webview我想要webView有cookie(我得到的答案postData()存储在webView.我希望webView获取cookie并加载存储在webview中的cookie的URL.

我正在收到回应.

public HttpResponse postData() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("https://example.com/login.aspx");

    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("txtUsername", "user"));
        nameValuePairs.add(new BasicNameValuePair("txtPassword", "123"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);
        String responseAsText = EntityUtils.toString(response.getEntity());
        Log.v(TAG , "Response from req: " + responseAsText);
        return responseAsText;

    } catch (ClientProtocolException e) {

    } catch (IOException e) {

    }
    return null;
}
Run Code Online (Sandbox Code Playgroud)

我用loadUrl:

webView.loadUrl("http://a_page.com/getpage.aspx?p=home");
Run Code Online (Sandbox Code Playgroud)

我想我不是真正管理一个cookie,我不知道该怎么做.任何建议或解决方案?

cookies post android http

19
推荐指数
5
解决办法
7万
查看次数

ASP.Net引发错误"System.InvalidOperationException:Collection被修改;" 换到越南语的时候

环境:操作系统Windows 2008 R2 Sp1,IIS 7.5,应用程序池CLR .Net 4 x64(集成模式).

我们的生产站点是ASP.net网站(不是Web应用程序),它支持UI文化的6种语言,如下所示:

en-US,ja-JP,th-TH,zh-CN,zh-TW,ko-KR和vi-VN.

该网站与越南语以外的所有语言完美配合.有时,当我们将语言更改为越南语时,某些页面会抛出异常,如下所示

 System.InvalidOperationException: Collection was modified; enumeration operation may not execute. 
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) 
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) 
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) 
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) 
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) …
Run Code Online (Sandbox Code Playgroud)

.net asp.net c#-4.0

6
推荐指数
0
解决办法
519
查看次数

如何获得带有日期和时间的去电号码?

我正在收到来电详细信息(Number,Name,Date)。但是如何获得去电细节。我已经编写了用于拨出电话详细信息的代码,但是会抛出异常NullPointerException。以下是我的MyCallReceiver.java文件和清单文件

  public void onReceive(Context context, Intent intent) {

    this.context = context;



    if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {

        String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);

        Toast.makeText(context, "Call From : " + incomingNumber, Toast.LENGTH_LONG).show();

        doToast(getContactName(context, incomingNumber) + " " + incomingNumber);
        String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
        doToast(currentDateTimeString +" "+incomingNumber);


    } else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_IDLE) || intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
        Toast.makeText(context, "DETECTED CALL HANG UP EVENT", Toast.LENGTH_LONG).show();

        String outgoingNumber=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        Toast.makeText(context,"Calling To :"+outgoingNumber,Toast.LENGTH_LONG).show();
    }
 }
Run Code Online (Sandbox Code Playgroud)

android android-studio android-broadcastreceiver

5
推荐指数
1
解决办法
4811
查看次数

如何在android中获取当前可见的片段?

我有MainActivity,在这个活动中我有四个fragments.片段名称是A,B,C,D.

Fragment currentVisibleFragment = getSupportFragmentManager().findFragmentByTag(null);
Run Code Online (Sandbox Code Playgroud)

使用上面的这一行,我试图让当前可见,fragment但我无法获得当前可见的片段.

android android-fragments android-activity

1
推荐指数
2
解决办法
1万
查看次数