w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Android - cannot capture backspace/delete press in soft. keyboard
What if you checked for like the decimal number for the backspace character? I think its like '/r' (decimal number 7) or something, at least for ASCII. EDIT: I guess Android uses UTF-8, so this decimal number would be 8. http://www.fileformat.info/info/unicode/char/0008/index.htm

Categories : Android

backspace and delete button does NOT delete characters in a textarea on IE
Keycode 9 is tab. Check here: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes You want 8 and 46, so something like: if (e.which == 8 || e.which == 46) return false;

Categories : Javascript

Implementing Backspace and Enter Keys on a Qt Virtual Keyboard
Consider MyInputPanelContext::sendCharacter function in the linked example. When QKeyEvent keyPress object is constructed, character.unicode() is used as the second argument. However, you can also use Qt::Key values as the second argument. For example: QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); You should rewrite this method to accept int argument that will be passed to QKeyEvent constructor and change characterGenerated(QChar) signal to keyGenerated(int) so you can send a special key (Qt::Key_Backspace) or a character key (character.unicode()) using the same signal and slot.

Categories : C++

Backspace does not delete dashes
if(n.length == 3 || n.length == 7 || n.length == 13){ s="-" } When you backspace the dash, the length is 3 again, so the dash gets added. You are going to have to check if the last key the user pressed is backspace, like var lastKeyIsBackspace; if(!lastKeyIsBackspace && (n.length == 3 || n.length == 7 || n.length == 13)){ s="-"; } Then, check if the key was backspace in your key handler: function forceNumber(e) { var keyCode = e.keyCode ? e.keyCode : e.which; if((keyCode < 48 || keyCode > 58) && keyCode != 8 && keyCode != 188 && keyCode != 189) { return false; } // check if the key was backspace (key code 8) if (keyCode == 8) lastKeyIsBackspace = true; else lasyKeyIsBackspace = false; return true; }

Categories : Javascript

Input box and text vanish on backspace/delete in IE8
Its been mentioned elsewhere that IE10 compatibility mode handles onpropertychange wrong. Dunno if that's the case but FWIW it works for me in IE8 vanilla.

Categories : Javascript

Backspace to delete whole word (entity) instead of each letter/character
You need to look into the listeners for editing text. Then, when the user presses backspace, delete till you find a space by maybe using a lastIndexOf() method. So, you getText() from EditText, you substring() it till the last space character, take that substring and set it as the new text

Categories : Android

Getting deleted character or text on pressing delete or backspace on a textbox
You could use the keydown event handler instead so that the last character to be deleted is still available: $('textarea').on('keydown',function(e) { var deleteKeyCode = 8, value = $(this).val(), length = value.length, lastChar = value.substring(length-1, length); if (e.which === deleteKeyCode) { alert(lastChar); } });

Categories : Javascript

I want to take only alphabets, backspace, delete and space in a text field in java swing platform
The problem with your code is on the (: Instead of: if (!(Character.isAlphabetic(c)) || (c==KeyEvent.VK_BACK_SPACE) || (c==KeyEvent.VK_DELETE) || (c==KeyEvent.VK_SPACE)){ getToolkit().beep(); evt.consume(); } Change it to: (Look closely at the parenthesis) if (!((Character.isAlphabetic(c)) || (c==KeyEvent.VK_BACK_SPACE) || (c==KeyEvent.VK_DELETE) || (c==KeyEvent.VK_SPACE))) { getToolkit().beep(); evt.consume(); } This !(Character.isAlphabetic(c)) will return TRUE for space. Note the early )!

Categories : Java

Adding my own keyboard instead of default keyboard in Android device as input
You should first take a look here. Then continue with this thread here, as stated there: Some tips: Read this tutorial: Creating an Input Method clone this repo: LatinIME An inputMethod is basically an Android Service, so yes, you can do HTTP and all the stuff you can do in a Service. You can open Activities and dialogs from the InputMethod. Once again, it's just a Service. Here's another tutorial on the topic. I hope all this is helpful for you. Cheers

Categories : Android

Android: Numeric key register backspace pressed
You need to implement your own EditText and override the method onKeyPreIme(): @Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // Do whatever you want to here. return true; } return false; }

Categories : Android

Android - backspace key does not issue onKeyDown callback
You can try to catch back key and use this method which is triggered when back is pressed. http://developer.android.com/reference/android/app/Activity.html#onBackPressed() You can use super.onBackPressed(); in your method or you can override it to do other things when clicked @Override public void onBackPressed() { // your instructions }

Categories : Android

how to capture backspace key code in android browser - javascript?
input change event $('#myinput').bind('input', function(){ // code }); backspace $('#myinput').on('keypress', function() { //code }).on('keydown', function(e) { if (e.keyCode==8) { //code } });

Categories : Javascript

Delete that particular username from .txt file when browser of that user is closed
There's no sure-fire way to tell if the user has closed his or her web browser. Trying to catch such an action w/ JavaScript will undoubtedly lead to bugs. The only thing you can do is delete said usernames after a pre-defined period of inactivity. If the user hasn't carried out any actions within the pre-defined timeframe, assume that they are inactive.

Categories : PHP

How do I delete field values of a table once window is closed?
The best way to do this is to use cron. Code the php script that will do the clean up and set up cron to run it every x minutes, hours to run it for you. http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/ Another option could be using ignore_user_abort() depending on how exactly you want to remove the data from the offender table http://php.net/manual/en/function.ignore-user-abort.php

Categories : PHP

Restricting Android NumberPicker to Numeric Keyboard for Numeric Input (not Alpha keyboard)
I have successfully achieved this, borrowing heavily from @LuksProg's helpful answer to another question. The basic idea is to search for the EditText component of the NumberPicker and then to assign the input type as numeric. First add this method (thanks again to @LuksProg): private EditText findInput(ViewGroup np) { int count = np.getChildCount(); for (int i = 0; i < count; i++) { final View child = np.getChildAt(i); if (child instanceof ViewGroup) { findInput((ViewGroup) child); } else if (child instanceof EditText) { return (EditText) child; } } return null; } Then, in my Activity's onCreate() method I call this and set the input type: np.setMinValue(0); np.setMaxValue(intensityStrings.length-1); EditText

Categories : Android

deleting a selected option from a select box using the "delete" key on the keyboard
You attach an event handler to onkeydown, you check for the delete key, you get the current value, you find the option with that value, you remove the option. http://jsfiddle.net/KgPBr/2/ $("#list").keydown(function(event) { if(event.which != 46) // not delete key return; var sel = $(this); var val = sel.val(); if(val != "") sel.find("option[value="+val+"]").remove(); }); edit Here's the plain JavaScript version, it may be less compatible with all browser than the jQuery version. http://jsfiddle.net/9cwyx/ document.getElementById("list").onkeydown = function(e) { var evt = e ? e : event; var sel = evt.target ? evt.target : evt.srcElement; if(evt.keyCode && evt.keyCode == 46 || evt.which == 46) { var val = sel.value; var opts =

Categories : Javascript

MacOS, how to delete unused service item in Keyboard Shortcuts
Look in ~/Library/Services or /Library/Services In the Finder, ~/Library is now an invisible folder by default in Mountain Lion. Of course, people can google for "Mac show hidden files" and find a command to enter into the command-line to make all files and folders visible. As a programmer, I like being able to see everything. Unix Command: defaults write com.apple.Finder AppleShowAllFiles TRUE Reference: http://osxdaily.com/2009/02/25/show-hidden-files-in-os-x/

Categories : Osx

EditText hidden by keyboard when android:gravity="center" - Android
I recently dealt with this issue on a Nexus 7 phone. The behaviour didn't otherwise occur on any of our other test phones. The trick seems to be to change the focus BEFORE you close the softkeyboard. The keyboard is closed at 3 points - clicking the Done button, clicking outside of the edittext box, and clicking the back button. First, create a hidden element to eat your focus <MyEditText android:id="@+id/editHidden" android:layout_width="0dp" android:layout_height="0dp" android:layout_below="@id/imageLogin" /> I stored this but it's a bit ugly... @Override protected void onResume() { super.onResume(); Utils.focusable = findViewById(R.id.editHidden); Now change the focus to your hidden element wh

Categories : Android

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

How to check whether an application is being closed in android
From the Android Developer Guide: There are a few scenarios in which your activity is destroyed due to normal app behavior, such as when the user presses the Back button or your activity signals its own destruction by calling finish(). The system may also destroy your activity if it's currently stopped and hasn't been used in a long time or the foreground activity requires more resources so the system must shut down background processes to recover memory. When you switch between apps by pressing the home button, Android pauses the activity and resumes it when you return to the activity. For the most part, the OS decides when to quit an application so it wouldn't make sense for you to log when an activity is destroyed. I would suggest overriding the onPause() or the onSto

Categories : Android

Get closed canvas shape in android
Try the following way. public class MainActivity extends Activity { private ArrayList<Path> _graphics = new ArrayList<Path>(); private Paint mPaint; float x1, x2, y1, y2; boolean isDraw; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new DrawingPanel(this)); System.out.println(x1 + " " + x2 + " " + y1 + " " + y2); mPaint = new Paint(); mPaint.setDither(true); mPaint.setColor(0xFFFFFF00); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(3); } class DrawingPanel extends SurfaceView implements SurfaceHolder.Callback

Categories : Android

Dialog gets closed on screen rotation android
This is because your activity is recreated on orientation change. See: Activity Life-cycle Management [developer.android.com]. UPDATE: The dialog for the list preference is a part of the preference hierarchy and is created by android. Hence it is saved and restored by android in the PreferenceActivity's onSaveInstanceState() and onRestoreInstanceState() calls. Whereas you are creating the dialog for your Preference "prefAlert" and must save and restore in your class' onSaveInstanceState and onRestoreInstanceState methods. See this: Recreating an activity [developer.android.com]

Categories : Android

Connection closed before request completed - Android ION
If you don't mind checking, I think the underlying cause of this bug was fixed recently: https://github.com/koush/ion/issues/18 https://github.com/koush/AndroidAsync/issues/55 Was related to SSL.

Categories : Android

Android BOOT_COMPLETED not received when application is closed
was struggling with the same problem, the reason is you are using Log.d to track you application in logcat, unfortunately when you restart your phone the application is receiving the BOOT_Complete but you can't see it because it's not logging to logcat. try making a Toast with some text instead of Log.d to make sure if BOOT_COMPLETED is or is not received. hope this Help.

Categories : Android

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Android google map v2 is not working after the application is closed and reopened
I think that the best place would be to create a class that extends SupportMapFragment, and initialise the map in: @Override public void onAttach(Activity activity) Besides that though, I think if you initialise the map in onResume of the container activity it should be ok. But if you by initialising you mean adding the mapfragment to the activity, I would suggest doing it in the xml or in your activity's onCreate. Just my two pennies.

Categories : Android

Android Twitter default share-force closed
This is what I do to share stuff with twitter: tweetButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub initShareIntentTwi("twi"); } }); private void initShareIntentTwi(String type) { boolean found = false; Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); // gets the list of intents that can be loaded. List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities( share, 0); if (!resInfo.isEmpty()) { for (ResolveInfo info : resInfo) { if (info.activityInfo.packageName.toLowerCase().contains(type) || info.activityInfo.nam

Categories : Android

Android : Does a Service gets killed when an Activity in the same process is closed?
Services in Android run as long as it is not closed by OURselves or the SYSTEM Or by the user. Does the running service get closed if all the activities in my app are closed ? If you used startService() to start the service, no. If you used bindService() and called unbindService() a matching number of times, then yes. And i also came to know that both an Activity and a Service can't be run at the same time on the main process, Is this true ? An Activity is an object. A Service is an object. Objects do not "run" in Java (or any other OO language that I can think of). Methods run. For my scenario which design is best ? Activity+Service in same process, Activity+ IntentService in same process, Activity, Service in diff processes ? "Activity+Service in same process".

Categories : Android

Android - attempt to re-open an already-closed object: SQLiteQuery using loaderManager
Fixed it: @Override public void onLoadFinished(Loader cursorLoader, Cursor cursor) { if(!cursor.isClosed()){ adapter.swapCursor(cursor); } } I do have another problem now, my list does not get updated automatically...

Categories : Android

IOException: read failed, socket might closed - Bluetooth on Android 4.3
I have finally found a workaround. The magic is hidden under the hood of the BluetoothDevice class (see https://github.com/android/platform_frameworks_base/blob/android-4.3_r2/core/java/android/bluetooth/BluetoothDevice.java#L1037). Now, when I receive that exception, I instantiate a fallback BluetoothSocket, similar to the source code below. As you can see, invoking the hidden method createRfcommSocket via reflections. I have no clue why this method is hidden. The source code defines it as public though... Class<?> clazz = tmp.getRemoteDevice().getClass(); Class<?>[] paramTypes = new Class<?>[] {Integer.TYPE}; Method m = clazz.getMethod("createRfcommSocket", paramTypes); Object[] params = new Object[] {Integer.valueOf(1)}; fallbackSocket = (BluetoothSocket) m.invoke(

Categories : Android

Send notification from a service running in background after application is closed in Android
Notification: NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder( getApplicationContext()); Intent intent = new Intent(getApplicationContext(), YourActivity.class); intent.setAction("notification"); PendingIntent pendingIntent = PendingIntent.getActivity( getApplicationContext(), 0, i intent,PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); builder.setSmallIcon(R.drawable.app_icon) .setContentTitle("Next Appoinment....") .setContentText(response)

Categories : Android

How to add a specific key on android keyboard
just try like this <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:digits="0123456789/.-"> </EditText>

Categories : Android

Hide the keyboard whenever I want in the app on Android
InputMethodManager iMM = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE); Show it via: iMM.showSoftInput(ed, 0); Hide it via: iMM.hideSoftInputFromWindow(ed.getWindowToken(), 0);

