unexpected null in start extracting text in InputMethodService - android

I am developing soft keyboard every thing works fine but when i change orientation following error occurs
"Unexpected null in startExtractingText : mExtractedText = null, input connection = com.android.internal.view.InputConnectionWrapper"
and close the inputview as well
i don't know how to solve this please help.

I found problem
when External application force close Input-view it will throw
start extracting text null

I have faced the same issue. I have resolved this issue. In my case , I was adding my custom view on overrided method setExtractView(View view). But I was not removing views first.
Let me explain :
#Override
public void setExtractView(View view) {
// You have to do this if you are not doing so
view.removeAllViews() ; // This is the line
view.addView(yourView) ; // Here you can put your own Custom view
super.setExtractView(view);
}
This is working for me.I hope this will help you.

Related

Problem Onclick + "v" does not recognize the methods in android studio code

I am fairly new to programming, I was writing an application code in Android Studio but had a problem
It turns out that when I put this line in my code (In image)
it does not detect it and an error occurs both with "onClick" and with "(v)" I reached this point and I don't know how to solve it
Attached images:
[1]: https://i.stack.imgur.com/huZLu.png Error Code
[2]: https://i.stack.imgur.com/hCJYJ.png All Code
I would really appreciate the answer
This problem is eating my head!
Thank you
it's not a big problem, you can write like this, it will solve your issue
mOpicon2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
finish();
}
});

swipeDown doesn't work in Uiautomator

I am trying to use Android UIautomator and trying to swipeDown() a view to open another view. But I have failed to do so. I have tried swipeLeft() and swipeRight() for other layouts and I succeeded, but can't find a solution why this is not happening for swipeDown().
the code I have wrote so far:
UiObject drawer=new UiObject(new UiSelector().className("android:id/tabs"));
drawer.swipeDown(5);
I have read all the possible documents and can't find what I am doing wrong. Please let me know what I have done wrong. Thanks in advance.
You must ensure that the UiObject drawer in your case is visible, if it is not visible swipeDown can not be performed.
try something like this, then you can see what fails!
if (drawer.waitForExists(1000))
{
boolean swipeWasPerformed = drawer.swipeDown(5);
Log.i(swipeWasPerformed);
}

WebView appears as plain white box after the second time it's been initialised

