I am trying to make a game that switches the activity whenever the user clicks a button. I am trying to use the Application class to use a variable throughout all of my activities, this is the variable for the current time in milliseconds when the app starts.
Then, in the game over screen I want to find the current time again, and then subtract currentTime from the new current time. This should give me the amount of time the user has been playing the game. After finding this value; I simply want to display it on the screen. The problem is, I am getting the following error:
Starting: Intent { act=android.intent.action.MAIN cat= [android.intent.category.LAUNCHER] cmp=com.example.username.buttonsmasher/.Main_Menu }
Error type 3
Error: Activity class {com.example.username.buttonsmasher/com.example.username.buttonsmasher.Main_Menu} does not exist.
Here is my Main_Menu onCreate activity, where I set the currentTimeMillis as the variable CurrentTime, which I get from the myCurrentTime class:
Here is the gameOver screen where I display the total time spent on the app:
Here is the android manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.username.buttonsmasher" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main_Menu"
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=".Left_Up"
android:label="@string/title_activity_left__up" >
</activity>
<activity
android:name=".Left_Center"
android:label="@string/title_activity_left__center" >
</activity>
<activity
android:name=".Left_Down"
android:label="@string/title_activity_left__down" >
</activity>
<activity
android:name=".Center_Up"
android:label="@string/title_activity_center__up" >
</activity>
<activity
android:name=".Center_Center"
android:label="@string/title_activity_center__center" >
</activity>
<activity
android:name=".Center_Down"
android:label="@string/title_activity_center__down" >
</activity>
<activity
android:name=".Right_Up"
android:label="@string/title_activity_right__up" >
</activity>
<activity
android:name=".Right_Center"
android:label="@string/title_activity_right__center" >
</activity>
<activity
android:name=".Right_Down"
android:label="@string/title_activity_right__down" >
</activity>
<activity
android:name=".GameOver"
android:label="@string/title_activity_game_over" >
</activity>
</application>
<application>android:name=".myCurrentTime"</application>
</manifest>
Please help me as to why this error is happening. The reason I only posted certain methods of the app is because I know the issue is with the time. The app was running fine untill today, when I tried to add the time display. I really appreciate your help, and I have been trying to solve this issue for over 2 hours now! Thank you so much, and if you need any more information, feel free to let me know. Any feedback is appreciated.
Thanks!
答案 0 :(得分:1)
Ah, I didn't see your second Application tag. I don't think you can do that :)
Place the name property inside the first application tag and remove the second one.