草庐IT

post-content

全部标签

使用 HttpUrlConnection 获取 "already connected"的 Android POST 请求

我正在尝试使用HttpUrlConnection进行POST调用,但没有成功。我经常收到“IllegalStateException:已连接”错误消息。我对重用连接不感兴趣。请检查我的代码并告诉我是否做错了什么:publicstaticfinalintCONNECTION_TIME_OUT=10000;publicSimpleResponsecallPost(StringurlTo,Mapparams){System.setProperty("http.keepAlive","false");HttpURLConnectionconn=null;SimpleResponserespon

android - 为什么 notifyItemChanged 只能在 setAdapter 之后的 Post Runnable 中起作用?

publicclassMainActivityextendsAppCompatActivity{@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);RecyclerViewlist=(RecyclerView)findViewById(R.id.list);list.setLayoutManager(newLinearLayoutManager(this));finalRecyclerView.A

android - Intent.ACTION_GET_CONTENT 与谷歌驱动器

我有以下Intent:Intentintent=newIntent(Intent.ACTION_GET_CONTENT);intent.setType("text/*");startActivityForResult(intent,DBOpenHelper.REQUEST_CODE_RESTORE);Intent允许用户从多个选项中选择一个文本文件。例如,它适用于本地存储和Dropbox,在这两种情况下,我都可以从以下位置获取文件:@OverridepublicvoidonActivityResult(intrequestCode,intresultCode,Intentdata){s

android.content.ActivityNotFoundException : No Activity found to handle Intent { act=android. settings.USAGE_ACCESS_SETTINGS }

此问题仅发生在Android5.0Lollipop上。我无法使用带有Lollipop的手机,我已经在GenymotionAndroidEmulator中开发了代码,但此问题不会在模拟器中发生。我只从用户的手机中获取失败的堆栈跟踪信息。我的代码:if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){Intentintent=newIntent(Settings.ACTION_USAGE_ACCESS_SETTINGS);startActivity(intent);}应用程序崩溃以及我从用户那里获得的堆栈跟踪信息:android.c

android - HTTP POST 响应到 android 中的 WebView

我正在尝试使用HTTP连接到该页面邮政。我做了一个用于创建的http帖子一个WebView。我需要从webview重定向到另一个页面。但是当单击继续按钮时会抛出异常。我的代码是publicclassZHttpPostProjActivityextendsActivity{/**Calledwhentheactivityisfirstcreated.*/privateWebViewmWebView;privateProgressDialogprogressBar;privatestaticfinalStringTAG="ZHttpPostProjActivity";@Overridepu

android - 执行 http POST 返回 HTML 而不是 JSON

编辑完全重新处理问题以便更好地理解我必须使用2个POST参数查询给定的urlhttp://api.bf3stats.com/pc/player/:'player'(用于播放器名称)和'opt'(用于选项)。我已经在http://www.requestmaker.com/上测试过了具有以下数据:player=Zer0conf&opt=all。我得到了正确的JSON响应(以为我不知道他们的网站如何执行查询,我猜它是php)。现在我正尝试在Android中做同样的事情:privateStringBuilderinputStreamToString(InputStreamis){//thism

android - 显示图片时,Google Ads MediaView 无法正确地将高度调整为 wrap_content

我今天收到一封来自AdMob的电子邮件说:Changetonativeadspolicy:NativeadswillrequireMediaViewtorenderthevideoormainimageasset.Inanefforttohelpyoudeliverabetteradexperiencemoreeasily,beginningOctober29th,nativeadswillrequireMediaViewtorenderthevideoormainimageasset.Adunitsnotcompliantbythisdatewillstopservingads,wh

php - 使用 POST 方法和 HttpURLConnection 将 JSON 对象从 Android 发送到 PHP 服务器

我正在尝试在我的Android应用程序和本地网络上的WampServer之间建立通信。当我想从服务器读取数据时,我已经成功了,但是当我尝试向服务器发送数据时却遇到了问题。我正在使用服务来建立通信:publicclassSynchronisationServiceextendsService{@OverridepublicIBinderonBind(Intentintent){returnnull;}@OverridepublicintonStartCommand(Intentintent,intflags,intstartId){super.onStartCommand(intent,

javascript - "multipart != application/json"在 android 上获取 post 错误(react-native)

我有一个使用react-native构建的应用程序,它在iOS中运行完美。我正在使它也可用于Android,但在尝试将联系表单数据发布到我的服务器时出现错误。varformData=newFormData()formData.append('name',fullname)formData.append('email',email)formData.append('message',message+'--SentfromAndroidapp')fetch('https://www.xxxx.com/mail',{method:'POST',headers:{'Accept':'appli

在 android Kitkat 中找不到 android.support.v4.content.FileProvider 类

我正在使用FileProvider在我的应用程序中。像往常一样,我宣布在AndroidManifest.xml中标记文件如下。当我在有lollipop的安卓设备上运行它时版本它工作正常。当我在kitkat上试穿时版本它显示以下错误:FATALEXCEPTION:mainProcess:com.jk.android.perfectphotoeditor2018,PID:24992java.lang.RuntimeException:Unabletogetproviderandroid.support.v4.content.FileProvider:java.lang.ClassNotFo