EDIT: tl;dr: WebView appears as white box, even though I appear to be setting it up correctly, and indeed it does work the first two times, but fails subsequently)
EDIT: Video showing the problem in action...
I have the following bit of code which inflates a view (Which contains a WebView) from the xml which defines it:
private void createCard(ViewGroup cvFrame, Card card) {
//... setup vairables...
cvFrame.clearDisappearingChildren();
cvFrame.clearAnimation();
try {
View cv = LayoutInflater.from(getBaseContext()).inflate(R.layout.card_back_view,
cvFrame, true);
cv.setBackgroundDrawable(Drawable.createFromStream(mngr.open(deckName + "_Card_back.png"), deckName));
TextView suit = (TextView)cv.findViewWithTag("card_back_suit");
//...setup text view for suit, this code works fine every time...
WebView title = (WebView)cv.findViewWithTag("card_back_title");
//This WebView doesn't appear to be the one which actually appears on screen (I can change settings till I'm blue in the face, with no effect)
if (title != null) {
title.setBackgroundColor(0x00000000);
title.loadData(titleText, "text/html", "UTF-8");
} else {
Log.e("CardView", "Error can't find title WebView");
}
} catch (IOException e) {
Log.e("CardView", "Error making cards: ", e);
}
}
When this method is called as part of the onCreate method in my Activity, the WebView contains the correct code, and is suitably transparent.
I have a gesture listener which replaces the contents of the ViewGroup with different content (It animates the top card off to the left, replaces the contents of the top card with card 2, puts the top card back, then replaces card 2 with card 3)
//Gesture listener event
ViewGroup cvFrame = (ViewGroup)findViewById(R.id.firstCard);
cardLoc++
cvFrame.startAnimation(slideLeft);
(onAnimationEnd code)
public void onAnimationEnd(Animation animation) {
if (animation == slideLeft) {
ViewGroup cvFrameOldFront = (ViewGroup)findViewById(R.id.firstCard);
ViewGroup cvFrameNewFront = (ViewGroup)findViewById(R.id.secondCard);
createCard(cvFrameOldFront, cards.get((cardLoc)%cards.size()));
createCard(cvFrameNewFront, cards.get((cardLoc+1)%cards.size()));
TranslateAnimation slideBack = new TranslateAnimation(0,0,0,0);
slideBack.setDuration(1);
slideBack.setFillAfter(true);
cvFrameOldFront.startAnimation(slideBack);
}
}
When the animation has happened and I replace the contents of the cards, the TextView suit is replaced fine and the code definitely passes through the code to replace the WebView contents, but for some reason I end up with a white rectangle the size and shape of the WebView, no content, no transparency.
If I change the WebView to a TextView, it's contents is replaced fine, so it's an issue that occurs only with the WebView control :S
Can anyone tell me why / suggest a fix?
It turns out the WebView doesn't get cleared down when using the LayoutInflater to replace the contents of a ViewGroup. The other controls all seem to get removed (or at least the findViewWithTag() returns the right reference for every other control). I've just added in the line cvFrame.removeAllViews() immediately before the LayoutInflater does it's stuff and that fixed the issue.
If anyone has any better explanation for this I'll throw the points their way otherwise they will just go into the ether...
By calling findViewById, you are getting a reference on the previously loaded webview do you ?
so the loadData call that fails is the second one you make on a single webview instance.
you may want to check this :
Android WebView - 1st LoadData() works fine, subsequent calls do not update display
It appears that loadData() won't load data twice... you may want to try WebView.loadDataWithBaseUri()
Hope that helps.
I had a similar problem loading several WebViews content.
It was because of a misusing of the pauseTimers function
The situation was : the first webView weren't needed anymore, conscientiously I wanted to pause it before to release it. Calling onPause() and pauseTimers()
pauseTimers being common to any web views, it broke every use of webviews occuring after that, there were displaying only white rectangles.
Maybe its not your problem here, but it's worth checking your not calling WebView.pauseTimers() somewhere.
To confirm your answer, the source code for LayoutInflater.inflate(int resource, ViewGroup root, boolean attachToRoot) does in fact internally calls root.addView() which attaches the newly inflated view at the end of the root's children instead of replacing them.
So the mystery now is why did your call to findViewWithTag() is returning the expected objects for your other widgets (which would be the top, most recently created instances), but for your WebView it was returning something else.
Is it possible that there is another object in your layout XML which shares the same "card_back_title" tag?
I was also wondering why you didn't use the more common findViewById() instead, but I am not sure whether it would make a difference.

Custom error popup window background

Is there any way to set a custom layout for an error popup window in TextView:
.
In textView.setError(String, Drawable) we can set an error icon only.
showError() method in TextView and ErrorPopup class are private, so I can't work with them.
Any ideas? Thanks in advance! Michael
UPD:
Thanks for comments, but as I understand it, the theme trick isn't applicable here:
(TextView 3384 line from android-10)
void fixDirection(boolean above) {
mAbove = above;
if (above) {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error_above);
} else {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error);
}
}
In android-15 com.android.internal.R.styleable.Theme_errorMessageBackground theme parameter is used, but it is internal.
Therefore I don't see any way to solve this problem, except writing my own error notificator ):

Android WebView setEmbeddedTitleBar problem

I'm trying to add a titlebar on WebView so the titlebar to be scrolled with WebView.
I used this code.
private void setEmbeddedTitleBar(WebView web, View titlebar) {
try {
Method m = WebView.class.getMethod("setEmbeddedTitleBar", new Class[] { View.class });
m.invoke(web, titlebar);
}
catch(Exception e) {
Log.d("TEST", "Err: "+e.toString());
}
}
I called the method above and the titlebar seemed to be added to the corresponding webview but the titlebar doesn't show up and just white space( height of titlebar ) is upside the webview content.
My classes are 'CTitleBar' , 'CTab' and 'CWebView'.
CTab includes CWebView as a member( for one WebView per a Tab ).
And CTitleBar includes CTabs array as a member.
Prorgam operates like below.
By clicking 'add tab' button, user add a tab.
Then CTab is created with CWebView in it.
The tab is added to CTab array in CTitleBar.
( ** IMPORTANT ** ) And the CTitleBar view is added as tab.webView's titlebar.
This means.. the titlebar is referenced by it's member's member( titlebar.tab.webview ).
It seems to be a cross reference I think.
I don't know if this causes the 'white space' problem.
Or am I just using the method invocation with worng way?
How can I solve it?
Somebody help me.

Categories

Resources