Android Manifest Splash Hello World Complete Balls up
我有一个功能齐全的应用程序,如果你可以称之为功能齐全的 hello world。 有 3 个选项卡,每个选项卡都执行一些操作,并且在它之前会出现一个提示。
我想我犯了一个错误,尝试使用 google api 来获取一些 gps 的东西,并以某种方式成功地破坏了我的项目和备份版本。所以现在我只是想把它全部拼凑起来,然后再通过电子邮件发送给我的讲师。
问题:当设置运行配置来启动启动画面时,启动画面完成后我收到大量错误。我是一个完全的新手,所以我不知道我的代码剩下的哪一部分是错误的。我怀疑它要么是清单,要么是启动代码意图指针。
logcat
10-24 05:28:08.297: D/dalvikvm(612): GC_EXTERNAL_ALLOC freed 673 objects / 52920 bytes in 136ms
10-24 05:28:13.185: W/dalvikvm(612): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
10-24 05:28:13.195: E/AndroidRuntime(612): FATAL EXCEPTION: Thread-8
10-24 05:28:13.195: E/AndroidRuntime(612): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.b00517566.helloworldfinal/com.b00517566.helloworld.HelloWorldfinalActivity}; have you declared this activity in your AndroidManifest.xml?
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Activity.startActivityForResult(Activity.java:2817)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Activity.startActivity(Activity.java:2923)
10-24 05:28:13.195: E/AndroidRuntime(612): at com.b00517566.helloworldfinal.splash$1.run(splash.java:37)
启动
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.b00517566.helloworldfinal"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".HelloWorldFinalActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="splash"> <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter></activity>
<activity android:name="ButtonTab">
<intent-filter></intent-filter>
</activity>
<activity android:name="MiscTab">
<intent-filter></intent-filter>
</activity>
<activity android:name="RadioBtnsTab">
<intent-filter></intent-filter>
</activity>
</application>
</manifest>
清单
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// thread for displaying the SplashScreen
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
Intent i = new Intent();
i.setClassName("com.b00517566.helloworldfinal",
"com.b00517566.helloworld.HelloWorldfinalActivity");
startActivity(i);
//startActivity(new Intent("com528.b00517566.helloworld"));
// stop();
}
}
};
splashTread.start();
}
I had a fully functional app, if you could call a hello world fully functional.
Had 3 tabs, each did something, and a splash would come up before it.
I think I made the mistake of trying to use google api to get some gps stuff going on and somehow managed to bork my project and the backup versions. so right now I'm just trying to peice it all back together before I email it to my lecturer.
QUESTION: When setting run configuration to launch the splash, I get a load of errors as the splash finishes. I'm a complete novice so I don't know what part of whats left of my code is wrong. I suspect its either the manifest or the splash code intent pointer thingy.
logcat
10-24 05:28:08.297: D/dalvikvm(612): GC_EXTERNAL_ALLOC freed 673 objects / 52920 bytes in 136ms
10-24 05:28:13.185: W/dalvikvm(612): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
10-24 05:28:13.195: E/AndroidRuntime(612): FATAL EXCEPTION: Thread-8
10-24 05:28:13.195: E/AndroidRuntime(612): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.b00517566.helloworldfinal/com.b00517566.helloworld.HelloWorldfinalActivity}; have you declared this activity in your AndroidManifest.xml?
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Activity.startActivityForResult(Activity.java:2817)
10-24 05:28:13.195: E/AndroidRuntime(612): at android.app.Activity.startActivity(Activity.java:2923)
10-24 05:28:13.195: E/AndroidRuntime(612): at com.b00517566.helloworldfinal.splash$1.run(splash.java:37)
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.b00517566.helloworldfinal"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".HelloWorldFinalActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="splash"> <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter></activity>
<activity android:name="ButtonTab">
<intent-filter></intent-filter>
</activity>
<activity android:name="MiscTab">
<intent-filter></intent-filter>
</activity>
<activity android:name="RadioBtnsTab">
<intent-filter></intent-filter>
</activity>
</application>
</manifest>
splash
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// thread for displaying the SplashScreen
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
Intent i = new Intent();
i.setClassName("com.b00517566.helloworldfinal",
"com.b00517566.helloworld.HelloWorldfinalActivity");
startActivity(i);
//startActivity(new Intent("com528.b00517566.helloworld"));
// stop();
}
}
};
splashTread.start();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误表明它找不到“HelloWorldfinalActivity”,并且您的清单定义了“HelloWorldFinalActivity” - 第一种情况为小写 f,第二种情况为大写 F。
清单中的活动名称应与您为活动指定的带有“.”的类名称相同。在他们面前。例如,如果您有一个 HelloWorldFinalActivity.class,则清单中的名称应为“.HelloWorldFinalActivity”。
此外,还有一种更直接的方法来启动活动:
将 CurrentActivityName 替换为该代码所在的类的名称。
The error says that it cannot find "HelloWorldfinalActivity" and your manifest defines "HelloWorldFinalActivity" - lowercase f in the first case, uppercase F in the second.
Your activity names in the manifest should be the same as the class names that you give your activity with a '.' before them. For instance, if you have a HelloWorldFinalActivity.class then the name in the manifest should be ".HelloWorldFinalActivity".
Also, there's a more straightforward way to start an activity:
Replace CurrentActivityName with the name of the class this this code is in.