android Drawable calling NullPointerException in onCreate after onDestroy has been called - android

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..

Related

Why my Unity game in Android freezes when calling LoadScene?

The game freezes permanently when I try to load the next scene but when I load it with "Additive" mode it's loaded fine (using SceneManager.LoadScene("NextScene", LoadSceneMode.Additive)).
In editor everything works even with mode "Single", the problem only appears with Android.
I don't want to use the "Additive" mode because it loads the content of the new scene above the old one.
I try:
using "adb logcat" to see if any exception occurs but there are no exceptions.
load an empty scene as a new scene but the problem still appears.
load using SceneManager.LoadSceneAsync("NextScene") but the problem still appear.
load with "Additive" mode and after the next scene is loaded I try to Unload the old scene using SceneManager.UnloadScene("OldScene") but it freezes again.
So the problem appears when Unity try to unload the old scene.
(I use Unity 2018.4.10f1 LTS).
Thanks in advance for any help.
Try to delete the objects from the last scene
In for loop to see what object response for the error
I try to build the game with PC and I face the same problem.
I see what in the output_log.txt file in "C:/Users/.../AppData/Local/Temp/.../My game name/Crashes" and the first readable messages after the crash are like this:
"ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFEF20E5212)"
without any other errors or exceptions by my game,
so I try to test the game with an updated version of Unity (2018.4.10f1 --> 2018.4.20f1),
Abracadabra everything works fine with the new version!!
and the problem doesn't appear anymore!!
I think it was a memory management problem in Unity 2018.4.10f1 but I don't know why.

Expansion Android Apk working very slow whenever downloading first time

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

Plaid Sandbox Android APP Program Keeps Refreshing

The code that I'm using was imported directly from this example code:
https://github.com/plaid/link/tree/master/webviews/examples/android
When I run the app in Android Studio on a Nexus 5X emulator I see this:
Empty Menu
It then goes to the loading screen:
Loading
The app then switches between the two as if it were constantly refreshing. I see the empty menu then the loading screen pops up, then back to the empty menu then loading screen again.
I'm very new to Plaid so there might be something very simple that I'm missing but thanks for the help!
In the initialize link step, replace [PLAID_PUBLIC_KEY] with the public key provided to you. If you haven't registered for an account with Plaid, you have to do that first.
linkInitializeOptions.put("key", "[PLAID_PUBLIC_KEY]");
An HTTP request is sent with the public key, and the shouldOverrideUrlLoading function will keep getting called upon response without a valid public key, perpetuating the refresh cycle that you see.

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!

Why do I get a strange blank screen error with OpenGLes/Android/NDK?

I'm getting a very weird error ever since I have "ported" the spritebatch code from Nokia's site. It runs well as a desktop applcation emulated by POWERVR. But on Android I only get a blank screen (in fact its black.) This happens if I just try to display a image, but it doesn't crash.
Here is where comes the weird part comes in: if i put glGeterror(); in the update function it works fine! (slowly, but displays everything fine) and geterror code returns 0. I have no idea what is going on or how to debug it, as I'm new to OpenGL but everything looks correct in the source. I spitted geterrors all around the code but without any clue. I've attached my project if you want to take a look. You will need Visual Studio + vsandroid to compile.
apparently the problem is not on the sprite batch, but in the java code. I replaced for another one that uses surface view and no longer im getting this esotheric behavior.

Categories

Resources