Android App crashing when opening a new intent
Two things, when you initialize your intent, you're using Intent(String action) as the constructor. Is com.rohan.tictactoe.PlayerOne
an action? Is it your class? If it's a class, you really shouldn't be doing it that way.
Try this:
public void winner(){
Intent i = new Intent(this, PlayerOne.class);
Intent x = new Intent(this, PlayerTwo.class);
//blahblah rest of your code
}
Secondly, you need to add the activities to your AndroidManifest.xml in order for it to work. Inside your AndroidManifest.xml, you must add this between your application tags:
<activity android:name=".PlayerOne"/>
<activity android:name=".PlayerTwo"/>
Why does my app keep crashing when launching the camera intent in a new activity?
you are occuring java.lang.SecurityException: Permission Denial ... with revoked permission android.permission.CAMERA
- your app don't have camera access permission
use runtime permissions for acquire
App crashes while passing Intent
You can try this approach to call the second activity from the asynctask
When initializing the object of asynctask pass the current class reference as parameter
private class insertOTP extends AsyncTask<Void, Void, String> {
private Activity activity;
private ProgressDialog pDialog;
public insertOTP(Activity activity) {
this.activity = activity;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(activity);
pDialog.setMessage("Kindly wait...");
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected String doInBackground(Void... params) {
try {
// RPS for inserting few things
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String response) {
super.onPostExecute(response);
pDialog.dismiss();
if (response.equals("success")) {
Intent intent = new Intent(activity, SecondActivity.class);
intent.putExtra("class","1");
activity.startActivity(intent);
} else {
Toast.makeText(activity, "This user already exists...", Toast.LENGTH_SHORT).show();
}
}
}
Android app crashes when starting a new Intent
Oh, your error is simple.
I think you have copied the Activities and you have forgotten to change the layout in the setContentView()
of all of your Activities. all of them are R.layout.activity_main
so the app is starting the activity_main.xml but the view are getting findViewById()
from their real resources.
Android App crashes when trying to go to a new Intent
**THE PROBLEM LIES HERE! It crashes when I click on the list item, to go to the content...**
Intent intent = new Intent(MainActivity.this, Post.class); // use MainActivity.this
intent.putExtra("id", yourId); // seems typo
startActivity(intent);
Please also check the AndroidManifest.xml.
Activity "Post" should be declared there.
<activity android:name=".Post" />
my app crashes when I start a new intent
You lambda convention for intent is correct.
You should not use JACK for now as it now deprecated or replaced in android studio 2.4 preview
https://android-developers.googleblog.com/2017/04/java-8-language-features-support-update.html
Or you can also Use retrolambda if you want as jack is not supported with databinding.
For your question: my main question here is, what might be causing this issue?
Check you logs to find why the application is crashing
as you said you have defined it in android manifest so that would not be an issue.
Check view whether is null or not (might not be refrenced properly)
I dont think there is any problem with build process as application crashes at runtime.
Do share you log in question.
Related Topics
How to Loop Through List of Webelements and Select One Webelement With a Condition
Unit Testing Private Functions in Junit With Mockito
How to Retrieve Element Value from Soap Response Using Java
How to Get the Parent Element Name of a Child Element in Json
Crudrepository and Hibernate: Save(List<S>) VS Save(Entity) in Transaction
Http Post Request With Content Type Application/X-Www-Form-Urlencoded Not Working in Spring
How to Center Crop a Background Image of Linear Layout
Java.Sql.Sqlexception: Field Doesn't Have a Default Value
How to Send Text to Textarea in Div Element Using Selenium
How to Read Empty Cells of an Excel File Using Poi
Unable to Deploy Spring Boot 2 Application Due to Hikaripool Exception During Pool Initialization
Typecasting an Object from Parent Class to Child
Spring Boot Application Shutdown Immediate After Starting
Why Is Git Bash Not Using the Correct Java Path as Defined in the Path Environment Variable
Java.Time.Format.Datetimeparseexception: Text Could Not Be Parsed At Index 3