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.
Related
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.
I made 2 activities.
e.g] MainActivy and MediaActivity.
If user click home button in MediaActivity, App will hide.
I want launch MediaActivty again when screen on.
Open the gmail app, tap on an email to show it's contents. You have now gone from one activity (email list) to another (email details). Press the home button. Now open the gmail app again. Voila! You have returned to the email you selected.
What you ask for is the default behavior of an Android app. Unless you do something like call finish() in your onPause() method in MediaActivity you should return to MediaActivity when you open the app again.
If your app doesn't behave like this I suggest that you post some code.
Try to write your activities the following way :
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Put your own code here.
}
}
public class MediaActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Put your own code here.
}
}
What you're asking is Up Navigation / Ancestral Navigation(if I understood it correct). Refer to this guide: http://developer.android.com/training/implementing-navigation/ancestral.html
Othewise, if you want to have multiple instances of an activity, it's android:launchMode property should be set to standard in manifest. Refer:
http://developer.android.com/guide/topics/manifest/activity-element.html
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 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);
}
}
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