Expansion Android Apk working very slow whenever downloading first time - android

Currently, I am using this plugin
https://github.com/erobertson42/cordova-plugin-xapkreader/tree/cordova-9
I am using this path to show the image -
'content://com.x.x/main_expansion/assets/dummy.png';
and to make image path safe I am using domSanitizer.bypassSecurityTrustUrl method
getImg(img) {
img = this.domSanitizer.bypassSecurityTrustUrl(img);
return img;
}
Whenever I am using my app, it is working very slow but I am going one by one on the screen throughout the app first time it stucks on every screen approx 40 to 60seconds but after taking sometime it will work normally. If anybody has any suggestion or concern, please share

Related

Android, Xamarin: Load Pictures Into Recycle Viewer While Scrolling

Have you ever been going through apps like 9gag, Instagram or Facebook? You notice, that while scrolling the pictures load into the recviewer. They sort of come in one by one while you can still use the app.
I have implemented my own custom recviewer and am stuck right here:
pictures = KumulosHelper.Pictures.getNewestXPhotosFromUserInRange
(strUsername, "6", startNumberOfTask.ToString(), "1");
foreach (var picture in pictures)
{
startNumberOfTask++;
var metrics = Resources.DisplayMetrics;
lstData.Add(new DataForProfile()
{
imageId = startNumberOfTask,
img = (Bitmap.CreateScaledBitmap
(KumulosGeneral.DecodePhotoFromBase64(picture.photo),
metrics.WidthPixels, metrics.WidthPixels, true)),
description = picture.taskId.ToString()
});
}
Where I type in "6" is where I get 6 pictures to load into my recycle viewer form the server. I can type in 10 or 20 and it continues loading those pictures. So, I could probably set up a "reachedbottomevent" to continue loading new pictures when the viewer reached the end. But that would mean that the user has to wait everytime he or she reached the bottom of the matrix. This is pretty annoying. Also, the whole activity wont start untill all pictures are fully loaded.
How do I get my recview to behave like the afforementioned apps above? Some sort of "smart" loading the pictures?
Thank you for the input!
Try using the Picasso library which is very reliable and easy to use. It also loads pictures in a background thread.
https://www.nuget.org/packages/Square.Picasso/
Also, the whole activity won't start until all pictures are fully loaded.
In order not to block your UI thread try using a BackgroundWorker or a Task.
At last, if you want to load a new batch of images before the user reaches the bottom of your list, then change your logic to trigger the call for a new batch for example when the user scrolls half the table.

Images randomly break in PhoneGap/WebView on Android 4.4

I am experiencing a strange bug in PhoneGap on Android 4.4, for which I couldn't find any solution online. In my app, I am loading a lot of different images from a remote server, and as the user navigates back and forth, new images are loaded on each page (4 at a time, to be specific, through jQuery-generated html). After having navigated back and forth for a little while, some images will randomly not show up and instead show the typical "broken image" icon.
Now, here comes the strange part: I have been following the instructions at jQuery/JavaScript to replace broken images and done a few tests of my own. In conclusion, the naturalWidth and naturalHeight parameters report the right sizes of the images, and complete reports true for all images. Therefore, the solutions mentioned in the above SO thread don't work at all. Changing the image src doesn't help, either with or without a setTimeout (I tried adding the current timestamp as a parameter to the image path as well).
Did anyone else encounter this issue at all, or am I going crazy here? :)
EDIT: By the way, no error is ever reported. Therefore, no error handler is called when loading the image, making it useless to solve the problem with the already suggested methods (see the link above).
This is how i handle error images,
<img src="images/imageName.jpg" onError="onErrorFunc(this);" alt=" " />
function onErrorFunc(elem){
var imgUrl = "https://alternative-image";
elem.onerror = function (){
elem.src='images/noimage.jpg';
}
elem.src=imgUrl;
}
Hope it helps!

call to a possibly undefined method loadmovie at the (Air for android) publisher

I'm creating an android app using Flash CS5.5 and everything goes fine , but when I finished , I realized that the app size is VERY BIG coz of the lots pictures inside the app.
So, I uploaded the pics to a website and I created a square for the image and I give it an instance name (photo), putting this action to it
loadMovie("http://im37.gulfup.com/Jc0Ek.jpg", _root.photo.empty);
At the normal publish , the image shows perfectly with no errors
but at the (AIR FOR Android) publish , it's giving me this error,
(call to a possibly undefined method load movie)
so , what is the action or the way that I should do , to make my android app size low or where to upload the images and how to link them to the app?
It's an AS2 code and you need AS3 like so:
var urlRequest:URLRequest = new URLRequest("http://im37.gulfup.com/Jc0Ek.jpg");
var imageLoader:Loader = new Loader();
imageLoader.load(urlRequest);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
function onLoadComplete(e:Event):void
{
addChild(imageLoader);
}
function onLoadError(e:IOErrorEvent):void
{
trace("Error loading image");
}

Recent Apps on UiAutomator

I am now working with Android UiAutomator on for UI Test on my Android app. My app has a function that requires the user to verify the email to continue, so I try to do it like this: after reach to that function -> getUiDevice.pressHome -> Browser -> try to log in email -> PressHome again -> Press RecentApps then I stuck here, I cannot press on my Apps to return to it again. I try another way by clicking on my App icon but it starts my app again, not at the state before. Can anyone suggest me a solution for this? Any help is appreciate.
Thanks in advance.
Try this :
UiObject appBackground = new UiObject(new UiSelector().description("ABC"));
appBackground.click();
It did not show any description through 'uiautomatorviewer' command but this worked for me.
I could manage to create this behavior with:
fun backgroundAndForeground() {
val device = UiDevice.getInstance(getInstrumentation())
device.pressHome()
// Pressing app switch two times makes the last app put on background come to foreground.
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
}
In this case, I think that android only resume app when clicking the recent app image. It does not work on clicking display text or app icon. So, we need to click image of your app in recent app list. At that time you need to write as below. I always do that for similar case.
// Take all image view by class type and click by instance no.
new UiObject(new UiSelector().className("android.widget.ImageView").instance(3)).click();
You need to count instance no of your recent app image view. Not app icon image in recent app scroll view. Please try this. Thanks.
I've spent half a day on this and concluded I needed to issue a device.click(). Since my use-case is that my app was the last one running (not switching to the browser like you), I can safely click the middle of the screen and it'll always work.
If you're the 2nd to last running app, you can probably do x: 0 and y: device.displayHeight/2.
I've not tested this on many operating systems, only 9.

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