我正在開發的應用程序正在與我混淆。我目前有三項活動(所有這些活動均在清單中定義),所有過渡到彼此,即介紹 - >活動1 - >活動2。Android startActivity()適用於一個類,但不適用於其他
public void GOTOGPS(View v)
{
switch (v.getId()){
case R.id.button1: startActivity(new Intent(v.getContext(), StreetLightOutageActivity.class));//Jump to StreetLightOutageActivity (main.xml)
default: break;
}//switch
}//GOTOGPS
然而,在使用去我的第三個活動我的第二個活動「StreetLightOutageActivity」的方法不起作用:
public void GOTOCAMERA1(View v)
{
switch (v.getId()){
case R.id.picturebutton: startActivity(new Intent(v.getContext(), Camera.class));
default: break;
}//switch
}//GOTOCAMERA1
從介紹到的第一個活動的過渡使用工作正常
logcat的給了我一個ActivityNotFoundException:
05-17 15:51:41.292: E/AndroidRuntime(534): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {sl.reporter/android.hardware.Camera}; have you declared this activity in your AndroidManifest.xml?
,然後一個的InvocationTargetException我以爲從以前的例外莖:
05-17 15:51:41.292: E/AndroidRuntime(534): Caused by: java.lang.reflect.InvocationTargetException
現在什麼是真正讓我的是,如果我修改從我introscreen過渡到我的第二個活動去「Camera.class」,而不是StreetLightOutageActivity.class的方法,它的工作原理。
最後,這裏是我的清單,以防萬一有幫助,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sl.reporter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:icon="@drawable/ic_launcher">
<activity
android:name=".StreetLightOutageActivity">
</activity>
<activity
android:name=".Camera">
</activity>
<activity
android:name=".Introscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
聖牛,我去吃午飯,回來,你已經修好了。我刪除了「android.hardware.Camera」,並像你說的那樣使用了「sl.reporter.Camera」,它完美運行。 – 0nyx
我很高興你的問題解決了。但爲什麼你不選擇我的答案是正確的? :) –
對不起,這是我在StackOverflow上的第一篇文章。剛剛做到了。 – 0nyx