Is there a way to disable the "keyboard-dismiss" button? - java

Is there a way to disable/hide this keyboard-dismiss button and keep the soft-keyboard open?
I want to have the default back-button there and when that button is pressed it should finish() my activity without having to dismiss the keyboard first.
I have tried this: android:windowSoftInputMode="adjustResize|stateAlwaysVisible" in my manifest file, but that didn't do what I expected.

I decided that I shouldn't mess with the Android standard meaning and I have chosen to let the users dismiss the keyboard if they wish to.

Use the android:windowSoftInputMode="stateHidden" in your activity in manifest file. This will work.

Related

Display activity as a popup window

I have a service that starts an activity as a dialog/popup window from my app. It works generally ok.
When my app is closed (not in recents), the popup will overlay any underlying app with a transparent surrounding background.
But the issue comes when my app was minimized in the background and I'm using another app, then I click on the service button to display the popup, it brings my app back into the front with the popup over my app (not the previous third-party app).
How can I prevent this behavior and make my activity overly any window regardless of my app's state?
This is the theme I'm using
<style name="PopupTheme" parent="Theme.AppCompat.Dialog">
</style>
If the popup dialog has nothing to do with your app (and you want it to be separate and distinct from your app in case your app is already running), then you want to do the following:
In the manifest, set the taskAffinity for this dialog-themed Activity to an empty string, set the excludeFromRecents flag and the noHistory flag like this:
<activity android:name=".DialogThemedActivity"
android:taskAffinity=""
android:excludeFromRecents="true"
android:noHistory="true"
... />
Declaring the Activity like this ensures that it is not associated with any existing task that your app is currently in. It also ensures that this task will not end up in the list of recent tasks (so that the user doesn't accidentally start the Activity again from the list of recent tasks) and that the task will be deleted as soon as the user navigates away from the dialog-themed Activity.
Now, in your Service, make sure that when you launch the Activity you add FLAG_ACTIVITY_NEW_TASK:
Intent intent = new Intent(this, DialogThemedActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
This is the correct way to do this.
Just found it out. Simply adding this flag to the launching intent
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

How to make custom text selection dialogue in android

How to Highlight text in android TextView like this?
& also how to show a custom dialogue on text selection?
I Have Tried with TextView default property
android:enabled="true"
android:textIsSelectable="true"
android:focusable="true"
android:longClickable="true"
But By Using this it only show default share and copy option from android.
You can set the hilight by calling setSelection on the TextView. As for the dialog- you can add to it, but you can't remove from it. The way to add to it is to create an Activity with an intent filter that makes it catch the PROCESS_TEXT action. That will automatically make Android add your app to the copy paste bar with the name of your app, and allow users to click on it to perform whatever transformation you wish.
Please note that this will occur in every app, not just your own. I don't know of a way to make it specific to your app.
So for example the "Tweet" option on your bar there is because you have twitter installed. Delete it and the option would disappear. There's no other way, other than to totally turn off that menu and build your own version.

How to create a fully unclosable ProgressDialog?

How to show a ProgressDialog from a background service that is unclosable in any way, displayed above whole screen, above any app, including keys? I mean a dialog exactly like the "Power off.. shutting down" one that is displayed when phone is shutting down, when you can neither do anything to make it disappear nor click anything below it.
PS. If the app needs to be a system app to create such dialog, that's not a problem for me.
Use this
ProgressDialog.setCancelable(false);
Create a full screen activity Using full screen Activity prevent back navigation by overriding onBackPressed()
Disable back button in android

Working with DIalogs in Fragments

In my application, I have the Activity and several Fragments (Activity works as Controller and Fragments - as views)
In some of Fragments I need to show AlertDialogs and ProgressDialogs, Activity can change current Fragment.
My problem is: activity can receive broadcasts and C2DM notifications, and when I created AlertDialog, Activity can change fragment, but Dialog stays. So when user clicks on some buttons, app crashes.
DIalogFragments works like a simple Dialog.
Have I dismiss dialog manually or check if fragment is active? Is there any built-in tools?
First of all I might be missing something, no code etc to go by but...
Secondly: maybe you shouldn't be using dialoges? Seems like a cumbersome user interface. Just use fragments for those as well? Though you say you are using DialogFragments so maybe you've already thought about that and use them as "regular" fragments already.
Thirdly: Dismiss the dialogs when the fragment that showed is removed/hidden then? Use the onStop() callback for example in the fragment or a more central place where you are perhaps saving the currently showing fragment and deciding to display a new one.
Dismiss the dialog by calling ´dismiss´ on the Dialog object or Fragment or dismissDialog in the Activity.
See dismissing dialog: http://developer.android.com/guide/topics/ui/dialogs.html#DismissingADialog
You can still call dismiss on those DialogFragments.
http://developer.android.com/reference/android/app/DialogFragment.htm

Why doesn't my Android activity refresh/redraw?

RoomInfoActivity.java: http://pastebin.com/L9fFsFeH
(note: this is the 3rd activity launched by the same application, not that it should matter..)
AndroidManifest.xml: http://pastebin.com/QbvQaTf3
room_info.xml: http://pastebin.com/DFNABSNF
Image: http://dl.dropbox.com/u/16952797/temp_stuff/elfapp_ss04.PNG
(note: when I click on the button, "nothing" happens.)
Description: So what happens is the code compiles just fine, and the .apk is launched and run without any issues, but the RoomInfoActivity doesn't reflect the changes that are supposed to be made (such as changing the text of the TextViews and Button) when I click on the button. I'm looking for the least complicated way to do these.
EDIT: I have now made a change, I added this line buttonCleaned.setClickable(true);
under this:
rumInfo.setText(getIntent().getExtras().getString("entry"));
buttonCleaned.setText("Färdig med städningen");
rumStatus.setText("Status: "+checkStatus());
Is your onClick() method ever called? I think you need to set the Activity as a click listener on the button, using the setOnClickListener method.

Categories

Resources