Discussion:
How to use the app bar with NativeActivity?
Andreas Falkenhahn
2018-03-27 14:04:29 UTC
Permalink
Is it possible to have an app bar on top of a NativeActivity whose contents are drawn by C code writing raw pixels into the memory buffer obtained from ANativeWindow_lock()?

I've read the App Bar developer tutorial provided by Google at https://developer.android.com/training/appbar/setting-up.html but it says that activities using the App Bar should extend AppCompatActivity, i.e.

public class MyActivity extends AppCompatActivity { }

and then call setSupportActionBar(). But how can I make this work with NativeActivity? I don't know much about Java but I don't think it's possible to write an activity which extends two activities, i.e. AppCompatActivity *and* NativeActivity, is it?

So is it possible to use the App Bar together with a NativeActivity at all?
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1485448003.20180327160429%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
Philippe Simons
2018-03-27 14:23:49 UTC
Permalink
it's possible since NativeActivity extends framework Activity, you have
access to the native ActionBar.
So you should be able to setup a menu to it.
Post by Andreas Falkenhahn
Is it possible to have an app bar on top of a NativeActivity whose
contents are drawn by C code writing raw pixels into the memory buffer
obtained from ANativeWindow_lock()?
I've read the App Bar developer tutorial provided by Google at
https://developer.android.com/training/appbar/setting-up.html but it says
that activities using the App Bar should extend AppCompatActivity, i.e.
public class MyActivity extends AppCompatActivity { }
and then call setSupportActionBar(). But how can I make this work with
NativeActivity? I don't know much about Java but I don't think it's
possible to write an activity which extends two activities, i.e.
AppCompatActivity *and* NativeActivity, is it?
So is it possible to use the App Bar together with a NativeActivity at all?
--
Best regards,
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/
msgid/android-ndk/1485448003.20180327160429%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CADomA48ZgyzJ_nRBbkZMHMwFNsRjDdd7cYy2j8i78ACv03z7Jw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Falkenhahn
2018-03-27 15:36:16 UTC
Permalink
Post by Philippe Simons
it's possible since NativeActivity extends framework Activity, you
have access to the native ActionBar.
So you should be able to setup a menu to it.
Thanks. Unfortunately, the Action Bar is probably not fit for my
needs. I'll post a follow-up question...
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/327411020.20180327173616%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Falkenhahn
2018-03-27 18:52:54 UTC
Permalink
Post by Philippe Simons
it's possible since NativeActivity extends framework Activity, you
have access to the native ActionBar.
So you should be able to setup a menu to it.
Hmm, are you sure that this is possible? I'm having a really hard time
trying to get an ActionBar on top of my NativeActivity. It's very hard
to find sample code because obviously everybody uses the AppCompat-style
bars which I cannot use because of NativeActivity.

So I've tried the following instead:

public class MyActivity extends android.app.NativeActivity {

@Override
public void onCreate(Bundle savedInstanceState) {

this.requestWindowFeature(Window.FEATURE_ACTION_BAR);

super.onCreate(savedInstanceState);

getActionBar().show();
}
}

But it doesn't work. No ActionBar is shown. Any ideas?
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/09557122.20180327205254%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
Philippe Simons
2018-03-27 18:58:08 UTC
Permalink
could you try using the Theme
Post by Andreas Falkenhahn
Post by Philippe Simons
it's possible since NativeActivity extends framework Activity, you
have access to the native ActionBar.
So you should be able to setup a menu to it.
Hmm, are you sure that this is possible? I'm having a really hard time
trying to get an ActionBar on top of my NativeActivity. It's very hard
to find sample code because obviously everybody uses the AppCompat-style
bars which I cannot use because of NativeActivity.
public class MyActivity extends android.app.NativeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);
getActionBar().show();
}
}
But it doesn't work. No ActionBar is shown. Any ideas?
--
Best regards,
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/
msgid/android-ndk/09557122.20180327205254%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CADomA49zfvT5tj-XM%3Dnf3dDBXW32vWfkXXMam6NVki4hsjhPKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Falkenhahn
2018-03-27 19:10:54 UTC
Permalink
Post by Philippe Simons
could you try using the Theme
I've tried the following:

In res/values/styles.xml:

<resources>
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>

In AndroidManifest.xml:

<activity android:name=".MyActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:theme="@style/CustomActionBarTheme">

But it still doesn't work. It doesn't show an ActionBar :-(
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/182101375.20180327211054%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
Philippe Simons
2018-03-27 19:18:25 UTC
Permalink
if you don't apply any theme, you should still see the window title? no ?
Post by Andreas Falkenhahn
Post by Philippe Simons
could you try using the Theme
<resources>
<style name="CustomActionBarTheme"
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>
<activity android:name=".MyActivity"
android:configChanges="orientation|screenSize"
But it still doesn't work. It doesn't show an ActionBar :-(
--
Best regards,
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/
msgid/android-ndk/182101375.20180327211054%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CADomA4_UfWei1jEZ7fW8ZP7wdvX3jh8R1Nw-tLkp8De1jGODbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Andreas Falkenhahn
2018-03-27 19:30:36 UTC
Permalink
Post by Philippe Simons
if you don't apply any theme, you should still see the window title? no ?
No, there is no window title when not setting a theme...
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/224595449.20180327213036%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
Loading...