How to show the Unreal screen in Android's subview? - android

I want to know how to show the Unreal screen on Android's subview.
I apologize for my lack of English skills.
I want to show the Unreal screen in subView for Android-based projects.
I want to put it in a project created by a new project through Android Studio.
The start consists of Android native code, and several menus were all created using JetPack api.
Here, I want to configure the bottom with Android UI and the top with an Unreal screen.
Or, if you press the start button for UNREAL screen, I want to render the screen where the entire screen is UNREAL screen.
These two things should possible.
I knew how to do Unity.
Unity knows what is possible.
Is Unreal possible?
If possible, can I get help with the guide links such as documents and videos?

Try this as I assume that you have already added the Unreal Engine Viewport Client plugin to your project and that you have added a LinearLayout with the id
import com.epicgames.ue4.ViewportClient;
public class MainActivity extends Activity {
private ViewportClient mViewportClient;
private SurfaceView mSurfaceView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the Android View to display the Unreal Engine Viewport
mSurfaceView = new SurfaceView(this);
// Add the Android View to the layout
LinearLayout layout = findViewById(R.id.layout);
layout.addView(mSurfaceView);
// Create the Viewport Client and associate it with the Android View
mViewportClient = new ViewportClient();
mViewportClient.SetViewport(mSurfaceView);
// Configure the rendering settings for the Viewport Client
mViewportClient.SetResolution(1920, 1080);
mViewportClient.SetCameraPosition(0, 0, 1000);
mViewportClient.SetPostProcessingEnabled(false);
// Start the rendering loop for the Viewport Client
mViewportClient.Start();
}
#Override
protected void onDestroy() {
super.onDestroy();
// Stop the rendering loop when the activity is destroyed
mViewportClient.Stop();
}
}

Related

How to make my Unity 3d (AR) project play in a full screen on my phone?

Testing Augmented Reality made with Unity 3d and vuforia on my android device is not showing in full screen !
I have tried to change everything in unity player settings but nothing changed
i even tried to do a script for the AR Camera
public class fullscreen : MonoBehaviour
{
// Start is called before the first frame update
void Start() =>
// Toggle fullscreen
Screen.fullScreen = !Screen.fullScreen;
// Update is called once per frame
void Update()
{
}
}
but it didnt work
I want to show it in the full screen
check my imageon Android device
If your game is in fullscreen Screen.fullScreen = !Screen.fullScreen; will make your game not fullscreen anymore. Use Screen.fullScreen = true;
Then, under Project Settings -> Player -> Resolution and Presentation check Start in fullscreen mode.

How to load a specific layout of an activity in android

I am working on an augment reality android app. I developed the app in unity using vuforia and then imported it in android studio as i wanted to design it in android studio. The activity name in generated project structure is UnityPlayerActivity which has no layout in the project. The activity is passed to UnityPlayerclass and the layout is generated. This is some code of my UnityPlayerActivity activity.
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// Setup activity layout
#Override protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy
mUnityPlayer = new UnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
as it uses that layout how can i design that activity by referencing it.
It is not possible to do this by referencing the object(Java does not support call by reference).
You need to define a new function in UnityPlayer class that generates a layout and returns the LayoutParams object.
Then use the Layout inflator. Something like this:
LayoutParams mParams=mUnityPlayer.layoutGenerator() //some function to generate LayoutParams
LayoutInflator.getLayoutInflator().inflate(LayoutParams);
Finally i found an easy solution to my problem. I displayed the unity scenes in a subview using a framelayout and now i can customize the UI easily. Check here and here to see more information.

Flicking background image using Phonegap with Android

