Android ime actionGo doesn't work on certain devices - java

ime actionGo simply won't work on certain devices, like the HTC Evo 4G. It works on Motorola Atrix and Droid X.
Here is the code:
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:hint="#string/password_hint"
android:password="true"
android:inputType="textPassword"
android:autoText="false"
android:imeOptions="actionGo"/>
TextView.OnEditorActionListener listener = new TextView.OnEditorActionListener()
{
public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event)
{
if(actionId == EditorInfo.IME_ACTION_GO)
{
loginValidation();
}
return true;
}};
password.setOnEditorActionListener(listener);

This seems to be a bug. Different manufacturers make a customized keyboard for their phone which may not completely behave as the android standard keyboard. This issue has been raised before. Most people overcome this issue by either overiding the onKey event or using a TextWatcher class. A bug has been filed about this
http://code.google.com/p/android/issues/detail?id=2882

I ran into this recently and if you're not worried about the user being able to add lines via the keyboard this worked for getting the "Go" button to show up:
android:singleLine="true"

Related

Unknown bits set in runtime_flags: 0x28000

I made a simple app using Cards in Material Components in Android. When I try to run it in my "OnePlus AC2001" mobile, I'm getting this error in logcat.
2021-01-31 17:28:59.544 26933-26933/? E/rialdesigncard: Unknown bits set in runtime_flags: 0x28000
But I'm not getting any error when I run the app in the emulator.
This is my MainActivity.java file:
public class MainActivity extends AppCompatActivity {
CardView cardView;
TextView textView;
CheckBox checkBox;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
private void init() {
cardView = findViewById(R.id.my_card_ui);
textView = findViewById(R.id.title_text);
checkBox = findViewById(R.id.checkbox);
cardView.setOnClickListener(v -> {
checkBox.setChecked(checkBox.isChecked()? false: true);
textView.setText("First title");
});
}
}
This is my ActivityMain.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="#+id/my_card_ui"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkable="true"
android:clickable="true"
android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="30dp">
<CheckBox
android:id="#+id/checkbox"
android:layout_width="30dp"
android:layout_height="30dp" />
<TextView
android:id="#+id/title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title 1"
android:textColor="#color/black"
android:textSize="30dp"
android:textStyle="bold" />
<TextView
android:id="#+id/title_para"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="I am a paragraph and I am in a card. I am a paragraph and I am in a card. I am a paragraph and I am in a card."
android:textColor="#color/purple_700"
android:textSize="20dp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
I couldn't find the solution to this error anywhere. Please help me solve this.
I have been consistently seeing this error for some time now (OnePlus device), but I haven't been able to find a solution either. The error does not seem to impact the app in any way though.
Additional point of information:
I have observed that this error appears in the Logcat whenever I Run/Debug the app on a real device, but it does not show up consistently in the Run/Debug consoles. I haven't tried to check (as you have) if the error is replicated when using an emulator.
Also, my Logcat shows the Unknown bits set in runtime_flags: 0x20000 error for many other packages as the device is running. Some examples: .android.dialer, oneplus.weather, twitter.android, and so on.
This is what I've found out so far:
From the ARM DS5 DUI0446U Debugger User Guide, a possible memory map for internal RAM can be between 0x8000 and 0x28000. I'm not from a computer engineering background, and I'm not sure if this is a relevant direction for understanding the problem further. Searching the Android Runtime (ART) site (this, or in general, this) yielded no useful results.
For a related error, by following this answer to the ART source code, 0x28000 seems to be related to either the DEBUG_IGNORE_APP_SIGNAL_HANDLER flag or the DISABLE_TEST_API_ENFORCEMENT_POLICY flag (line 154-155 as of this time of this post). [E.g., 1 << 17 is 0x20000]
I don't have a deeper understanding of the either of the two flags. Nevertheless, the 0x20000 error seems to be pretty commonplace in production apps. While this is not an indication that the 0x28000 error is equally hassle-free, to my mind it does shed some light on the nature of the runtime_flags.
It just might be the case that errors related to these flags (see the enum in the source code) may not really "break" the app. Some further information is required in order to be absolutely certain, but the above might be good enough to not be concerned about the app breaking.
P.S.: If you think this response is good enough, do mark it as an answer so I will have some feedback as well.

android.support.v7.preference.EditTextPreference how to set keyboard to numeric

android:inputType is not working on EdidtTextPreference from support library. Is changing the input type even possible with this preference? I want a preference with a numeric keyboard. More specifically I will want to set a custom Keyboard, but I can't seem to even open the default one with this preference. If it is not possible with EditTextPreference, can someone give me an idea how I would go about doing what I desire?
<android.support.v7.preference.EditTextPreference
android:key="key"
android:title="title"
android:maxLines="1"
android:dialogMessage="title"
android:inputType="number" />
Actually, the solution is quite easy. Since android:inputType="number" didn't seem to work, I went with this:
PreferenceFragment.java
#Override
public void onResume() {
EditTextPreference preference = (EditTextPreference) findPreference("key");
EditText et = preference.getEditText();
if (et != null) {
et.setInputType(InputType.TYPE_CLASS_NUMBER);
//in fact, you can do whatever you can normally with an EditText here
}
}
Although I'm not sure if this is how it works with the latest androidx Preference.

Bettering the Generic SeekBar Example

