PentaGames
PentaGames

Reputation: 3

Error: This class should provide a default constructor

I tried to generate a signatured APK but then this error appears:

Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.penta.games.mrpolitik.SpendenDialog) [Instantiatable]

This is my Dialog file

package com.penta.games.mrpolitik;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class SpendenDialog extends Dialog implements
        android.view.View.OnClickListener {

    private Activity c;
    private Button yes, no;

    public SpendenDialog(Activity a) {
        super(a);
        this.c = a;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.spenden_dialog);
        yes = (Button) findViewById(R.id.btn_yes);
        no = (Button) findViewById(R.id.btn_no);
        yes.setOnClickListener(this);
        no.setOnClickListener(this);
    }



    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_yes:
                Uri uri = Uri.parse("https://patreon.com/user?u=5716519&utm_medium=social&utm_source=twitter&utm_campaign=creatorshare2");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                c.startActivity(intent);
                break;
        }
        switch (v.getId()) {
            case R.id.btn_no:
                break;
        }
        dismiss();
    }



} 

How can I solve this error?

Upvotes: 0

Views: 422

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006654

How can I solve this error?

Step #1: Delete your constructor

Step #2: Delete your c field

Step #3: Replace all former references to c with getContext()

Upvotes: 1

Related Questions