Reputation: 45
When I click on Signin Button, App is Crashing. While I am debugging the code, it moves to a finally block of "Looper.java" file. I don't have any file with this name.
MainActivity.java
private void signIn() {
Intent intent = new Intent(MainActivity.this, Main_Tab.class);
startActivity(intent);
setContentView(R.layout.activity_main_home);
}
Looper.java
try {
msg.target.dispatchMessage(msg);
} finally {
if (traceTag != 0) {
Trace.traceEnd(traceTag);
}
}
Upvotes: 0
Views: 3765
Reputation: 43
You wouldn't have added the activity (Main_Tab) to your AndroidManifest.xml file I faced the same issue and it was resolved upon doing this.
Upvotes: 2
Reputation: 132
Are you sure the Main_Tab.class extends some kind of Activity class such as "AppCompatActivity". One thing that also caught my eyes is your usage of underscore in Main_Tab, but I guess it's my personal preference to use camelcase for naming classes.
Also try removing:
setContentView(R.layout.activity_main_home);
Upvotes: 0
Reputation: 556
Change your sign in constructor to this
private void signIn() {
Intent intent = new Intent(context, Main_Tab.class);
startActivity(intent);
finish();
}
and in your onCreate constructor add this if not there already.
final Context context = this;
Let me know if you still have issues.
Upvotes: 0
Reputation: 7
private void signIn() {
Intent intent = new Intent(MainActivity.this, Main_Tab.class);
startActivity(intent);
}
Try this, don't call setContentView method after starting the activity.
Upvotes: 0
Reputation: 759
In onCreate()
method always put these two lines on top -
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
So, all you need in onClickListener()
, in this case which is signIn()
are these.
Intent intent = new Intent(MainActivity.this, Main_Tab.class);
startActivity(intent)
If the app is still crashing, debug onCreate()
method of Main_Tab
and post the log report.
Upvotes: 0
Reputation: 831
The below line should be before starting the activity.
setContentView(R.layout.activity_main_home);
because when you run new activity, new content will be displayed instead of old one. it should be like this.
private void signIn() {
setContentView(R.layout.activity_main_home);
Intent intent = new Intent(MainActivity.this, Main_Tab.class);
startActivity(intent);
}
Upvotes: 0
Reputation: 33
try this
private void signIn() {
Intent intent = new Intent(MainActivity.this, Main_Tab.class);
startActivity(intent);
}
Upvotes: 0