Making activity fullscreen in Android 4.0 - fullscreen

I've looked for it in many web sites. I wanna make my activity full screen in Android 4.0 (Whole screen with even virtual buttons and bar). There are many solutions even in Stack Overflow. Many of them are ticked as it works. However when I try these solutions, they don't work! I couldn't find where I am making the mistake. I'm giving an example code that was given as answer for my problem (it's worked as they said):
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}

This isn't enough:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
In order to accomplish what you want to accomplish, add this:
this.getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
I know this is a rather old question (with a bunch of duplicates), but this is found via Google so I figured I'd still post this solution.

Related

Tenant Not availalbe exception despite the use of the workaround

I have implented GetAllBusinessPartnerCommand and also customized the code in the BusinessPartnerServlet. When I try to call the application with the customized code, I always get this error.
Code GetAllBusinessPartnersCommand
package com.sap.cloud.s4hana.examples.commands;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import com.sap.cloud.s4hana.examples.BusinessPartnerServlet;
import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory;
import com.sap.cloud.sdk.frameworks.hystrix.HystrixUtil;
import com.sap.cloud.sdk.s4hana.connectivity.ErpCommand;
import com.sap.cloud.sdk.s4hana.datamodel.odata.helper.Order;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner;
import com.sap.cloud.sdk.s4hana.datamodel.odata.services.DefaultBusinessPartnerService;
public class GetAllBusinessPartnersCommand extends ErpCommand<List<BusinessPartner>>{
private static final Logger logger = CloudLoggerFactory.getLogger(BusinessPartnerServlet.class);
public static final String CATEGORY_PERSON ="1";
public GetAllBusinessPartnersCommand() {
super(HystrixUtil.getDefaultErpCommandSetter(
GetAllBusinessPartnersCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));
}
#Override
protected List<BusinessPartner> run() throws Exception {
// TODO Auto-generated method stub
return new DefaultBusinessPartnerService().getAllBusinessPartner()
.select(BusinessPartner.BUSINESS_PARTNER,
BusinessPartner.LAST_NAME,
BusinessPartner.FIRST_NAME,
BusinessPartner.IS_MALE,
BusinessPartner.IS_FEMALE,
BusinessPartner.CREATION_DATE)
.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_PERSON))
.orderBy(BusinessPartner.LAST_NAME, Order.ASC)
.execute();
}
#Override
protected List<BusinessPartner> getFallback() {
logger.warn("Fallback called because of exception:",
getExecutionException());
return Collections.emptyList();
}
}
n the following you can see the commands and the offered workaround for the problem set ALLOW_MOCKED_AUTH_HEADER=true. Before testing I checked if all variables are set correctly and set ALLOW_MOCKED_AUTH_HEADER=true again because I set it too early before.
After this steps i build my project like i always do and get the error from above when im calling the service. I also read this post where someone have the same problem and used the mentioned workaround. But this doesnt work for me and i have no clue why. TenantNotAvailableException, when trying to call business partner from s4 CF SDK
error when call page
Starting mock-server
set variables and workaround plus check
Unfortunately SAP Cloud SDK 2.x is no longer supported. Please use our migration guide to move to the latest version 3.43.0 You can find my blog post on this topic too. If you face any issues, please create another StackOverflow question (with tag sap-cloud-sdk) or comment to the blog post. For more details, please find our documentation.

Why is getOnBackPressedDispatcher() method unresolved until 'androidx.navigation:navigation-ui' is added as a dependency?

I'm trying to customize onBackPress behaviour of JetPack Navigation. Although I found the solution I'm just curious what's going behind the scenes in the following scenario:
Initial state of my activity is
MyActivity extends androidx.appcompat.app.AppCompatActivity {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getOnBackPressedDispatcher().addCallback(...); // <--- Method is unresolved
}
}
How come that after I add the following dependency to build.gradle the getOnBackPressedDispatcher() method is being resolved:
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
What's going behind the scenes? Does it have something with the Jetifier? Does it alter the classes based on declared dependencies or something similar?
implementation 'androidx.appcompat:appcompat:1.1.0'
Implement this dependency to its latest version, this will fix the problem.