This code and minor variations thereof exist in many forums on the net. When I launch it on my Samsung Galaxy Tab 2 (Android 4.1.1), the bar appears, the thumb can be moved, the position is reported, etc. All good, EXCEPT, the thumb never disappears. Mine manifests as a little blue circle, which I can slide along a bar, but it leaves a trail of "thumbs" behind it: one at each of the possible integer locations in the range of the seekbar.
Is the code incomplete? Is there something we have to add to manually redraw the component?
import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
public class FullscreenActivity
extends Activity
implements SeekBar.OnSeekBarChangeListener {
SeekBar seekBar;
TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
seekBar=(SeekBar)findViewById(R.id.seekbar);
textView=(TextView)findViewById(R.id.textview);
seekBar.setOnSeekBarChangeListener(this);
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// Notify that the progress level has changed.
textView.setText(textView.getText()+"\n"+"SeekBar now at the value of:"+progress);
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
// placeholder
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
// placeholder
}
}
Here's the layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/FrameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<SeekBar
android:id="#+id/seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="75dp"
android:max="31"
android:progress="15" />
<TextView
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="270dp"
android:layout_marginTop="150dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" />
</FrameLayout>
Screenshot of the effect:
Update The effect is the same on a ZTE-BLADE running Android 2.2. Of course teh default graphic is different (the gray / orange seekbar with a more square "thumb") but the thumbs remain behind at all the points I've scrolled through.
The residual garbage clears if I change the screen orientation, which makes me think it just needs a redraw. Can anyone help?
So, I copied and pasted my example code line-at-a-time into a new project, running it as I went, hoping to find the line which failed.
Got the whole thing pasted in and it worked perfectly. No problems in the seekbar.
On comparing the projects, the only difference was that the AndroidManifest.XML file contained the line
android:theme="#style/FullscreenTheme"
in the activity section. So, I went back to my original (faulty) project and took this line out. Now the project works fine.
I have my answer: the code is complete and there's nothing we need to add to make it redraw.
I still don't understand why this line had that effect and now I have a horrible white background when I wanted black.

Soft keyboard listener

I'm making a game using AndEngine which uses the soft keyboard of the device.
I'm NOT using EditText, but rather my own. I'm trying to detect presses on the soft keyboard,
I've already succeeded in showing and hiding the keyboard over the AndEngine scene.
My activity implements the OnKeyboardActionListener, which I read is used as a soft-keyboard listener, but I'm not sure how to register the keyboard with this class (the activity).
Obviously, at the moment, the code inside onPress() is useless..
I couldn't find any examples, most of them refers to EditText, which I'm not using..
Is it possible?
Maybe a service or something?
Thanks in advance.
EDIT:
I'm trying to create my own keyboard using KeyboardView and a custom Keyboard,
This way I could do
KeyboardView kbView = new KeyboardView(this,null);
kbView.setKeyboard(new Keyboard(this, R.xml.keyboard);
kbView.setOnKeyboardActionListener(new OnKeyboardActionListener() {
....
}
Has anyone done this? works, doesn't?
Thanks.
I ended up creating my own Keyboard and KeyboardView`, then I used this code
CustomKeyboardView kbView = (CustomKeyboardView) findViewById(R.id.keyboard_view);
kbView.setKeyboard(new Keyboard(this, R.xml.myCustomKeyboard);
kbView.setOnKeyboardActionListener(new OnKeyboardActionListener() {
#Override
public void onPress(int primaryCode) {
// A Key was pressed
}
....
}
And created a KeyboardView in the xml layout
<pathToCustomKeyboardView.CustomKeyboardView
android:id="#+id/keyboard_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:layout_alignParentBottom="true" />
CustomKeyboardView only extends KeyboardView, dunno why, but it works with the custom and not with the original
EDIT:
Also, The activity extends SimpleLayoutGameActivity, And then I selected the layout which contains the CustomKeyboardView

Real Admob Ads Appearing When Setting Test Mode Programmatically

Kind of a strange issue here: Whenever I set test mode via xml, I receive the expected test ads in my emulator. However, when I try to do the same programmatically, I seem to get real ads. According to the Admob documentation, these two methods should be equivalent, no? Here is my xml code:
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxx"
ads:loadAdOnCreate="true">
</com.google.ads.AdView>
And here is the relevant Java code:
#Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
}
As mentioned before, if I insert the line ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" into the above xml code, I get the test ad just fine. Any ideas?
I believe you have to call .loadAd(adRequest) on the AdView object.
See Google's AdMob documentation here
In the Adding a com.google.ads.AdView section.
You don't have to call it programmatically.
It took me a while until I get what device is AdMob's sdk what expecting cuz' I was thinking it was something related to the real device like ( adb devices )
But here is a comment from the official documentation that cleared it up.
"There will be a log message with the code needed to add the current device to the list of test devices"
You may get a message akin to it
I/Ads(26674): To get test ads on this device, call adRequest.addTestDevice("F1254CDFBA84BDC27F5C7C6E12445D06");
All you have to do after that is to place this ID into your layout xml as below
<com.google.ads.AdView
android:layout_alignParentBottom="true"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/publisherId"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, F1254CDFBA84BDC27F5C7C6E12445D06" />
Hope it helps you guys out
Paulo Miguel Almeida

Categories