Getting Illegalstateexception On Button Click
Solution 1:
The key part of the full stack trace is found here:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.unholyalliance.infinitestream/com.example.unholyalliance.infinitestream.Host}; have you declared this activity in your AndroidManifest.xml
It appears you do not have this Host activity declared in your manifest file. Open AndroidManifest.xml and check for or add the following:
<activityandroid:name=".Host" />Also make sure you fix the issue in Host to first only declare your TextView and then assign the value in onCreate() after setContentView().
privateTextView service_status;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_host);
service_status = (TextView) findViewById(R.id.textView1);
...
}
Solution 2:
Make sure that your onClick in Button view in activity_main.xml is like this android:onClick="host"
Example:
<Button
android:id="@+id/main_activity_bt_host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/host"
android:onClick="host" />
Solution 3:
Above answers are correct, but also double check to register your class in Manifest.
<activityandroid:name=".Downloaded"android:label="@string/app_name"></activity>.Downloaded is your class name above.
Solution 4:
Check your Parcelable objects or Serializable objects that are putted intent whether is correct. Inspect carefully subclasses and add essential interfaces (Serializable or Parcelable) if you need.
Post a Comment for "Getting Illegalstateexception On Button Click"