0
My APK opens correctly when the code is this:
package com.example.wheresmybusdriver;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Localizacao extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_localizacao);
}
public void sairLogin(View view){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
But when I add to the code:
TextView statusLocation = (TextView)findViewById(R.id.textStatus);
public void informeStatusSim(View view) {
statusLocation.setText("Sua localização esta sendo transmitida!");
}
public void informeStatusNao(View view) {
statusLocation.setText("Sua localização não esta sendo transmitida!");
}
Thus remaining the result:
package com.example.wheresmybusdriver;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Localizacao extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_localizacao);
}
public void sairLogin(View view){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
TextView statusLocation = (TextView)findViewById(R.id.textStatus);
public void informeStatusSim(View view) {
statusLocation.setText("Sua localização esta sendo transmitida!");
}
public void informeStatusNao(View view) {
statusLocation.setText("Sua localização não esta sendo transmitida!");
}
}
apk does not open and the message appears ("apk" shows faults continuously). I find it strange that when I enter my apk, I go to his homepage, so it works correctly, but when I click on the button to enter Activity with the above code, it stops working.
I did that and now it works, thank you.
– João Pedro Souza