Android logcat显示过度延迟设置亮度
我在eclipse中创建了一个简单的android应用程序,并在模拟器上运行它。它真的很慢,当我检查logcat时,我看到了两条“过度延迟”线 编辑:为了澄清,应用程序确实运行并显示预期的“输入消息先生”。我在研究它为什么这么慢,并认为过度的延迟可能与滞后有关 这是我的档案: 模拟器设置:Android logcat显示过度延迟设置亮度,android,logcat,avd,android-logcat,Android,Logcat,Avd,Android Logcat,我在eclipse中创建了一个简单的android应用程序,并在模拟器上运行它。它真的很慢,当我检查logcat时,我看到了两条“过度延迟”线 编辑:为了澄清,应用程序确实运行并显示预期的“输入消息先生”。我在研究它为什么这么慢,并认为过度的延迟可能与滞后有关 这是我的档案: 模拟器设置: Target: Android 4.1 - API Level 16 CPU: ARM (armeabi-v7a) SD Card: 9MiB Max VM application heap size: 10
Target: Android 4.1 - API Level 16
CPU: ARM (armeabi-v7a)
SD Card: 9MiB
Max VM application heap size: 1024
Device Ram Size: 1024
package com.example.my.first.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my.first.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/welcome_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/welcome_message_text"
android:layout_weight="1"/>
<Button android:id="@+id/editor_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/editor_button_text"
android:layout_weight="0"/>
</LinearLayout >
09-24 17:26:00.363: E/PowerManagerService(158): Excessive delay setting brightness: 420ms, mask=2
09-24 17:26:00.584: E/PowerManagerService(158): Excessive delay setting brightness: 218ms, mask=2
09-24 17:26:01.602: I/Choreographer(1750): Skipped 48 frames! The application may be doing too much work on its main thread.
09-24 17:26:32.856: I/Choreographer(1750): Skipped 39 frames! The application may be doing too much work on its main thread.
09-24 17:26:52.942: E/PowerManagerService(158): Excessive delay setting brightness: 158ms, mask=2
MainActivity.java:
Target: Android 4.1 - API Level 16
CPU: ARM (armeabi-v7a)
SD Card: 9MiB
Max VM application heap size: 1024
Device Ram Size: 1024
package com.example.my.first.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my.first.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/welcome_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/welcome_message_text"
android:layout_weight="1"/>
<Button android:id="@+id/editor_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/editor_button_text"
android:layout_weight="0"/>
</LinearLayout >
09-24 17:26:00.363: E/PowerManagerService(158): Excessive delay setting brightness: 420ms, mask=2
09-24 17:26:00.584: E/PowerManagerService(158): Excessive delay setting brightness: 218ms, mask=2
09-24 17:26:01.602: I/Choreographer(1750): Skipped 48 frames! The application may be doing too much work on its main thread.
09-24 17:26:32.856: I/Choreographer(1750): Skipped 39 frames! The application may be doing too much work on its main thread.
09-24 17:26:52.942: E/PowerManagerService(158): Excessive delay setting brightness: 158ms, mask=2
AndroidManifest.xml:
Target: Android 4.1 - API Level 16
CPU: ARM (armeabi-v7a)
SD Card: 9MiB
Max VM application heap size: 1024
Device Ram Size: 1024
package com.example.my.first.app;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my.first.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/welcome_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/welcome_message_text"
android:layout_weight="1"/>
<Button android:id="@+id/editor_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/editor_button_text"
android:layout_weight="0"/>
</LinearLayout >
09-24 17:26:00.363: E/PowerManagerService(158): Excessive delay setting brightness: 420ms, mask=2
09-24 17:26:00.584: E/PowerManagerService(158): Excessive delay setting brightness: 218ms, mask=2
09-24 17:26:01.602: I/Choreographer(1750): Skipped 48 frames! The application may be doing too much work on its main thread.
09-24 17:26:32.856: I/Choreographer(1750): Skipped 39 frames! The application may be doing too much work on its main thread.
09-24 17:26:52.942: E/PowerManagerService(158): Excessive delay setting brightness: 158ms, mask=2
由于您在计算机上使用的是仿真器,因此这很常见,与运行仿真器的计算机的性能有关,而与应用程序无关 这种情况偶尔也会发生在插入计算机并用作仿真器的手机上,但发生频率要低得多,而且很少见 您的应用程序很可能很好 您可以通过将手机插入电脑并在不使用应用程序的情况下使用手机来确认这一点。您将在logcat中看到系统本身的一些异常 您也可以在手机上安装,无需将其插入计算机,即可直接在手机上查看报告的错误。您可以在运行应用程序时查看是否发生这种情况,也可以在不运行应用程序时查看是否确实存在问题
注意:在Android 4.1+上,Catlog需要root用户,但在早期的4.0及以下版本上,它不需要root用户。您能发布在UI上运行的代码吗thread@draksia我如何看待所述UI线程中的代码?从属于您的方法调用的任何内容activity@draksia添加了mainactivity.java如果查看括号中的进程id号,您将看到(158)中的“过度延迟”消息来自手机上的其他信息。但是(1750)中的帧跳过消息可能来自您的应用程序。