Make BaseCrashReportDialog extend AppCompatActivity
See original GitHub issueBackground
I’m currently developing a custom crash report dialog, and I want it to be a full-screen dialog, as shown below:
I’ve extended BaseCrashReportDialog
, and I need to add the “X” in the top-left corner and the “Send” button in the top-right corner. I am using the following code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
ActionBar supportActionBar = getSupportActionBar();
assert supportActionBar != null;
supportActionBar.setDisplayHomeAsUpEnabled(true);
supportActionBar.setHomeAsUpIndicator(R.drawable.close);
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.report_problem, menu);
return true;
}
Problem
However, I cannot call getSupportActionBar()
because the base class doesn’t extend AppCompatActivity
. As a result, I cannot put an “X” in the top-left corner in a way that works on all OS versions.
Solutions
I can think of a few ways to deal with this:
- Use
AppCompatDelegate
as suggested in #443. The problem with this is it requires me to write a large amount of boilerplate code so is quite messy. Plus, there are still some behaviours that are built intoAppCompatActivity
but notAppCompatDelegate
. - Change
BaseCrashReportDialog
to extend fromAppCompatActivity
. I think this is a more reasonable base class than the currentFragmentActivity
. But I suppose this could be a breaking change… 😞 - Change
BaseCrashReportDialog
into a fragment that developers can include into their own activities. This way you still get a lot of control and the ability to hook into the activity but without dictating the class hierarchy for the activity itself.
Edit: actually I ended up deciding not to go ahead with ACRA (due to GDPR), but I’ll still leave this issue open in case you’re interested.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
java - How to extend AppCompatActivity for an activity which ...
AppCompatActivity ; import java.util.ArrayList; public class Exter extends AppCompatActivity{ public static ArrayList<HashMap<String, ...
Read more >AppCompatActivity - Android Developers
public class AppCompatActivity extends FragmentActivity implements AppCompatCallback, TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.
Read more >Introducing the Activity - CommonsWare
When you create a new project, it is very likely that you will be given an activity that extends from AppCompatActivity .
Read more >9. WHAT IS APPCOMPATACTIVITY IN ANDROID STUDIO
In this video you will understand in detail what is AppCompatActivity with simple real life examples.
Read more >Different Ways to fix Cannot resolve symbol ... - GeeksforGeeks
When you create a project and extends activity AppCompatActivity, sometimes you must have observed Android Studio throws an error that is:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think I’d prefer to allow any activity as dialog, and encapsulate all logic in
BaseCrashReportDialog
in a POJO.There are no sources in the repository for it, as this “Class [is] generated based on AcraDialog”
(Quote from http://www.acra.ch/javadoc/latest/org/acra/config/DialogConfiguration.html)