嘿伙计们感谢回答我是Android编程的新手(我今天开始),当我尝试构建一个具有在5秒后弹出的启动背景的应用程序时,它会给我带来各种错误,包括一些文件没有出现“跳过48帧!”我会在这里发布错误
07-16 21:29:23.119: E/Trace(641): error opening trace file: No such file or directory (2)
07-16 21:29:23.309: D/dalvikvm(641): GC_FOR_ALLOC freed 73K, 3% free 8051K/8259K, paused 44ms, total 46ms
07-16 21:29:23.309: I/dalvikvm-heap(641): Grow heap (frag case) to 8.497MB for 614416-byte allocation
07-16 21:29:23.390: D/dalvikvm(641): GC_CONCURRENT freed 1K, 3% free 8650K/8903K, paused 33ms+16ms, total 79ms
07-16 21:29:23.709: I/Choreographer(641): Skipped 42 frames! The application may be doing too much work on its main thread.
07-16 21:29:23.770: D/gralloc_goldfish(641): Emulator without GPU emulation detected.
07-16 21:29:29.019: I/Choreographer(641): Skipped 48 frames! The application may be doing too much work on its main thread.
这是main.java
public class Main扩展Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Thread logoTimer = new Thread(){
public void run(){
try{
sleep(5000);
Intent menuIntent = new Intent("com.kamath.thebasics.MENU");
startActivity(menuIntent);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
finish();
}
}
};
logoTimer.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
和menu.java
公共类菜单扩展了Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
}
答案 0 :(得分:0)
试试这个(在主要活动的onCreate中):
Thread myThread = new Thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent menuIntent = new Intent("com.kamath.thebasics.MENU");
startActivity(menuIntent);
}
}
};
myThread.run();
也许这有帮助。