Notification Bar does cut my views

I have a really strange behaviour on my nexus 4 (running android 4.4).
Although I set these Flags in my MainActivity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
activity.getActionBar().hide();
My Views (e.g. DialogFragments) do get cut by the invisible NotifictaionBar, see the attached Screenshot at the top.
Does anybody have a hint for me what to do, which flags I have to set?
Thanks in advance.
So I figured it out: In this post there is the answer: https://stackoverflow.com/a/20281449/855950
I had to set this flags in my MainActivity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getActionBar().hide(); //Be carefull of target API
in the OnCreate of my DialogFragment this line (to hide the Title)
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog);
and in the onCreateView of my Dialog this line:
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Works for me :)

How i can use jfreeChart with Javafx2

For a JavaFX2 Application I have to show different types of Charts.I am using jfreeChart for Charts creation and code given below:
public static JFreeChart generatePieChart() {
DefaultPieDataset dataSet = new DefaultPieDataset();
dataSet.setValue("China", 25);
dataSet.setValue("India", 25);
dataSet.setValue("United States", 50);
JFreeChart chart = ChartFactory.createPieChart(
"World Population by countries", dataSet, true, true, false);
return chart;
}
This returns me a chart object. How can I integrate this with my JavaFx Node like HBox etc.?
This answer discusses a few different approaches for chart integration in JavaFX.
Using the FXGraphics2D bridge to paint JFreeChart
David Gilbert (JFreeChart creator) created a bridge which allows a JFreeChart to be painted using JavaFX primitives. The project is FXGraphics2D:
FXGraphics2D is a free implementation of the Graphics2D API that targets the JavaFX Canvas. The code has been developed for the use of Orson Charts and JFreeChart, but will be generally useful for any code that uses the Graphics2D API.
FXGraphics2D requires JDK 1.8.0 or later and is licensed under the terms of a (three clause) BSD-style license.
See the FXGraphics2D site and the answer to Interoperability between Graphics2D and GraphicsContext for more information.
David notes in a comment on another answer:
FXGraphics2D is now integrated directly in JFreeChart (at version 1.0.18) so JavaFX support is now included (requires JDK/JRE 1.8).
Solution Embedding JFreeChart in JavaFX
Use a SwingNode from Java 8 to embed Swing based content such as JFreeChart in JavaFX applications.
import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.*;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.jfree.chart.*;
import org.jfree.data.general.DefaultPieDataset;
public class JFreeChartSwingNodePopulationPieChart extends Application {
#Override public void start(Stage stage) {
final SwingNode chartSwingNode = new SwingNode();
chartSwingNode.setContent(
new ChartPanel(
generatePieChart()
)
);
stage.setScene(
new Scene(
new StackPane(
chartSwingNode
)
)
);
stage.show();
}
private JFreeChart generatePieChart() {
DefaultPieDataset dataSet = new DefaultPieDataset();
dataSet.setValue("China", 1344.0);
dataSet.setValue("India", 1241.0);
dataSet.setValue("United States", 310.5);
return ChartFactory.createPieChart(
"Population 2011", dataSet, true, true, false
);
}
public static void main(String[] args) { launch(args); }
}
Alternative Solution Using JavaFX Charts
Use JavaFX's own charting framework.
JavaFX charts do not cover exactly the same functionality as JFreeChart, but are excellent for many applications.
The default pie chart code posted in the question can trivially be replicated in JavaFX using JavaFX charts, eliminating the need to use an external library for such charts.
import javafx.application.Application;
import javafx.collections.*;
import javafx.scene.*;
import javafx.scene.chart.*;
import javafx.stage.Stage;
public class JavaFXPopulationPieChart extends Application {
#Override public void start(Stage stage) {
final PieChart chart = new PieChart(
FXCollections.observableArrayList(
new PieChart.Data("China", 1344.0),
new PieChart.Data("India", 1241.0),
new PieChart.Data("United States", 310.5)
)
);
chart.setTitle("Population 2011");
stage.setScene(new Scene(chart));
stage.show();
}
public static void main(String[] args) { launch(args); }
}
On JavaFX and JFreeChart Functional Comparisons
If only there were support for error bars. Without them, the charting framework has much less value for science apps.
The JavaFX Advanced Candlestick Chart from Oracle's Ensemble Sample Application demonstrates how to use JavaFX to build a candlestick chart. Even though error bars are different from candlesticks, I think the implementation of a custom error bar chart would be quite possible using the existing JavaFX charting library and the code would end up similar in many ways to the Ensemble candlestick chart sample.
But sure, the point is still valid, some things such as error bars are currently going to be easier to achieve leveraging a mature library such as JFreeChart.
As Alexander points out, if there is required functionality missing from the standard JavaFX charting framework which looks like it would be applicable to a wide range of users, then it is best to file a feature request to get the functionality embedded into the standard library. Though some kinds of advanced chart features are probably best handled by a 3rd party extension library for JavaFX charting (of which there are none currently available that I know of).
It is now possible to display a JFreeChart instance on a JavaFX Canvas using FXGraphics2D, a free implementation of the Graphics2D API for JavaFX.
JFreeChart is Swing-oriented - while the JFreeChart class itself is not a Swing component, it is typically displayed on a org.jfree.chart.ChartPanel, which is a subclass of javax.swing.JPanel. It uses a ava.awt.Graphics2D object to draw itself.
I suppose that you could use the createBufferedImage() method of JFreeChart to get a BufferedImage, and then use SwingFXUtils to convert it to a javafx.scene.image.WritableImage, but then you'd lose the interactive nature of the chart.
Unfortunately, at the moment, there doesn't seem to be any way to embed a Swing component in JavaFX
making this:
chartSwingNode.setContent(
new ChartPanel(
generatePieChart()
)
);
brings this error only when running (the code compiles):
>
Exception in thread "AWT-EventQueue-0" java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key Save_as
at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
at java.util.ResourceBundle.getString(ResourceBundle.java:407)
at org.jfree.chart.ChartPanel.createPopupMenu(ChartPanel.java:2785)
at org.jfree.chart.ChartPanel.(ChartPanel.java:577)
at org.jfree.chart.ChartPanel.(ChartPanel.java:523)
at org.jfree.chart.ChartPanel.(ChartPanel.java:426)

