Normally I will declare a new activity in AndroidManifest.xml as below:
Let’s say my new activity is Tutorial.java.
<activity android:name=".Tutorial"></activity>
But I found an example, the developer not declare the new activity as above. The code is list as below:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dezine.thebasics"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".myMain"
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=".myMenu"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.dezine.thebasics.CLEARSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
myMenu.java
package com.dezine.thebasics;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class myMenu extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final MediaPlayer mpButtonClick = MediaPlayer.create(this, R.raw.click);
Button bTutorial1 = (Button) findViewById(R.id.button1);
bTutorial1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.dezine.thebasics.TUTORIAL"));
mpButtonClick.start();
}
});
}
}
The above code is work fine at beginning(mean I don’t change anything in AndroidManifest.xml) but it will come out error after I modify something in Manifest.xml. eg. I change the SDK version.
E/AndroidRuntime(5236): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.dezine.thebasics.TUTORIAL }
Please tell me how it work. Thank you.
There is a difference between TUTORIAL and Tutorial
Let me give you more detail.
You have written below code to start activity:
But you have defined activity inside AndroidManifest.xml as:
And thats why you are getting this exception.