Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:58:19+00:00 2026-05-27T02:58:19+00:00

Is there a way to set the content of a NativeActivity to a component

  • 0

Is there a way to set the content of a NativeActivity to a component created in Java (such as a FrameLayout, ImageView, etc)? I have a need to use a NativeActivity (for getting touchpad input on Xperia Play), but I also need to be able to view components created in the Java code.

I’ve tried overriding the onCreate command and calling setContentView there, but although that doesn’t throw any errors, it doesn’t do anything either (apparently because the content view is already set by the native code). Is there some sort of window id or something that I could pass to the native code to tell it what the content view should be, or can this somehow be set up in the XML to set the NativeActivity’s content view to a component that I can modify from Java?

Let me know if you need any more information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:58:19+00:00Added an answer on May 27, 2026 at 2:58 am

    I’ll post the answer here for others with the same problem, since I did eventually figure out a method that works.

    In the onCreate() method, if you are setting any particular window flags (FEATURE_NO_TITLE, FLAG_FULLSCREEN, FLAG_KEEP_SCREEN_ON, etc) do those before you call super.onCreate() (or they’ll be ignored). Then wherever you would normally put this:

    setContentView( whatever );
    

    Do this instead:

    getWindow().takeSurface( null );
    getWindow().setContentView( whatever );
    

    That’s the basic way to get the content to be controlled from the Java side. Any place in your code where you deal with the content, use “getWindow()” instead of “this”.

    Some other things to keep in mind, are that the normal onKey and onTouch methods will not be called (their native equivalents will be instead), so if you need to be able to process input on the Java side, you’ll have to set up some JNI linkage to send the information from native to Java. I believe everything else is included in the official XPeria Play touchpad sample code (the additions to the AndroidManifest.xml and what-not).

    If you want to look at my project for reference, it is open-source and can be found at:

    http://www.paulscode.com/forum/index.php?topic=75.msg1540#msg1540

    Just click the “source code” link next to “XPeria Play Touch-Pad Example”. It may not be all that useful to you though, because it is a rather large project and may be difficult to find what you are looking for. If you have any problems, post a question on my forum there or email me, and I’ll be happy to help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in Java/.jsp to set the content type, etc... so that
Is there a way to set a custom content type page to a custom
Is there a way to get the Content-Type of the response or conversely set
BASIC QUESTION: Is there a way to set the mime-type (content-type) of elements inside
Is there any way to set focus to the document, i.e. the content area,
Is there a way to set the cell content and imagaView from: - (void)tableView:(UITableView
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there any way to set up a PendingIntent with the download manager? Or
Is there any way to set order by clause in HQL by run time.
Is there any way to set DPI (dots per inch) in case of PDFsharp?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.