Making a servlet "Public"?

I finally got my test servlet working from this thread?
Calling HttpServlet class from xpages client side script and regular notes forms?
The issue that remains is I am being asked to login. But my final servlet will need to run without logging in. I have my acl set to Read public document and Write public documents for anonymous.
What I don't know how to do is to make the serlet public access. Other design documents have an "Available to Public Access users" property but I am seeing no such property for java files. Would this be set somewhere else? Maybe in my IServletFactory perhaps?
I don't know why I was required to log in before but it looks like it is now working. The only thing that is requred is that Read Public Public Document be enabled.
This is a bit concerning since it at least appears there is no way to make some servlets non-public. In my case it won't be an issue but it could be an issue for others.
Also what I noticed is that if you change the Public Access acl setting, it looks like you need to rebuild your servlets for some reason or the servlets won't run. When I get a chance I will open a ticket with notes support for both of these issues.
For those wanting to execute a servlet, I suggest this article:
http://8b30b0.wordpress.com/2013/02/04/creating-a-basic-domino-servlet/#comments
But here is a much more simplifed version of IServletFactory that might be easier to understand and get working.
package test;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import com.ibm.designer.runtime.domino.adapter.ComponentModule;
import com.ibm.designer.runtime.domino.adapter.IServletFactory;
import com.ibm.designer.runtime.domino.adapter.ServletMatch;
public class TestFactory implements IServletFactory {
private ComponentModule module;
public ServletMatch getServletMatch(String contextPath, String path)
throws ServletException {
System.out.println("TestFactory:getServletMatch");
String servletPath = "";
String pathInfo = path;
return new ServletMatch(getWidgetServlet(),servletPath,pathInfo);
}
public void init(ComponentModule arg0) {
System.out.println("TestFactory:init");
this.module = arg0;
}
public Servlet getWidgetServlet() throws ServletException {
return module.createServlet("com.pnc.cld.HelloWorld", "testServlet",null);
}
}

Resources