Android - Disable right swipe from ACTION_PICK_WIFI_NETWORK screen - android

We have a commercial application that runs on an Android tablet. It is the activity that is launched on startup, and we have taken steps to prevent the user from access the android system. This includes removing the home and back buttons, as well as settings such as:
ContentResolver cr = getContentResolver();
Settings.Global.putString(cr, "policy_control", "immersive.full=*");
Settings.Secure.putInt(cr, "user_setup_complete", 0);
We have a new requirement to allow the user to connect to WiFi. For this, we would like to access the system wifi settings programatically, via an intent:
Intent intent = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK);
intent.putExtra("extra_prefs_show_button_bar", true);
intent.putExtra("extra_prefs_set_next_text", (String)null);
startActivity(intent);
This works great - allowing the user to do whatever is needed to establish the wifi connection, including a back button to get back to our app. However, I have found that if you swipe right from the left edge, the Settings navigation drawer opens, and now the user is able to access the android system.
Is there a way to prevent this drawer from opening? Maybe prevent swipe actions while this screen is up, but then to allow them when our application is on top?

We discovered a partial solution. If you include this extra with the intent:
intent.putExtra(":settings:hide_drawer", true);
It will successfully prevent the drawer from opening on this page. However, if you select any of the menu items (such as "Configure Wi-Fi" or "Advanced"), this causes a new intent to be sent, and the drawer is accessible again on these pages. Go back to the original WiFiSettings page from the sub setting pages, and the drawer is disabled again.
Looks like we may have to modify the Android source in order to get the behavior we are looking for.

Related

How can i call the menu power in android xamarin?

I want to show that with something like Android.Provider.Settings, to start a new activity
Unfortunately that will not be available to you
Here is a list of settings you could possibly launch within a new intent
https://developer.xamarin.com/api/type/Android.Provider.Settings/
power settings is not one of them.

How make a Android application that can't be closed

I'm developing an Android app for a company where those who will use it are the employees, for this reason the company asked me to develop an application that the user can not close, because if he will not use the smartphone for other purposes, but for this I need the Android native buttons do not interfere with the application.
I've deactivated the button to go back and put the application as Home.
#Override
     public void onBackPressed () {
         super.onBackPressed ();
     }
