Skip to content

Instantly share code, notes, and snippets.

@iandouglas
Last active November 10, 2016 00:48
Show Gist options
  • Select an option

  • Save iandouglas/0d6daa197bc0062e3317b41f2a40eff3 to your computer and use it in GitHub Desktop.

Select an option

Save iandouglas/0d6daa197bc0062e3317b41f2a40eff3 to your computer and use it in GitHub Desktop.
Stuck on styling a taskstack toolbar on the launched activity
...
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.RegisterActivity"
android:theme="@style/AppTheme"
android:label="@string/menu_register"
android:parentActivityName="io.getstream.example.activities.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
...
<?xml ...>
<android.support.design.widget.CoordinatorLayout ...
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ToolbarPopupOverlay" <!-- is this even needed? -->
android:theme="@style/ToolbarTheme" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.AppBarLayout>
...
</android.support.design.widget.CoordinatorLayout>
...
protected void launchActivity(String activity, Context context) {
intent = null;
int requestCode = 0;
if (activity.equals("register")) {
requestCode = CONST_ACTIVITY_REGISTER;
intent = new Intent(context, RegisterActivity.class);
} else { ... }
if (intent != null) {
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
taskStackBuilder.addParentStack(MainActivity.class);
taskStackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentIntent(pendingIntent);
startActivityForResult(intent, requestCode);
}
}
@Lennoard
Copy link
Copy Markdown

Why are you using 2 AbbBarLayout anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment