解决方案:
<activity
android:name=".Specials"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.kita.MyGardenCenterApp.SPECIALS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
确定臭名昭著的“未找到活动”错误。
按钮:
Button btnSpecials = (Button) findViewById(R.id.btnSpecials);
btnSpecials.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.kita.MyGardenCenterApp.SPECIALS"));
}
});
显现:
<activity
android:label="@string/app_name"
android:name=".Specials" >
<intent-filter >
<action android:name="android.intent.action.SPECIALS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
原木猫:
05-16 09:44:50.149: E/AndroidRuntime(17747): FATAL EXCEPTION: main
05-16 09:44:50.149: E/AndroidRuntime(17747): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.kita.MyGardenCenterApp.SPECIALS }
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.Activity.startActivityFromChild(Activity.java:3057)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.Activity.startActivityForResult(Activity.java:2837)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.Activity.startActivity(Activity.java:2923)
05-16 09:44:50.149: E/AndroidRuntime(17747): at com.kita.MyGardenCenterApp.Home_Page$1.onClick(Home_Page.java:49)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.view.View.performClick(View.java:2408)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.view.View$PerformClick.run(View.java:8816)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.os.Handler.handleCallback(Handler.java:587)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.os.Handler.dispatchMessage(Handler.java:92)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.os.Looper.loop(Looper.java:123)
05-16 09:44:50.149: E/AndroidRuntime(17747): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 09:44:50.149: E/AndroidRuntime(17747): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 09:44:50.149: E/AndroidRuntime(17747): at java.lang.reflect.Method.invoke(Method.java:521)
05-16 09:44:50.149: E/AndroidRuntime(17747): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
05-16 09:44:50.149: E/AndroidRuntime(17747): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:651)
05-16 09:44:50.149: E/AndroidRuntime(17747): at dalvik.system.NativeStart.main(Native Method)
编辑:
为了回应您的一些答案,我有另一个使用以下代码的应用程序,它工作正常。这就是为什么我在这里问。我想以正确的方式做到这一点。
我的 .java 文件也是 Specials.java
<activity
android:label="@string/app_name"
android:name=".mainAboutUs" >
<intent-filter >
<action android:name="com.kita.PapaStew.MAINABOUTUS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
添加完整清单
<?xml version="1.0" encoding="utf-8"?>
<permission
android:name="com.kita.MyGardenCenterApp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="com.kita.MyGardenCenterApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:name="StoredValues"
android:icon="@drawable/icon"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<service android:name=".C2DMReceiver" />
<receiver
android:name="C2DMReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.kita.MyGardenCenterApp" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.kita.MyGardenCenterApp" />
</intent-filter>
</receiver>
<activity
android:name=".MyGardenCenterAppActivity"
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=".myTabbar"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.kita.MyGardenCenterApp.MYTABBAR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Home_Page"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.HOMEPAGE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Notification"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.NOTIFICATION" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Calendar"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.CALENDAR" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Facebook"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.FACEBOOK" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Map_Activity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAPACTIVITY" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".More"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MORE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Twitter"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TWITTER" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Website"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.WEBSITE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Google_Plus"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.GOOGLEPLUS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Notes"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.NOTES" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Feedback"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.FEEDBACK" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kita.MyGardenCenterApp.SPECIALS"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.kita.MyGardenCenterApp.SPECIALS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Ask_the_Expert"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.ASKTHEEXPERT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Tips"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TIPS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Just_In"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.JUSTIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Calulators"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.CALCULATORS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>