我目前正在使用Phonegap 1.6.0和Sencha Touch 1.1创建一个应用程序.最近,在使用Android 4.0.4的智能手机上进行测试时,我们发现Facebook登录并没有像预期的那样完全正常工作.我们正在使用位于此处的Phonegap Facebook插件和Cordova补丁.会发生的是,一旦我们尝试使用Android Honeycomb或更高版本的智能手机登录Facebook,该应用程序就会启动NetworkOnMainThreadException,因为主线程上不允许进行网络操作.此异常仅在Android Honeycomb或更高版本上引发,这就是我们在2.3.3上没有注意到的原因.调用FB.login()并且未达到回调时抛出异常.
我检查了各种线程和主题,但都非常模糊.我知道我必须在一个单独的线程中运行网络操作,但我不确定应该怎么做.线程似乎发生在Java中,但我根本就没有使用任何Java,所以在使用非我编写的代码进行修改之前,我想要一些帮助.
我将稍后尝试缩小导致异常的部分.任何帮助,将不胜感激.
错误堆栈:
05-25 15:42:29.018: I/Web Console(3785): Cordova Facebook Connect plugin initialized successfully. at file:///android_asset/www/cdv-plugin-fb-connect.js:24
05-25 15:42:29.120: D/OpenGLRenderer(3785): Flushing caches (mode 0)
05-25 15:42:30.479: D/ConnectPlugin(3785): authorized
05-25 15:42:30.479: D/ConnectPlugin(3785): Bundle[{expires_in=5177550, access_token=censored, code=censored}]
05-25 15:42:30.503: D/AndroidRuntime(3785): Shutting down VM
05-25 15:42:30.503: W/dalvikvm(3785): threadid=1: thread exiting with uncaught exception (group=0x40a671f8)
05-25 15:42:30.511: E/AndroidRuntime(3785): FATAL EXCEPTION: main
05-25 15:42:30.511: E/AndroidRuntime(3785): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=-1, data=Intent { (has extras) …Run Code Online (Sandbox Code Playgroud) 我在AsynkTask中编写了网络操作代码时得到了android.os.NetworkOnMainThreadException.抛出这个例外有什么其他原因吗?
这是我的代码:
public class Background_confirmation extends AsyncTask<Void, Integer, Void> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
progressDialog = ProgressDialog.show(Confirmation.this,
"Please wait...", "Retrieving data ...", true);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://68.121.167.160/sip_chat_api/create_account.php?useralias="
+ useralias + "&cntname=" + cntcode + "");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
e.printStackTrace();
}
if (backgroung_flag == 1) {
} else {
if (is != null) …Run Code Online (Sandbox Code Playgroud) 在ICS上,我在使用UrlConnection时遇到android.os.NetworkOnMainThreadException错误 - 即使我在一个运行在它自己的进程上的服务中发出此请求,并且被异步调用以通过Messenger完成.
更改StrictPolicy无效,我仍然收到错误.
我能做什么?
编辑:此服务在一个单独的进程中运行 - 具有不同的pid和所有内容.
我正在使用一个使用开源Java库(Calimero)的Android应用程序.当我尝试通过WiFi连接到KNXnet/IP路由器时,我的代码会引发错误.
这里的问题代码:
private static KNXNetworkLinkIP connect(InetSocketAddress isaLocalEP, InetSocketAddress isaRemoteEP)
{
KNXNetworkLinkIP netLinkIp = null;
int serviceMode = KNXNetworkLinkIP.TUNNEL; // tunnel to IP router
boolean useNAT = true; // NAT not used for PC true or false , but needed for emulator = true
KNXMediumSettings tpSettings = new TPSettings(true); // TP1 medium
try
{
// Output the local end point address
if (m_debugOutput == true)
{
System.out.println("..Tunneling, NAT ignored, TP1 medium");
// Should be the PC's VPN address
System.out.print("..Local EP:");
System.out.println(isaLocalEP.getHostName() …Run Code Online (Sandbox Code Playgroud) 我为活动创建了一个布局文件.在这个布局中,我创建了一个带有textview和edittext的LinearLayout.现在我想创建额外的LinearLayouts,它将查看并包含与原始LinearLayout完全相同的视图,但具有不同的文本.我还想在运行期间以编程方式执行此操作,因为这些LinearLayout的数量在运行之间会有所不同.我已经阅读了一些关于inflaters的内容,但我对它们的理解并不充分.
我在想这样的事情,显然代码是错误的,但希望你明白我想做什么:
LinearLayout llMain = (LinearLayout)findViewById(R.id.mainLayout);
LinearLayout llToCopy = (LinearLayout)findViewById(R.id.linearLayoutToCopy);
for(int player = 0; player < size; player++)
{
LinearLayout llCopy = llToCopy.clone();
TextView tv = (TextView)llCopy.getChildAt(0);
tv.setText(players.get(player).getName());
llMain.addView(llCopy);
}
Run Code Online (Sandbox Code Playgroud) 我试图在iframe元素中注入脚本试图以这种方式实现,子和父不属于同一个域(我知道XSS在最新浏览器中被阻止)有没有办法将脚本注入按钮的子元素点击父母元件.(在Chrome控制台中有类似的运行脚本)
var myIframe = document.getElementById("myIframeId");
var script = myIframe.contentWindow.document.createElement("script");
script.type = "text/javascript";
script.src = "randomshit.js";
myIframe.contentWindow.document.body.appendChild(script);
Run Code Online (Sandbox Code Playgroud) 我正在尝试将此C#方法转换为PHP.第二个参数中的out是什么意思?
public static bool Foo(string name, out string key)
Run Code Online (Sandbox Code Playgroud) 我在水平滚动视图中添加了线性布局,并在布局中添加了一些文本视图.是否有可能在此布局中获得可见的孩子.
这段代码得到了所有孩子,但我想看到(仅显示)孩子:
final HorizontalScrollView scroll = (HorizontalScrollView)findViewById(R.id.horizontalScrollView1);
LinearLayout linearLayout = ((LinearLayout)scroll.findViewById(R.id.linearLayout1));
int chilrenNum = linearLayout.getChildCount();
Run Code Online (Sandbox Code Playgroud) 我正在使用pico默认的android TTS引擎和IPA caracters这样做
String text3 = "<speak xml:lang=\"fr-FR\"> <phoneme alphabet=\"ipa\" ph=\"+"+words+"\"/>.</speak>";
myTTS.speak(text3, TextToSpeech.QUEUE_ADD, null);
Run Code Online (Sandbox Code Playgroud)
它通常有效,但对于某些字母,它不喜欢"ã"或"ɑ"等.
所以我的问题是,如何将这些字母/声音添加到此TTS引擎?
我正在尝试创建一个带有头文件的cocoa touch框架,该文件遵循以下模式:
#include <Compay/Product.h>
Run Code Online (Sandbox Code Playgroud)
而不是通常的
#include <Product/Product.h>
Run Code Online (Sandbox Code Playgroud)
例如 #include <Google/Analytics.h>
代替 #include <Analytics/Analytics.h>
在xcode 7中?
android ×6
android-wifi ×1
c# ×1
cocoa-touch ×1
cordova ×1
exception ×1
facebook ×1
frameworks ×1
html5 ×1
iframe ×1
inject ×1
ios8 ×1
javascript ×1
networking ×1
out ×1
php ×1
sockets ×1
view ×1
xcode ×1