0

I've recently updated my app extending Appcompatactivity in my Activities. Since then, the Actionbar is gone when I launch an external library Intent.

For example, I'm using the HockeyApp SDK to launch their FeedbackActivity

Here is my code:

FeedbackManager.showFeedbackActivity(this, Uri.fromFile(file));

And here a screenshot (you can see the ActionBar is gone).

enter image description here

It used to work before until I started extending Appcompatactivity.

For the rest of Activities it works. The ActionBar is gone only when I launch an external library Intent.

Any ideas?

Ale
  • 2,282
  • 5
  • 38
  • 67

2 Answers2

3

First, check your theme it may be like below ("NoActionBar"). Then the action bar is not appearing. If this is your issue. please add an appropriate theme for your application

 <application
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    />

if your theme is not a problem, you can add below content to your XML file. (add this as a first child of your XML file)

<android.support.v7.widget.Toolbar
   android:id="@+id/my_toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="?attr/colorPrimary"
   android:elevation="4dp"
   android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
   app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

and add below content to your activity on create method

protected void onCreate(Bundle savedInstanceState) {
    .......
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);
}
PushpikaWan
  • 2,437
  • 3
  • 14
  • 23
  • @Ale what is the error now? same or different. Please make sure that u add Toolbar as a first child of xml – PushpikaWan Nov 05 '18 at 15:30
  • your solution is correct but it doesn't work in out context because we are launching an external Intent. When we launch `FeedbackManager.showFeedbackActivity(this, Uri.fromFile(file));` it opens a new `Activity` (from the HockeyApp SDK) but we cannot modify its layout. – Ale Nov 07 '18 at 09:12
0

The reason is probably that FeedbackManager.showFeedbackActivity(this, Uri.fromFile(file)) opens a new FeedbackActivity.class which is subclass of Activity.class instead of AppCompatActivity.class, so it can not show the ActionBar.Here is a link https://stackoverflow.com/questions/30681918/nullpointerexception-with-actionbar-setdisplayhomeasupenabledboolean-on-a-nu that explains some reasons.

SeneyLy
  • 21
  • 1