English 中文(简体)
另一条路段的反馈造成例外。
原标题:Callback from another thread causes an exception

我试图创造一个简单的多功能游戏。 《工作守则》(<>Workerservice)本应处理所有网络通信,这一服务与我的活动之间的所有互动都是与工技工组织进行的。 我认为,这是一种标准做法——使我能以两种方式进行互动,我也使用<条码>。

问题在于,必须改变在国库中只能做的事情。 I ve创建了Handler(in UI thread),认为这是一个明显的解决办法。 但令人惊讶的是,它没有发挥作用。

www.un.org/spanish/ga/president 我的<代码>Workerservice的对应方法做了一些工作,并做了一些回击——这项工作是细致的。 <打字码>Workerservice从这一深层结果中发现了一条新的read子和 call子:

<编码> Can t在未称作Looper.prepare()的校外制造手

在这里,一些法典明确规定:

private void startServerImpl(String name, float latStart, float latEnd,
float lonStart, float lonEnd)
{
    // some instructions here

    // this works fine:
    callback.notifySocketCreated();

    // my naughty thread:
    new ServerThread().start();

    // some instructions here
}

www.un.org/Depts/DGACM/index_spanish.htm

private class ServerThread extends Thread {
    @Override
    public void run()
    {
        //some instructions here

        // this call will cause an error
        callback.notifyGameRegistered();

    }
}

《<条码>查询的每一方法 期望:

public void notifyGameRegistered() throws RemoteException
{
    handler.dispatchMessage(handler.obtainMessage(CALLBACK_GAME_REGISTERED));
}

在Handler s handleMessage()中,采用简单的switch(msg.what)的方法,在每一种情况下,都进行简单的“ID”修改(即“Toast”,改动案文等)。

我不知道为什么这种例外被推翻。 我曾设法将其固定下来,将编码包装成<条码>可兰经<>条码/代码>,并打电话<条码>runOnUiThread(,但仍然使我感到奇怪——应当让步者总是在产生条码时操作吗? 或者,我是否做过错?

问题回答

我知道这是很晚的,但问题是,你称之为<条码>。

正确的方法是sendMessage()。

我猜测,问题不是你的手臂在错误的read子上,而是国际律师联合会试图在你使用Handle(Handle)方法的某个地方制造一名残疾者。 由于Handle(Handle)被叫作错透镜,你正在成为一个例外。

/**
 * Handle system messages here.
 */
public void dispatchMessage(Message msg)
{
    if (msg.callback != null) {
        handleCallback(msg);
    } else {
        handleMessage(msg);
    }
}

你们不得不从主线上说犯罪功能。

改变国际不动产业联合会的职能应当是拥有国际不动产业联合会的活动。

This link should help you out: http://android-developers.blogspot.com/2009/05/painless-threading.html





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签