I’m new to Java so, I think in order to prevent this error from appearing I’ll have to write a Handler thread? Using try and catch? How do i do this?
Here’s the code to help you out.
Thanks 🙂
package android.app;
import android.app.Activity;
import android.app.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class AndroidActivity extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.Start_CoolWhapp);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), activity2.class);
startActivityForResult(myIntent, 0);
}
});
}
}
Ok so there are a few things
First make sure all activities are in your manifest file like so:
You may need more attributes than that but that’s the basics.
I do not know why you need “startActivityForResult” as I cannot see the code but if it is just another activity with a layout with Views then you can alter your code like so:
Make sure activity2 has a layout and that the layout exists.