【问题标题】:OpenGLRenderer flushing caches (mode 0)OpenGLRenderer 刷新缓存(模式 0)
【发布时间】:2015-03-10 11:19:01
【问题描述】:

我有一个问题,我不知道原因,所以在 POST 中的 asynctask 调用后运行我的应用程序时,我更改了活动,并且当新的活动将主要内容设置到屏幕时,应用程序会因任何日志而崩溃。

activty chages 代码是在 asynctask 的 onPostExecute 方法中编写的,我尝试在另一个线程中执行此操作,从 Activity 调用 runOnUIThread 方法但不工作。 我看到的唯一日志:

03-10 12:03:20.312: I/MyHttpClient(3160): HTTPResponse received in [1210ms]
03-10 12:03:20.367: I/my.app.package.ActivationActivity(3160): SendActivation onPostExecute: ActivationResponse [my.app.result.json.with.SUCCESS:result.code]
03-10 12:03:25.398: D/OpenGLRenderer(3160): Flushing caches (mode 0)

编辑:现在我更改了一些类和对象的名称,但代码对我不起作用

class MyAsincTask extends AsyncTask<String, Void, String>
{
    private Exception exception;
    private Gson gson;

    protected void onPostExecute(String response) {
        hideProgressDialog();
        if (exception != null) {
            //deleted log code here
        } else if (response != null) {
            // I manage the json response from the server
            try {
                // I manage the json response 
                // determining if the server call was SUCCESS or ERROR
                if (resultCode.equals(Constants.RESULT_ERROR)) {
                    //deleted log code here
                }else if (resultCode.equals(Constants.RESULT_SUCCESS)) {
                    launchRegistration(); // I enter Here and then crashes
                }
            } catch (Exception e) {
                //deleted log code here
            }
            //deleted log code here
        } else {
            //deleted log code here
        }
    }

}

    protected void launchRegistration(){

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Intent mIntent = new Intent(mContext, ActivityToOpen.class);
            mIntent.setAction(Constants.ACTION_TO_OPEN_ACTIVITY);
            mIntent.putExtra(Constants.SOME_EXTRA,  extras);
            startActivity(mIntent);
            finish();
        }
    }); 
}

在其他活动中,而异步任务类在其他活动类中。这段代码适用于许多最近的设备,包括最近的硬件和最新版本,如 4.4 和 5 和 4.3,但问题出现在其他设备上,4.0 和 4.1,硬件资源较少。

【问题讨论】:

  • 能否请您发布您的代码
  • 我现在已经编辑了这个问题,我的代码在很多情况下都有效,但在某些情况下不起作用

标签: android multithreading android-activity android-asynctask


【解决方案1】:
`<activity android:name="com.example.Activity"
           android:excludeFromRecents="true"
           android:icon="@drawable/app_icon"
           android:label="@string/wizard.welcome.title"
           android:theme="@style/Theme.NoDisplay" /> `

我所做的错误是在清单声明中,某些活动的主题为“NoDisplay”,在最新版本的 android 中不起作用,但在以前的版本中起作用。为此,我遇到了一个问题。 谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-04
    • 1970-01-01
    • 2012-01-02
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多