...
<category android: name = "android.intent.category.HOME" />
However if the user clicks the button that displays open applications, it can exit the application.
I researched a lot before creating resolve this question and realized several attempts to solve this problem.
One. I tried to create the same behavior as the MX Player has, when you use the lock to see a video, the MX Player is always on top of everything, leaving the user to see and click others places. However using this behavior does not i cant see My Dialogs nor Popup and also can not apply a thema, as in my case is not simply an activity is the entire application.
Reference links of my attempt
How to disable Home and other system buttons in Android?
http://www.piwai.info/chatheads-basics/
If anyone knows how to use that behavior MX Player, or if anyone knows any more how to make the user can not close the application, please help me, I know it's not just me who have this problem.
Any help is welcome!
My API is 16 - Android-4.1
Are your target devices rooted? If so, this article goes through the steps to make this possible. What you specifically ask about can be done by modifying the build.prop file to include the following line: qemu.hw.mainkeys=1. This will stop the soft-key navigation bar from ever showing up.
If the device you're running isn't rooted, I don't think that it's possible to do what you're asking.
The best way i found to the user can't access others apps, was to make a service that check which is the top activity, if don't is my then reopen my app.
ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTasks = manager.getRunningTasks(1);
if (runningTasks != null && runningTasks.size() > 0) {
ComponentName topActivity = runningTasks.get(0).topActivity;
if (!topActivity.getPackageName().startsWith("com.mypackage.")) {
Log.i("Top Activity", topActivity.getPackageName());
if (LocalCache.getInstance().isForceHome()) {
Intent intent = new Intent(HomeService.this, AuthLoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
handler.postDelayed(this, 500);
}
Old question, but I'm facing exactly same situation:
In-house App
Can't be close
I'm going to set App as a Launcher, and block top-dowm swipe to prevent status bar appear.
I think it's good enough for an in-house App ~

Closing intent selection dialog (after user selection)

I use an Navigation intent in my app like:
uri= String.format(Locale.ENGLISH,"http://maps.google.com/maps?daddr=%f,%f",latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
EventMapOfflineActivity.this.startActivity(intent);
Works perfectly, the user can select the app (s)he wants to start.
But, after the selection the dialog won't close itself and after returning to the app sometimes the user has to press the back button up to 4x to close that dialog.
So is there any way to get the Android OS to close that dialog?
Or do we have to respect that Android way of doing it?
I would do that in the onStop() Handler of my app which is called when the user selected an app to start in the dialog (with a flag set to true on the click to go to navi and resettet to false in the onStop() )
I just think that the Android OS would not like messing with its dialogs, or is there a CLEAN way to do this?
Thanks in advance
But, after the selection the dialog won't close itself and after returning to the app sometimes the user has to press the back button up to 4x to close that dialog.
This is most likely a problem with your firmware, either due to bugs from the device manufacturer or bugs in some modded firmware that you have installed upon your device.
So is there any way to get the Android OS to close that dialog?
Android automatically closes the dialog.

How do I undo clearPackagePreferredActivities("com.android.launcher");

What I am trying to do is replicate what the ToddlerLock app does. I have managed to clear the default launcher with
PackageManager localPackageManager = getPackageManager();
localPackageManager.clearPackagePreferredActivities("com.android.launcher");
and then open the launch select dialog with this
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.startActivity(i);
As long as the user checks the "use by default for this action" the home key now sends the user to my app, thus essentially disabling it.
I then use "clearPackagePreferredActivities("com.my_application")" when I exit my app and the user has to choose a new default home app.
My question is how can I choose the default home application (essentially checking the "use by default for this action" check box in code for the "com.android.launcher" package. That way the user does not constantly have to see that dialog box every time they open and close my app.
I think ToddlerLock does this somehow without using clearPackagePreferredActivities
because if I look at the "clear defaults" in the application manager it is not cleared and you only have to go through the set as default dialog box one time on startup and once when you exit to set it back to the normal home screen.
Thanks for your help.
I have implemented the same functionality in different way.
Let's say you have 'LockScreenAcitivity' configured as Home Screen in Manifest.
Launch LockScreenActivity by sending Home Intent.
Android will popup a dialog, to select the default Acitivity
choose your LockScreenActivity from List as default Activity
.....
.....
While closing the Activity don't clear the prefered Activities.
Disable your LockScreenActivity alone by calling PackageManager.setComponentEnabledSetting()
After you disable your LockScreenActivity, android will rollback to previous Prefered Activity (that's your old home screen ).
Next time when you launch your app,
enable your lockscreenActivity again by calling PackageManager.setComponentEnabledSetting()
Launch LockScreenActivity by sending Home Intent.

re-prompt to choose default activity

is there a way to reprompt the user to choose a default activity for an intent? For example, user selects his default home apk and I want him to reconsider his choice once again.
I know how to do that on 2.1 and before, but is there a way to do that now on 2.2?
Famous Home Switcher, which did similar thing, does not work on 2.2 anymore thanks to google team
This is how I represent the Activity selection dialog:
It start the android default ResolverActivity for "HOME" Applications.
Intent selector = new Intent("android.intent.action.MAIN");
selector.addCategory("android.intent.category.HOME");
selector.setComponent(new ComponentName("android", "com.android.internal.app.ResolverActivity"));
startActivity(selector);
The above code is working for my 2.2 enabled tablets.
When executed, it displays the "Complete Actions with:" dialog with all possible Home applications in the list.
A way to detect which is currently set by default you could ask for all preferred activities. The lists "filters" and "comps" contain the data when calling .getPreferredActivities(...).
filters - contains the intent filter data, which you could query what type of data it is.
comps - contians the component which would be called if the intent filter matches
This way you could check if your application is the current "home" application set as preferred by the user.
List<IntentFilter> filters = new ArrayList<IntentFilter>();
List<ComponentName> comps= new ArrayList<ComponentName>();
getPackageManager().getPreferredActivities(filters, comps, null);
For example, user selects his default home apk and I want him to reconsider his choice once again.
That is no longer possible, unless your app is the preferred one. Then, I think you can use clearPackagePreferredActivities() to remove yourself as the preferred choice.
In other words, you are welcome to affect your own app, but you are not welcome to affect other apps.

Categories

Resources