I want to show a black screen in the task manager preview under Ice Cream Sandwich, like the German 'finanzstatus' app does. It would be nice if someone could point me in the right direction.
Using FLAG_SECURE will block your app from screenshots, including the recent tasks list:
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);
}
}
Related
Using the code below I prevent users taking screenshots of my app. I want to implement "enable screenshot button". Is it possible? Which concept should I use?
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);
}
}
You could restart the activity and this time not set the SECURE flag.
In my app, I have a switch in settings to enable or disable the secure flag. Then I simply do not set it if the settings specifies that I am allowed to take screenshots.
I'm developing an app that uses the sensor accelerometer. I want the display to go black for instance when a value reach 8.1 and go back to normal when 7 is reached. Is it possible without using screen brightness? I want it to be complete black and this is not possible what i know with screen brightness.
Hope I gave enough information.
Try this in your activity. Let your main.xml load a black image -
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Since you also need the screen to be black while you are using other apps. Then you need to write a background service that receives the accelerometer values and when it reaches 8.1, you can use the above snippet of code in your service.
As per security concern screenshots of my app screen should not be shown in recent apps.
I have tried adding android:excludeFromRecents="true" in all activities on the manifest file. However, screenshots are shown in recent apps, can some help me to solve this issue?
excludeFromRecents excludes from recents which is not what you need. Try setting FLAG_SECURE:
public class MyActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main_layout;
}
}
I am using API 10 GingerBread
I am not using a layout, although I did try this with a layout and it still doesn't work. Works fine with a normal Activity subclass, I don't see what the problem is.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.ic_launcher);
For what it is worth, using FEATURE_NO_TITLE works fine. What gives? Anybody have any suggestions?
Try this code...
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.main); //or whatever layout is shows
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.ic_launcher);
I found bunch of samples how to remove title/notification bar on Android. However, it's still not a full screen.
I still see a panel on my table with search, home, back and some other button.
Do you have any ideas how to hide this panel?
Generally speaking, I want kind of kiosk mode.
Use this code in onCreate of activity:
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
Sample code for a fullscreen activity:
public class HellofullActivity extends Activity {
/** 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);
setContentView(R.layout.main);
}
}
where you request that the window has not the green title bar and take full screen.
The core problem was device specific. I was doing development for Archos and Archos has it's own bar, which isn't not removed by FLAG_FULLSCREEN and FEATURE_NO_TITLE