I've got an application that uses PhoneGap and it has a brackground image. My issue is that, even though I'm using the source, the image flicks a little bit. (It seems that Android and PhoneGap are taking different references of the screen to display the image).
This is the code:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
getWindow().setBackgroundDrawableResource(R.drawable.splash);
this.setIntegerProperty("splashscreen", R.drawable.splash);
super.setIntegerProperty("backgroundColor", Color.TRANSPARENT );
cna = new CustomNativeAccess(this, appView);
appView.getSettings().setAppCacheEnabled(true);
appView.getSettings().setRenderPriority(android.webkit.WebSettings.RenderPriority.HIGH);
appView.getSettings().setCacheMode(android.webkit.WebSettings.LOAD_DEFAULT );
appView.setBackgroundColor(0);
appView.setBackgroundResource(R.drawable.splash );
appView.clearCache(false);
super.loadUrl(url); // this is an external url so it takes a bit of time
}
as a temporary fix I have force the app to work in full screen, and in that way doesn't do the flicking as both (Android and PhoneGap) take as reference top 0,0.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
I'm using PhoneGap 1.6 and any help would be really appreciated.

Creating a Questionnaire in Android

Peace be on all of you!
I have to develop a questionnaire like small android app. There will be 10 questions with only 2 types of answers, i.e. either "Yes" or "No". When the user will answer all of the 10 questions, a report will be shown to user according to his answers.
Kindly tell me, how should I proceed? Do I need to use database (sqlite) or can work without it? and how should I start to develop this app?
I am new to Android.
Thank-you!
If you are new to Android, than use a web approach: Show a html page 1-10 in a webView and link it each other and finally the 10th is linked to an url, where you will do a http POST / GET with your collected 10 params. Exactly as how would you do in a "standard' web development. Also you can use several app to wrapp into Android app: Appcelerator, Phonegap and so on.
Here is a class which is a screen: (Android Activity)
public class Help extends Activity{
private WebView webViewHelp;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
webViewHelp = (WebView) findViewById(R.id.webViewHelp);
webViewHelp.loadUrl("file:///android_asset/ui/help.html");
}
}
you need the help.xml build and placed into /res/layout/ folder.
Also write the help.html and place it into: /assets/ui folder and not android_asset and at is not file:///assets/ui/help.html!
in this case you have the starting point set up, than go and load with html links the next next next ... until is done, than pust url.
Somewhat easyer if you are doing in android ui development, and not web-like, but that need a bit more experience

Android PhoneGap with Native Controls

I am trying to build an Android application with PhoneGap.
I need to be able to use the PhoneGap WebView (super.appView) and all of its javascript magic but I also need to display some native UI controls around the WebView.
This post goes part way to providing a solution Android PhoneGap Plugin, UI tabbar, resize WebView
Has anyone managed to implement PhoneGap with a native UI?
I will also be using a GestureOverlayView but thats another story ;)
Answer:
super.onCreate(savedInstanceState);
//creates super.appView and calls setContentView(root) in DroidGap.java
init();
//just an empty LinearLayout
layoutId = R.layout.blank;
view = new LinearLayout(this);
setContentView(layoutId);
view.addView(your_component_here);
view.addView((View) appView.getParent()); //adds the PhoneGap browser at index 1
//accesses the browser at index 1. Tells browser to not fill view
view.getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
setContentView(view);
I would struggle to tell you how this works, all I can tell you is that it does and it is all my own work.
Setting the view to a different colour can help you to see what is going on too....
view.setBackgroundColor(Color.BLUE);
Working with PhoneGap-1.0.0.jar the latest release so far.
A more cleaner approach:
super.onCreate(savedInstanceState);
// Create native view with UI controls.
View header = View.inflate(getContext(), R.layout.header, null);
// PhoneGaps WebView is located inside a LinearLayout.
// The protected (and therefore inherited) variable root
// references this LinearLayout. Add your native Views
// to this variable.
root.addView(header);
// Create WebView and add it automatically to the LinearLayout.
super.loadUrl("file:///android_asset/www/index.html");
Yes, you can embed native controls within HTML by using the plugin.
Call the native method which contains your native view from HTML page using plugin.
e.g. window.plugins.anatomyPlugin.showAudio();
I use this for showing audio player design in native.
This guide from PhoneGap may be helpful.

Categories

Resources