我在运行应用时遇到问题
我有三个活动,包括 - MainActivity.java,一个启动活动,以及另一个名为AirportGuide的活动。
现在,当我在模拟器上运行应用程序时,播放声音,但屏幕为空白。飞溅三秒后,会打开一个新屏幕,该屏幕也是空白的。在我添加AirportGuide课程
之前,该应用程序运行正常这是MainActivity.java
package com.shashank.sharjahinternationalairport;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class MainActivity extends Activity {
ImageButton flightInfoButton;
ImageButton airportGuideButton;
ImageButton visitorInfoButton;
ImageButton saaDcaButton;
ImageButton cargoButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
flightInfoButton = (ImageButton) findViewById(R.id.flightInfo);
visitorInfoButton = (ImageButton) findViewById(R.id.visitorInfo);
saaDcaButton = (ImageButton) findViewById(R.id.saaDca);
cargoButton = (ImageButton) findViewById(R.id.cargo);
airportGuideButton = (ImageButton) findViewById(R.id.airportGuide);
airportGuideButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View V){
Intent openAirportGuide = new Intent( MainActivity.this, AirportGuide.class);
startActivity(openAirportGuide);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
这是AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shashank.sharjahinternationalairport"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.shashank.sharjahinternationalairport.Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.shashank.sharjahinternationalairport.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.shashank.sharjahinternationalairport.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.shashank.sharjahinternationalairport.AirportGuide"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.shashank.sharjahinternationalairport.AIRPORTGUIDE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
这是堆栈跟踪
02-13 13:01:50.808: E/eglCodecCommon(2345): writeFully: failed: Broken pipe
02-13 13:01:50.808: E/eglCodecCommon(2345): writeFully: failed: Broken pipe
02-13 13:01:50.808: W/libEGL(2345): eglInitialize(0x96a31040) failed (EGL_SUCCESS)
02-13 13:01:50.808: E/EGL_genymotion(2345): tid 2345: eglChooseConfig(576): error 0x3001 (EGL_NOT_INITIALIZED)
02-13 13:01:50.808: D/AndroidRuntime(2345): Shutting down VM
02-13 13:01:50.808: W/dalvikvm(2345): threadid=1: thread exiting with uncaught exception (group=0xa4cfdb20)
02-13 13:01:50.812: E/AndroidRuntime(2345): FATAL EXCEPTION: main
02-13 13:01:50.812: E/AndroidRuntime(2345): Process: com.shashank.sharjahinternationalairport, PID: 2345
02-13 13:01:50.812: E/AndroidRuntime(2345): java.lang.IllegalArgumentException: eglChooseConfig failed EGL_NOT_INITIALIZED
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.HardwareRenderer$GlRenderer.chooseEglConfig(HardwareRenderer.java:1173)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.HardwareRenderer$GlRenderer.loadEglConfig(HardwareRenderer.java:1135)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.HardwareRenderer$GlRenderer.initializeEgl(HardwareRenderer.java:1117)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:1057)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1550)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.Choreographer.doFrame(Choreographer.java:544)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.os.Handler.handleCallback(Handler.java:733)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.os.Handler.dispatchMessage(Handler.java:95)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.os.Looper.loop(Looper.java:136)
02-13 13:01:50.812: E/AndroidRuntime(2345): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-13 13:01:50.812: E/AndroidRuntime(2345): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 13:01:50.812: E/AndroidRuntime(2345): at java.lang.reflect.Method.invoke(Method.java:515)
02-13 13:01:50.812: E/AndroidRuntime(2345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-13 13:01:50.812: E/AndroidRuntime(2345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-13 13:01:50.812: E/AndroidRuntime(2345): at dalvik.system.NativeStart.main(Native Method)
这是启动活动
package com.shashank.sharjahinternationalairport;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity{
MediaPlayer splashSound;
@Override
protected void onCreate(Bundle splashScreen) {
// TODO Auto-generated method stub
super.onCreate(splashScreen);
setContentView(R.layout.splash);
splashSound = MediaPlayer.create(Splash.this, R.raw.splashsound);
splashSound.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(3200);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainActivity = new Intent("com.shashank.sharjahinternationalairport.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
splashSound.release();
finish();
}
}
答案 0 :(得分:10)
重新启动您的模拟器。在硬件设备上测试它,它可能会工作。