Reputation: 144
The app that I am developing is messing with me. I have three activities at the moment (all of which are defined in the manifest), that all transition into eachother i.e intro-->activity1-->activity2. The transition from the intro to the first activity works fine using:
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
However, the method in my second activity "StreetLightOutageActivity" that is used to go to my third activity does not work:
public void GOTOCAMERA1(View v)
{
switch (v.getId()){
case R.id.picturebutton: startActivity(new Intent(v.getContext(), Camera.class));
default: break;
}//switch
}//GOTOCAMERA1
LogCat gives me an 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?
and then an InvocationTargetException which I assume stems from the previous exception:
05-17 15:51:41.292: E/AndroidRuntime(534): Caused by: java.lang.reflect.InvocationTargetException
Now what is really getting me, is that if I modify the method to transition from my introscreen to my second activity to go to "Camera.class" instead of StreetLightOutageActivity.class, It works.
finally, here is my manifest just in case it helps,
<?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>
Upvotes: 0
Views: 598
Reputation: 11256
case R.id.picturebutton: startActivity(new Intent(v.getContext(), Camera.class));
I think in the above code you want to use sl.reporter.Camera
class, but mistakenly you end up using android.hardware.Camera
.
Upvotes: 1
Reputation: 22306
You likely are referencing the Android built in camera Class instead of your own
Make sure in your imports you don't have
import android.graphics.Camera;
or
import android.hardware.Camera;
if so delete it and make sure when you import your Camera class it is pointing to your own..
ex.
import sl.reporter.Camera;
Upvotes: 0
Reputation: 30168
You're using the wrong import for your purported Camera activity class:
Unable to find explicit activity class {sl.reporter/android.hardware.Camera};
Upvotes: 0