SAPUI5 Spinner is not working in higher versions of android - android

I have developed an application using SAPUI5. The spinner has to appear when navigating from one page to other. The spinner works fine on jelly bean android version. But fails on higher versions. Can anyone help me with this?
sap.ui.getCore().byId('loadingIndicator').setText("Loading...");
sap.ui.getCore().byId('loadingIndicator').open();

use sap.m.BusyDialog
var oBusyDialog = new sap.m.BusyDialog();
oBusyDialog.open();// will work when DOMis already there
oBusyDialog.close();//else it throws error and page completely fails in IE.
hence put it in try catch
try{
oBusyDialog.open();
}catch(e){
//Error handler
console.log("Busy dialog couldn't be loaded:"+e);
}
Check Preview here
Note: On Page refresh, DOM will not loaded before you call open() or
close() method, hence put it in try catch.

Related

How to provide input to a webView input field programmatically in Android Kitkat (4.4)

I need to provide input to a webview input control programmatically. For that I was using webView.dispatchKeyEvent() and it worked fine till Android 4.3 version but it is not working in 4.4 version (Kitkat - Chromium webView).
I see the below statements in the logcat:
W/UnimplementedWebViewApi(9737): Unimplemented WebView method onKeyMultiple called from: android.webkit.WebView.onKeyMultiple(WebView.java:2179)
I have tried dispatchKeyEvent(), onKeyDown() but nothing is working for Chromium webView in 4.4, please can someone let me know if there is a way to send input to webView fields programmatically.
Please note that I am looking for a generic solution for any webpage (Eg: username and password fields in Facebook URL) where I don't know the name/id of the input control so cant use a simple Javascript method for loading input.
You can use the Instrumentation class for this. I've tested it with Android 4.4 and it works.
First ensure that the WebView has focus, then call sendCharacterSync() to send individual key events. Note that these calls must be done from a background thread (this is mandatory).
For example:
final Instrumentation instrumentation = new Instrumentation();
new Thread(new Runnable()
{
#Override
public void run()
{
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_H);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_TAB);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_T);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_H);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_R);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E);
}
}).start();
The only issue is that you get a "typewriter" effect (i.e. the letters appear one by one, not all at once).

pagechange method doesn't work on android 2

I have set up a small mobile application and during tests I have stumbled upon a problem with older versions of mobile devices running Android version 2. Please note that iPhones, iPads and newer versions of Android, namely 4.xx display the pages well. The problem is as follows:
When page is called directly from the link:
Home
it is properly displayed.
However, when there is a click handler on a link, like here:
$(document).on('click', '#lstAddrList li', function ()
{
var anchor = $(this).find('a');
sessionStorage.SiteAddr = anchor.attr('id');
changePage();
});
the list line (in this case) stays selected and nothing happens. It is ONLY after the calling page is refreshed directly from the browser when the called page is displayed. I have a feeling that older Androids do not properly handle changePage() method.
Will you have some ideas?

Findall / FindAllAsync not working properly on android 4.1 jelly bean

I have a small android app that haves a webview. In android 2.2, 2.3, I can perform a search on this webview using findAll and it works great, highlights the words being searched and scrolls to the position of the match.
In android 4.0.X, the search works and scrolls ok, but no highlight (using findAll).
In android 4.1, using findAll or findAllAsync, it doesn't really matter, the search doesn't work well at all. In my tests, it performs the search, but does not scroll to the position of the match, instead returning to the top of the page, which is ridiculous. It even highlights the match, but without going to the position on the webview it's as good as useless from a usability standpoint.
Here's the source codes:
//////////////////////////////
// for android 2.2, 2.3, 4.0.x
//////////////////////////////
myContent.findAll(findBox.getText().toString());
try{
//Can't use getMethod() in android 4.0.3 as it's a private method
for(Method m : WebView.class.getDeclaredMethods()){
if(m.getName().equals("setFindIsUp")){
m.setAccessible(true);
m.invoke(myContent, true);
break;
}
}
}catch(Exception ignored){}
Then, on another method with target api 16:
/////////////////////////////
// for android 4.1
/////////////////////////////
myContent.findAllAsync(findBox.getText().toString());
try{
//Can't use getMethod() in android 4.0.3 as it's a private method
for(Method m : WebView.class.getDeclaredMethods()){
if(m.getName().equals("setFindIsUp")){
m.setAccessible(true);
m.invoke(myContent, true);
break;
}
}
}catch(Exception ignored){}
Any ideas on how to make the search work on jelly bean? Thank you very much.

Android:cannot make a selection after WebView search with highlight

Hello I have a bug in my app and I cannot figure it out.
I want to search for text in my WebView and get the found Text highlighted
for Android 1.5-2.3 this works quite well
public void onClick(View v){
webView1.findNext(true);
int i = webView1.findAll(findBox.getText().toString());
try{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView1, true);
}catch(Exception ignored){}
}
}
for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons
And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)
Thank you
I use the same for 3.x then it did not work on 4.0.x.
Yesterday I updated to 4.0.4 and now highlight works again.
So the solution can be found in the 4.0.4 sources.
OK I have found a quite good solution.
Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript
Anyway I don't understand, why I can't selecting text after the of the official Webview search
For Android 3.x I used webview.showFindDialog(stringtofind, true);
use findAllAsync() instead , finAll() is deprecated in API 16;

android Drawable calling NullPointerException in onCreate after onDestroy has been called

I am trying to make an App that acts as a map of a local area. Because of the local area, I do not want to use Googlemaps or its API. I want to use a .png that I import. My image is 2300 x 1650 and after searching for a way to load this image into my Activity (because just making one bitmap throws OOM exception), I found a way using Drawables. My code to implement the drawable is...
InputStream mapInput = resources.openRawResource(R.drawable.mymap);
mapDrawable = Drawable.createFromStream(mapInput, "mymap");
mapDrawable.setFilterBitmap(true);
mapDrawable.setBounds(0, 0, MAP_WIDTH, MAP_HEIGHT);
myCustomView.setMapDrawable(mapDrawable, MAP_WIDTH, MAP_HEIGHT);
and this works all fine and dandy and allows the App to function. However if I BACK or HOME screen out of the application and attempt to reload it, I get a NullPointerException when I try to access mapDrawable (so in this line of code, on mapDrawable.setFilterBitmap(true))
After my app fails, if I try to reopen it again, it works again. Unless I BACK or HOME out of it and then it fails. It always fails on the attempt to reopen.
I don't understand what I am doing wrong.
Here is a sample project showing asynchronous in google Maps..
https://github.com/commonsguy/cw-advandroid/tree/master/Maps/NooYawkAsync/
Try this if it works..

Categories

Resources