[Android Studio] manubittencourt:
Hello there!

I'm building an app but whenever it comes to the AlertDialog .show() it chrashes. I've reserached but couldn't find any solution.

Most of them were got their problem fixed by changing Context on

AlertDialog.Builder example = new AlertDialog.Builder(Context)

to

AlertDialog.Builder example = new AlertDialog.Builder(MyActivity.this);

But that's not my case, I've beeing using MyActivity.this all long and still crashes.

Here's my code:

ublic class MainActivity extends AppCompatActivity {

Button btMudaTela;

final Funcoes funcao = new Funcoes();

[MENTION=439709]override[/MENTION]

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button btMudaTela = (Button) findViewById(R.id.btMudaTela);

//Ao clicar no botão outra activity será aberta (ActivityCadastro)

btMudaTela.setOnClickListener(new View.OnClickListener() {

[MENTION=439709]override[/MENTION]

public void onClick(View v) {

AlertDialog.Builder adb = new AlertDialog.Builder(MainActivity.this);

adb.setTitle("teste");

adb.setMessage("ok");

adb.show();

funcao.mudaActivity(MainActivity.this, ActivityCadastro.class);

finish();

}

});

}

}

And here's my Logcat:

06-23 07:41:42.113 3303 3303 E AndroidRuntime: Process: com.example.teste.projetofinal, PID: 3303

06-23 07:41:42.113 3303 3303 E AndroidRuntime:	at com.example.teste.projetofinal.MainActivity$1.onClick(MainActivity.java:46)

06-23 07:41:42.123 954 1367 W ActivityManager: Force finishing activity com.example.teste.projetofinal/.MainActivity

06-23 07:41:43.334 954 1602 I ActivityManager: Process com.example.teste.projetofinal (pid 3303) (adj 9) has died.

06-23 07:41:43.334 954 1454 I WindowState: WIN DEATH: Window{444ca450 u0 com.example.teste.projetofinal/com.example.teste.projetofinal.MainActivity}

06-23 07:50:39.406 6806 6806 W InstallAppProgress: Replacing package:com.example.teste.projetofinal

06-23 07:50:42.219 5389 5389 I Finsky : [1] com.google.android.finsky.verifier.impl.br.c(104): Verification complete: id=0, package_name=com.example.teste.projetofinal

06-23 07:50:42.960 954 1046 I PackageManager: Package com.example.teste.projetofinal codePath changed from /data/app/com.example.teste.projetofinal-19.apk to /data/app/com.example.teste.projetofinal-20.apk; Retaining data and using new

06-23 07:50:43.921 954 1046 W PackageManager: Code path for pkg : com.example.teste.projetofinal changing from /data/app/com.example.teste.projetofinal-19.apk to /data/app/com.example.teste.projetofinal-20.apk

06-23 07:50:43.921 954 1046 W PackageManager: Resource path for pkg : com.example.teste.projetofinal changing from /data/app/com.example.teste.projetofinal-19.apk to /data/app/com.example.teste.projetofinal-20.apk

06-23 07:50:45.592 954 1036 I CrashAnrDetector: onPackageUpdateFinished : com.example.teste.projetofinal

06-23 07:50:46.073 6987 6987 E dalvikvm: >>>>> com.example.teste.projetofinal [ userId:0 | appId:10200 ]

06-23 07:50:47.444 6987 6987 E AndroidRuntime: Process: com.example.teste.projetofinal, PID: 6987

06-23 07:50:47.444 6987 6987 E AndroidRuntime:	at com.example.teste.projetofinal.MainActivity$1.onClick(MainActivity.java:40)

06-23 07:50:47.444 954 1602 W ActivityManager: Force finishing activity com.example.teste.projetofinal/.MainActivity

06-23 07:50:48.806 954 1602 I WindowState: WIN DEATH: Window{433e3670 u0 com.example.teste.projetofinal/com.example.teste.projetofinal.MainActivity}

06-23 07:50:48.836 954 1545 I ActivityManager: Process com.example.teste.projetofinal (pid 6987) (adj 9) has died.

06-23 07:50:51.188 3939 3939 E SPPClientService: [PackageInfoChangeReceiver] [handlePkgRemovedEvent] PackageName : com.example.teste.projetofinal, true, false

06-23 07:50:54.531 5389 5389 I Finsky : [1] com.google.android.finsky.externalreferrer.d.run(9): Package state data is missing for com.example.teste.projetofinal

06-23 07:50:55.792 3498 7271 I FontsPackageChangeOp: Package com.example.teste.projetofinal has no metadata