Jūs esateŽurnalai / Ernestas Kardzys's blog / ActivityNotFoundException on Android?
ActivityNotFoundException on Android?
I am creating a small Android client for my Master's theses. Unfortunately, I've encountered a problem: I get ActivityNotFoundException during runtime process. I just need to change the activity of my program (to show the help box). Maybe someone could give me a hint what I'm doing wrong?
My main file/activity looks like that:
package info.ernestas.uvrsclient; import info.ernestas.uvrsclient.help.HelpActivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class UVRSClientMain extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.uvrsclient_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.connecttoserver: return true; case R.id.disconnectfromserver: return true; case R.id.help: try { Intent myIntent = new Intent(this, HelpActivity.class); startActivityForResult(myIntent, 0); return true; } catch (Exception e) { Log.e("Error!", e.toString()); } default: return super.onOptionsItemSelected(item); } } }
My help file/activity looks like that:
package info.ernestas.uvrsclient.help; import info.ernestas.uvrsclient.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class HelpActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help); Button next = (Button) findViewById(R.id.Button02); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); } }
And, finally, my AndroidManifest.xml file looks like that:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="info.ernestas.uvrsclient" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".UVRSClientMain" 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=".HelpActivity"></activity> </application> <uses-permission android:name="android.permission.CAMERA" /> </manifest>
And the exception thrown is this one:
android.content.ActivityNotFoundException: Unable to find explicit activity class {info.ernestas.uvrsclient/info.ernestas.uvrsclient.help.HelpActivity}; have you declared this activity in your AndroidManifest.xml?
Some code taken from here: http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/


Skelbti naują komentarą