您好,我在这里看到了一个教程(http://www.youtube.com/watch?v=embeFCPzRCg),其中只有一个初始屏幕,然后其他主屏幕出现......视频中的代码工作正常。 ..但是当我编写自己的代码时,日志猫中出现错误并且启动屏幕出现但在进入下一个屏幕之前应用程序崩溃了。
日志文件错误
块引用
06-12 14:34:45.195: I/dalvikvm-heap(25510): Grow heap (frag case) to 13.376MB for 519700-byte allocation
06-12 14:34:45.240: D/dalvikvm(25510): GC_CONCURRENT freed 1K, 8% free 12731K/13831K, paused 13ms+2ms, total 45ms
06-12 14:34:45.310: D/libEGL(25510): loaded /system/lib/egl/libEGL_mali.so
06-12 14:34:45.320: D/libEGL(25510): loaded /system/lib/egl/libGLESv1_CM_mali.so
06-12 14:34:45.325: D/libEGL(25510): loaded /system/lib/egl/libGLESv2_mali.so
06-12 14:34:45.325: D/(25510): Device driver API match
06-12 14:34:45.325: D/(25510): Device driver API version: 10
06-12 14:34:45.325: D/(25510): User space API version: 10
06-12 14:34:45.325: D/(25510): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16
15:37:13 KST 2012
06-12 14:34:45.365: D/OpenGLRenderer(25510): Enabling debug mode 0
06-12 14:34:46.275: W/dalvikvm(25510): threadid=11: thread exiting with uncaught exception (group=0x411292a0)
06-12 14:34:46.280: E/AndroidRuntime(25510): FATAL EXCEPTION: Thread-11666
06-12 14:34:46.280: E/AndroidRuntime(25510): android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.example.edoc_dc/com.example.edoc_dc.Main}; have you declared this activity in your AndroidManifest.xml?
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1420)
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Activity.startActivityForResult(Activity.java:3446)
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Activity.startActivityForResult(Activity.java:3407)
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Activity.startActivity(Activity.java:3617)
06-12 14:34:46.280: E/AndroidRuntime(25510): at android.app.Activity.startActivity(Activity.java:3585)
06-12 14:34:46.280: E/AndroidRuntime(25510): at com.example.edoc_dc.Edoc_dc$1.run(Edoc_dc.java:28)
06-12 14:34:46.320: I/Process(25510): Sending signal. PID: 25510 SIG: 9
06-12 14:35:12.360: W/dalvikvm(25869): threadid=11: thread exiting with uncaught exception (group=0x411292a0)
06-12 14:35:12.360: E/AndroidRuntime(25869): FATAL EXCEPTION: Thread-11681
06-12 14:35:12.360: E/AndroidRuntime(25869): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.edoc_dc/com.example.edoc_dc.Main}; have you declared this activity in your AndroidManifest.xml?
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1420)
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Activity.startActivityForResult(Activity.java:3446)
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Activity.startActivityForResult(Activity.java:3407)
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Activity.startActivity(Activity.java:3617)
06-12 14:35:12.360: E/AndroidRuntime(25869): at android.app.Activity.startActivity(Activity.java:3585)
06-12 14:35:12.360: E/AndroidRuntime(25869): at com.example.edoc_dc.Edoc_dc$1.run(Edoc_dc.java:28)
这是我的初始屏幕代码,它是首先加载的 edoc_dc.java
package com.example.edoc_dc;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
public class Edoc_dc extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edoc_dc);
// meke the thread here
Thread splash_screen= new Thread(){
public void run() {
try{
sleep(1000);
}catch(Exception e){
e.printStackTrace();
}finally{
startActivity(new Intent( getApplicationContext(), Main.class));
finish();
}//end finaly
}// end run
};// end thread
splash_screen.start();
}// end method
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_edoc_dc, menu);
return true;
}
}
这是它的activity_edoc_dc.xml
<RelativeLayout 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" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_final" />
</RelativeLayout>
这里是main.java,它在打包com.example.edoc_dc之后被加载;
import android.app.Activity;
import android.os.Bundle;
public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// adding the desktop to it
setContentView(R.layout.main_desktop);
}// end on create
}// end main
这是它的 xml 文件 main_desktop.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HERE IS THE DESKTOP"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
这是我的清单文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.edoc_dc"
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=".Edoc_dc"
android:label="@string/title_activity_edoc_dc" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
请解决问题并告诉该怎么做..应用程序运行良好,只是在进入主屏幕之前崩溃了