Categories : Android

How to set max length to android keyboard
android:maxLength="6" should work, but since it isn't it might be happening because of your new style, so use an input filter to limit the max length of a text view. TextView editEntryVew = new TextView(...); InputFilter[] FilterArray = new InputFilter[1]; FilterArray[0] = new InputFilter.LengthFilter(6); editEntryView.setFilters(FilterArray);

Categories : Android

android keyboard with different language
It's very simple. Just need to add unicode as android:codes and it will print that particular char in edittext. android:codes="0x0AE7" android:keyLabel="2"

Categories : Android

Send Push notifications to iOS/Android on closed WiFi nework (no internet connection)
E.g. an on premises push notification service that can be used to send a notification to a users phone based on an event that is triggered by our server? With respect to Android, the answer is "not really". Your options are: Implement your "push" mechanism in the form of some message queue, where the devices poll looking for messages every so often, or Use a WakeLock and WifiLock to keep the device (and WiFi) powered on constantly, then use something like MQTT for the push message Either of these will be bad for the battery, though the first one is more configurable in terms of power drain (e.g., if you only check for messages once per hour, it won't be bad). The reason why GCM can keep the power drain low is because of special hooks for mobile data connections within the OS and

Categories : Android

Android - Bluetooth Printer not finished printing but throws IOException: Socket Closed
What happpend if you put a Thread.sleep(2000) right before the socket.close()? I work on bluetooth SPP and I had the same issue (Socket close before the end of data transfer). I think that the broadcast of socket.close() is faster than the transmission of the data, then all the data are not analyze by the BT printer when the close request is send

Categories : Android

Can I reposition and/or split android keyboard?
Answering my own question, after much digging I think the answer is no, there is no simple way of moving the keyboard from the bottom of the display. I have settled on a very small "keyboard" along the bottom, and then creating a mostly transparent popup view. Not nearly as simple as what I was hoping for, but I think I can eventually get it to look the way I want.

Categories : Android

How to set Different Key Background for every Key in Android Custom Keyboard
There was a later duplicate question posted at how to change key background of any key in Android soft keyboard . It had some good answers.

Categories : Android

android set app to portrait only, except when keyboard pulled out
One option is to tackle this problem programmatically. What you could do is detect if the user has a hardware keyboard attached, and if so force the orientation into landscape mode. Here are two ways to detect a hardware keyboard: http://developer.android.com/reference/android/content/res/Configuration.html#keyboard and if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { } Once you have detected that the user has a hard keyboard you can force landscape mode on the user with: myActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.