requestWindowFeature(Window.FEATURE_NO_TITLE) ERROR - android

I'm having trouble putting my application fullscreen in Android Lollipop, my code :
public class AoA extends ActionBarActivity {
protected void oncreate(Bundle savedInstanceState) {
super.onCreate(SavedInstanceState);
setupParameters();
}
public void setupParameters() {
GameParameterSingleton.ORIENTATION = GameParameterSingleton.PORTRAIT;
GameParameterSingleton.SCREEN_HEIGHT= getWindowManager().getDefaultDisplay().getHeight();
GameParameterSingleton.SCREEN_WIDTH = getWindowManager().getDefaultDisplay().getWidth();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
The application works when I do not use fullscreen,
Can anyone help me as I leave fulllscreen ? as I take the title of the application?

It seems that in API 21
this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
Doesn't work .
Try to Add this to your AndroidManifest.xml file
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Or add this
this.getActionBar().hide();
in onCreate method after super.onCreate(savedInstanceState);

Related

How to apply light(day) theme at run time (programatically) on Android

When the Android device set to dark mode.
But the user wants to see Light mode only on this app.
Is there any idea to handle this?
This code does not work for me
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
none of these codes is working
val config: Configuration = resources.getConfiguration()
config.uiMode = Configuration.UI_MODE_NIGHT_NO
resources.configuration.uiMode= Configuration.UI_MODE_NIGHT_NO
applicationContext.createConfigurationContext(config)
resources.updateConfiguration(config, getResources().getDisplayMetrics())
I would like to see the method too, where you set once for all your activities. But as far I know you have to set in each activity before showing any views.
For reference check this:
http://www.anddev.org/applying_a_theme_to_your_application-t817.html
Edit (copied from that forum):
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Call setTheme before creation of any(!) View.
setTheme(android.R.style.Theme_Dark);
// ...
setContentView(R.layout.main);
}
Edit
If you call setTheme after super.onCreate(savedInstanceState); your activity recreated but if you call setTheme before super.onCreate(savedInstanceState); your theme will set and activity does not recreate anymore
protected void onCreate(Bundle savedInstanceState) {
setTheme(android.R.style.Theme_Dark);
super.onCreate(savedInstanceState);
// ...
setContentView(R.layout.main);
}

Hide/remove status bar from android source code (Android 6.0.1)

I'm new to this forum, and first of all, i apologize for my English,
I have a question about Android 6.0.1,
I'm customizing the operating system with the source codes for the IMX6 board.
It's possible to remove or hide the "status bar" (notification bar) on the top of the operating system by editing the build.prop file or others files?
Thank you in advance,
public class WelcomeActivity extends AppCompatActivity{
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcome);
}
}
write this code in activity's onCreate method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.activity_splash);
}

Can screenshot's be disabled in an android app?

I am curious to know if screenshots can be disabled when running a android app if I were to design one.
You are welcome to use FLAG_SECURE to block screenshots and thumbnails of your activities:
public class FlagSecureTestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}

Android ActionBarSherlock ProgressBar always Indeterminate

I've got an activity that extends SherlockActivity but the progressbar is always indeterminate, even without setting it to true or after setting it to false.
I've already checked the import:
import com.actionbarsherlock.view.Window;
The activity in fact extends Sherlock:
public class MyActivity extends SherlockActivity {
Here is the onCreate method:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminate(false);
setSupportProgressBarIndeterminateVisibility(false);
In no place I set it to true, but it still appears without leaving.
The manifest:
<activity
android:name=".activities.MyActivity"
android:screenOrientation="portrait" >
</activity>
Any ideas of what might be causing this?
Thank you!
I am just enabling and disable the ActionBarShareLock ProgressBar.
Not sure but might be helpful to you.
Below is my code:
public class IndeterminateProgress extends SherlockActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
//This has to be called before setContentView and you must use the
//class in com.actionbarsherlock.view and NOT android.view
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.iprogress);
findViewById(R.id.enable).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
setSupportProgressBarIndeterminateVisibility(true);
}
});
findViewById(R.id.disable).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
setSupportProgressBarIndeterminateVisibility(false);
}
});
}
}
Updated
have you try with this:
getSherlock().setProgressBarIndeterminate(indeterminate);
OR
getSherlock().setProgressBarVisibility(visible);
I mean try with call getSherlock() before going to Ideterminate or change its visibility.
Let me comment of result.
Hope this will help you.
Try out as below:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.browser);
setProgressBarIndeterminateVisibility(true);
setProgressBarVisibility(true);
findViewById(R.id.enable).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
setProgressBarIndeterminateVisibility(false);
setProgressBarVisibility(false);
}
});
}
Well,
I can't find an explanation for why it is always indeterminate.
Also, this definitely is not working
getSherlock().setProgressBarIndeterminate(false);
However using
getSherlock().setProgressBarIndeterminateVisibility(false);
seems to solve the issue.
do this
just before you declare your activity view pass the progress bar and after defining your view disable the visibility of the progress bar then on your whatever click enable the visivility of the bar
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.yourlayout);
setSupportProgressBarIndeterminateVisibility(false);
......
......
.........
...OnClick()
{
setSupportProgressBarIndeterminateVisibility(true);
}
.............
It was the same problem I had and it taken me 5 hours to debug ABS to investigate the problem. The solution is very simple:
Use:
com.actionbarsherlock.view.Window.FEATURE_INDETERMINATE_PROGRESS
Like:
requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_INDETERMINATE_PROGRESS);
Instead of:
android.view.Window.FEATURE_INDETERMINATE_PROGRESS

CCGLSurfaceView Error

I'm developing some sample code.
I had some problem using cocos2d.
That is the CCGLSurfaceView problem.
Firstly, I imported cocos2d.jar in my project with fps_images.png file.
And i modify my project for using the cocos2d library.
Here are the code.
public class ToadActivity extends Activity {
protected CCGLSurfaceView _glSurfaceView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_glSurfaceView = new CCGLSurfaceView(this);
setContentView(_glSurfaceView);
}
#Override
public void onStart()
{
super.onStart();
CCDirector.sharedDirector().attachInView(_glSurfaceView);
CCDirector.sharedDirector().setDisplayFPS(true);
CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
}
}
==>>> _glSurfaceView = new CCGLSurfaceView(this);
Here, My application found a error. And at the result, it is killed in my android simulator.
What's the problem?
That library are decreated, not update more. It will be better start using: http://www.cocos2d-x.org/. It use c++, to work on android, use JNI (Native code). Code can be ported to other plataforms, like IOs.
Hope it help!

Categories

Resources