I want to show Android's InputMethodPicker for a fixed time and if the user does't interact with it, close it.
After opening with InputMethodManager's showInputMethodPicker method I was wondered how to close it programmatically.
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker
I have tried simulating backPress but it closes the calling activity instead.
Thanks.
This is my solution that works perfectly
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(intent);
this can used for various system dialog
Related
Please Please read the question complete before marking it as duplicate or vague
On clicking of a button I want to redirect the user to accessibility settings of the android mobile. Where user can click on the accessibility settings of the application. Here is the code that I am using for the same:
Intent dummyIntent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(dummyIntent, 1);
Problem: When user clicks on, I want that it should redirect back to my application and should not remain on the accessibility screen itself.
It's quite late but i had to make the same stuff. So my suggestion is to use onServiceConnected() overridden method in class that extends AccessibilityService . When user apply accessibility in the settings you can launch intent to desired activity inside onServiceConnected(). But you should keep in mind that after device reboot onServiceConnected() also called, so use some flag to make sure that is not user action.
try this :
Intent dummyIntent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
ActivityContext.startActivityForResult(dummyIntent, 1);
After showing the webbroser with this code :
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
How to close it programatically ?
How to close it programatically ?
You can't.
It's not under your control. A new activity has been launched and you must wait for the user to stop interacting with it (for example, when they click the back button) for control to return to your activity.
If you want fine-grained control you should probably look at embedding a WebView in your own activity or fragment, then you have full control over opening and closing it.
If you mean the Browser App, you may close it by code finding his PID and killing it but is discouraged.
Read this post
Hi in my app I have a dialog that asks if they would like to turn on my accessibility service if it is off. If they hit okay it launches an intent to open to accessibility like this
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(intent, 0);
This works fine however if they hit home from accessibility and then open my app again it doesn't show the dialog or anything but opens directly to accessiblity everytime. The only way to get around it is to hit back till I'm back at my home screen then reopening the app no longer opens to accessibility.
Why does it keep launching my old intent unless I back out? Why can't I hit back and then it not launch the intent again
Thanks for any help
Use flag FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivityForResult(intent, 0);
However if the user launch your app from the history list, it will still show up.
I think the problem is that your activity is still waiting for a result.
If so, calling forceFinish() in your onResume() should fix the problem.
http://developer.android.com/reference/android/app/Activity.html#finishActivity%28int%29
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.
Im developping an Android Service in Android that needs to pop-up a new dialog box for confirmation.
I can popup a new activity using Intent and Context
Intent myIntent = new Intent(context, ConfirmationActivity.class);
But then I need to handle the option selected in the dialog box (OK or Cancel).
Any suggestion?
Note: Not developing for smartphones.
Update: I need to return the result to the place I call the Dialog.
A service should not pop up anything at all. Imagine the user is in the middle of a phone call when your dialog pops up.
If you need a confirmation from the user the best thing you can do is to use the NotificationManager and use a PendingIntent to launch an Activity. The Activity can still have a dialog style if you like.
Control flows back from the Activity to your Service then, so when the user presses ok or cancel you would either call a bound interface or use SharedPreferences to tell the service about the user's choice.