I am getting NullPointerException while starting a helloworld activity. I am starting this class from FileEvent.java class, which code I have put down here.
public class FileEvent extends Activity implements ObserverActivity{
public static String path2;
public String filename;
public String path;
public adapter info ;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.info = new adapter(this);
}
public void insert(String path) {
// TODO Auto-generated method stub
// try{
this.info = new adapter(this);
this.filename = path;
System.out.println("Starting intent in fileevent");
try{
startActivity(new Intent(FileEvent.this,hello.class)); // In this line I am getting nullpointerexception was caught.
}
catch(Exception e)
{
Log.v("Caught in insert() of FileEvent : ",e.toString());
}
}
hello.class consists of a simple textview.
AndroidManifest.xml :-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sample_fileobserver"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.sample_fileobserver.hello"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.hello" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.sample_fileobserver.FileEvent"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.FIleEvent" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
The logcat shows the following message -
09-28 05:51:55.307: I/System.out(13542): Starting intent in fileevent
09-28 05:51:55.307: A/FileObserver(13542): Unhandled exception in FileObserver com.example.sample_fileobserver.MyFileObserver#b11bec18
09-28 05:51:55.307: A/FileObserver(13542): java.lang.NullPointerException
09-28 05:51:55.307: A/FileObserver(13542): at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
09-28 05:51:55.307: A/FileObserver(13542): at android.content.ComponentName.<init>(ComponentName.java:75)
09-28 05:51:55.307: A/FileObserver(13542): at android.content.Intent.<init>(Intent.java:3662)
09-28 05:51:55.307: A/FileObserver(13542): at com.example.sample_fileobserver.FileEvent.insert(FileEvent.java:42)
09-28 05:51:55.307: A/FileObserver(13542): at com.example.sample_fileobserver.MyFileObserver.onEvent(MyFileObserver.java:70)
09-28 05:51:55.307: A/FileObserver(13542): at android.os.FileObserver$ObserverThread.onEvent(FileObserver.java:125)
09-28 05:51:55.307: A/FileObserver(13542): at android.os.FileObserver$ObserverThread.observe(Native Method)
09-28 05:51:55.307: A/FileObserver(13542): at android.os.FileObserver$ObserverThread.run(FileObserver.java:88)
Note :-
1) I have not declared setContentView() in FileEvent class, since it does not going to use UI.
2) Here onCreate() is not running, as I am calling insert() from another class of my application.
It might seem that, this question might be duplicate of many other questions, but I did not find the right solution from those questions.
Thanks in advance.
You are getting error because you are trying to call another activity with FileEvent class context. I think it is not possible.
If you are calling insert() method from another class, have to pass context of that class.
Try to pass Context of that class.
Your Method should be
public void insert(String path, Context context)
{
info = new adapter(context);
filename = path;
try
{
startActivity(new Intent(context,hello.class));
}
catch(Exception e)
{
Log.v("Caught in insert() of FileEvent : ",e.toString());
}
}
Hope it will help you.
Change your manifest:
<activity
android:name="com.example.sample_fileobserver.FileEvent"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
I want to know why it cannot open up new java class.
When I try to start new activity, it will be crash.
public class MainActivity extends ActionBarActivity {
EditText emailEt;
TextView registerET;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
emailEt = (EditText) findViewById(R.id.email);
registerET = (TextView) findViewById(R.id.register);
registerET.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i("clicks","You Clicked register page");
Intent myIntent = new Intent(MainActivity.this, RegisterActivity.class);
startActivity(myIntent);
MainActivity.this.finish();
}
});
}
public void OnLogin(View view) {
String username = emailEt.getText().toString();
String type = "login";
BackgroundWorker backgroundWorker = new BackgroundWorker(this);
backgroundWorker.execute(type, username);
}
}
It's possible manifests problem? Am I put it wrong position for the activity?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a20_1discussboard">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>"
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<activity android:label="#string/app_name" android:name=".RegisterActivity"/>
</manifest>
It look like can be open up new java class, but it still display MainActivity.
Error Log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.a20_1discussboard, PID: 2194
java.lang.IllegalStateException: Could not find method onClick(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatTextView with id 'register'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Put proper Menifest format:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a20_1discussboard">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>"
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
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:label="#string/app_name"
android:name=".RegisterActivity"/> //<---here
</application>
</manifest>
Don't call finish(), this caused your crash:
registerET.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i("clicks","You Clicked register page");
Intent myIntent = new Intent(MainActivity.this, RegisterActivity.class);
startActivity(myIntent);
//remove finish();
}
});
Try declared activity in application in your AndroidManifest.xml like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a20_1discussboard">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>"
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
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:label="#string/app_name"
android:name=".RegisterActivity"/>
</application>
</manifest>
Be sure that you add RegisterActivity to your AndroidManifest.xml inside <application> tag:
<application ...>
...
<activity
android:label="#string/app_name"
android:name=".RegisterActivity"/>
</application>
Delete this line from onCreate method: MainActivity.this.finish();
If you want to stop or pause MainActivity, use:
#Override
public void onPause() { }
or
#Override
public void onStop() { }
in MainActivity class.
Thanks all.
Add RegisterActivity to AndroidManifest.xml inside <application> tag and remove MainActivity.this.finish()
It is working now.
I have following code, I am truing to start an activity given certain condition is true. But over startActivity(controllerActivity); I am getting java.lang.NullPointerException
The controllerActivity variable at the stage contains a valid value of Intent { act=android.intent.action.Main }
Thread thr_authenticateUser = new Thread(new Runnable() {
#Override
public void run() {
…
Boolean _authenticationStatus = Boolean.valueOf(authenticationReplyValue);
if (_authenticationStatus) {
Intent controllerActivity = new Intent("android.intent.action.Main");
startActivity(controllerActivity); //NullPointerException
}
}
});
thr_authenticateUser.start();
Over further findings I found out that the exact place where it is failing is inside Main activitY’s `onCreate()
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.main_view); // HERE: java.lang.NullPointerException
However the view name main_view is correct and it exists.
Manifest:
<activity
android:name=".Main"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.Main" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Compelte stack trace:
java.lang.NullPointerException
at android.app.Activity.startActivityForResult(Activity.java:3370)
at android.app.Activity.startActivityForResult(Activity.java:3331)
at android.app.Activity.startActivity(Activity.java:3566)
at android.app.Activity.startActivity(Activity.java:3534)
at com.citypulse.citypulse.User$1.run(User.java:57)
at java.lang.Thread.run(Thread.java:856)
Get the context to start your activity
getBaseContext().startActivity(controlledActivity);
or
YourActivity.this.startActivity(controlledActivity);
Okay so I've been messing around with the Twitter API, and all of a sudden I've started to get the ClassNotFoundException error code when I try and enter the Activity which has my login box to sign into Twitter.
Here's the error code.
2398-2398/josh.com.twitterapi E/dalvikvm﹕ Could not find class 'josh.com.twitterapi.LoginActivity', referenced from method josh.com.twitterapi.NavigationDrawerFragment.selectItem
07-05 02:19:30.138 2398-2398/josh.com.twitterapi E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: josh.com.twitterapi.LoginActivity
at josh.com.twitterapi.NavigationDrawerFragment.selectItem(NavigationDrawerFragment.java:204)
at josh.com.twitterapi.NavigationDrawerFragment.access$000(NavigationDrawerFragment.java:32)
at josh.com.twitterapi.NavigationDrawerFragment$1.onItemClick(NavigationDrawerFragment.java:99)
at android.widget.AdapterView.performItemClick(AdapterView.java:301)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3071)
at android.widget.AbsListView$1.run(AbsListView.java:3973)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
07-05 02:21:03.973 3223-3223/josh.com.twitterapi E/dalvikvm﹕ Could not find class 'josh.com.twitterapi.LoginActivity', referenced from method josh.com.twitterapi.NavigationDrawerFragment.selectItem
This is my LoginActivity.java.
package josh.com.socialme;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import com.codepath.oauth.OAuthLoginActivity;
public class LoginActivity extends OAuthLoginActivity<TwitterClient> {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
// Inflate the menu; this adds items to the action bar if it is present.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
// OAuth authenticated successfully, launch primary authenticated activity
// i.e Display application "homepage"
#Override
public void onLoginSuccess() {
// Intent i = new Intent(this, PhotosActivity.class);
// startActivity(i);
}
// OAuth authentication flow failed, handle the error
// i.e Display an error dialog or toast
#Override
public void onLoginFailure(Exception e) {
e.printStackTrace();
}
// Click handler method for the button used to start OAuth flow
// Uses the client to initiate OAuth authorization
// This should be tied to a button used to login
public void loginToRest(View view) {
getClient().connect();
}
}
This is my AndroidManifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="josh.com.socialme" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<activity
android:name=".Hub"
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=".Feed"
android:label="#string/title_activity_feed" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
And this is my method I use to get to the activity.
private void selectItem(int position) {
// Handle Navigation Options
Intent intent;
switch (position) {
case 1:
intent = new Intent(getActivity(), Feed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
break;
case 2:
intent = new Intent(getActivity(), LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
break;
}
}
I would greatly appreciate it if someone could point me towards the right direction.
Kind regards,
Josh
(AndroidManifest.xml as requested)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="josh.com.socialme" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<activity
android:name=".Hub"
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=".Feed"
android:label="#string/title_activity_feed" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_login_activity" >
</activity>
</application>
</manifest>
I'm trying to start an activity
`package com.kapzlock.mytestproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
#Override
protected void onCreate(Bundle SomeVar) {
// TODO Auto-generated method stub
super.onCreate(SomeVar);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
Intent openStartingPoint = new Intent("com.kapzlock.mytestproject.MAINACTIVITY");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
`
The Manifest xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kapzlock.mytestproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.kapzlock.mytestproject.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
It compiles without problems, but when I run the Splash.class, I'm getting an Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Activity Error. The package name is com.kapzlock.mytestproject and the class that I'm referencing to is MainActivity.class. Has anybody an idea where the mistake could be in?
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes.Click on Apply and clean the project.
This worked for me.Hope this helps.
Replace your code with following
finally
{
Intent openStartingPoint = new Intent(this,MAINACTIVITY.class);
startActivity(openStartingPoint);
}
Remove following from your manifest.xml in mainActivity tag
<intent-filter>
<action android:name="com.kapzlock.mytestproject.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
I get this error when I run my program. It starts up the first page, but when it's supposed to go to .Menu it crashes:
11-04 06:01:06.039: W/dalvikvm(949): threadid=11: thread exiting with uncaught exception (group=0x414c4700)
11-04 06:01:06.057: E/AndroidRuntime(949): FATAL EXCEPTION: Thread-87
11-04 06:01:06.057: E/AndroidRuntime(949): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.secondapp.MENU }
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Activity.startActivityForResult(Activity.java:3390)
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Activity.startActivityForResult(Activity.java:3351)
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Activity.startActivity(Activity.java:3587)
11-04 06:01:06.057: E/AndroidRuntime(949): at android.app.Activity.startActivity(Activity.java:3555)
11-04 06:01:06.057: E/AndroidRuntime(949): at com.example.secondapp.Splash$1.run(Splash.java:26)
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.secondapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
And here are the .java files of my .Splash activity and my .Menu activity:
Splash
package com.example.secondapp;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer ourSong;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.happyman);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent startMain = new Intent("com.example.secondapp.MENU");
startActivity(startMain);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
Menu
package com.example.secondapp;
public class Menu extends ListActivity {
String classes[] = {"MainActivity", "example1", "example2", "example3", "example4", "example5"};
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
String Cheese = classes[position];
super.onListItemClick(l, v, position, id);
try{
Class ourClass = Class.forName("com.example.secondapp." + Cheese);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
in your manifest the action should match. Change it with com.example.secondapp.MENU
It is in caps MENU should be Menu
Change to
Intent startMain = new Intent("com.example.secondapp.Menu");
coz your activity is public class Menu extends ListActivity { and in manifest you have
<activity
android:name=".Menu"
Edit:
Explicit intents designate the target component by its name (the
component name field, mentioned earlier, has a value set). Since
component names would generally not be known to developers of other
applications, explicit intents are typically used for
application-internal messages — such as an activity starting a
subordinate service or launching a sister activity.
Implicit intents do not name a target (the field for the component
name is blank). Implicit intents are often used to activate
components in other applications.
So Change to explicit intent
Intent startMain = new Intent(Splash.this,Menu.class); // in Splash.java
and in manifest
<activity
android:name="com.example.secondapp.Menu"
android:label="#string/app_name" >
</activity>
For more info check the docs
http://developer.android.com/guide/components/intents-filters.html
You need to set activity class in your manifest and you misspelled MENU
replace
<activity
android:name=".Menu"
android:label="#string/app_name" >
with
<activity
android:name=".MENU"
android:label="#string/app_name" >