Hey there,
I have an issue here and I am not really sure on how to solve it.
The Logcat says:
The connection pool for database 'my Database' has been unable to grant a connection to thread 1 with flags 0x2 for 240.0000 seconds
Click to expand...
Click to collapse
After this, my app freezes and I can do nothing more, than uninstall the app and create the database new. A restart with the taskmanager does not repair it.
In my app, I have an intent, which downloads every hour some data per Bluetooth. This data is the stored in my database. If I try to access the database in this time, the issue apears.
For now, I made sure, that only one instance of the SQLiteHelper is opened, so I have this static method:
PHP:
static BatteryManager getInstance(Context c)
{
if(bm==null)
bm = new BatteryManager(c);
return bm;
}
Right now, I am inserting the data with a simple sql command and :
PHP:
this.getReadableDatabase().execSQL(sqlCommand);
I know, that there are cleaner ways, but this would not solve a problem like this, right?
After some googling I found out, that a content provider would help me, is this correct?
What would you suggest?
Thank you for your help!
Related
Hi All,
I'm trying to access a SOAP service (I know, why can't people provide REST?!) from my android app.
I found ksoap2 and it looks nice and simple, I've imported the lib into my project (eclipse fwiw) and it all appears to be functioning normally.
However, the SOAP service I'm attempting to use is extremely picky.
It expects string data ("SAE" or "SHY" for example) named "crs" in a "type" of "CRSType". I can not figure out how I can get kSoap2 to do this. If I send the data as type String, I get a soap error back from the server of "no crs specified".
I have tried setting the request property to a java type of CRSType implementing CharSequence and a toString() method that returns the data. Wireshark shows me it's still reported to the service as "d:string".
I tried creating a custom data type with KvmSerializable and it nested it, and called the data "d:anyType" containing a normal "d:string"...
I'm starting to think I should craft the xml myself, but it's frustrating me and I figured I'd see if anyone here had any ideas.
ETA: Feel free to suggest other libs that might be suitable and as easy-to-use as kSoap2.
BTW, it's an opensource app, probably won't reach market but is on googlecode under droidtransport if anyone wants it (no webservice code committed as so far it's not working!)
TIA
--
Martyn
How can I ask user to activate wifi or mobile connection, with a dialog like this (programmatically)?
see the attachments
frx08 said:
How can I ask user to activate wifi or mobile connection, with a dialog like this (programmatically)?
see the attachments
Click to expand...
Click to collapse
Them some AlertDialog...
The data at http://developer.android.com/reference/android/app/AlertDialog.html should get you started building it.
They are just using Positive, Negative, and Neutral to preform different actions then their name would otherwise imply.
I'm looking for the way to ask something like "enable wifi"..
however I reached a solution searching in the android reference:
Code:
Intent wirelessOpts = new Intent(
"android.provider.Settings.ACTION_WIRELESS_SETTINGS");
startActivity(wirelessOpts);
this do the job.. but in the debug emulator I get an error..maybe because I need to add user permissions in the manifest xml.. but I don't know...
You did read the title and still clicked so I think you may need this little app
I wanted to see the Android device log convenient on my desktop browser without using USB cable and also be able to send APKs to the device to update my apps. Without root! App install of course needs confirmation on device.
Also a nice log view on the device is always helpful - I found aLogCat scrolling too slow to be usefull and it can not jump directly to errors.
For tests of my remotely running app MobileWebCam I also need the possibility to get logs saved even without internet connection - so SMS can be sent to the device to trigger logging. For other apps there is an intent to trigger logs if Remote LogCat is installed. And the standard feature is there, too: dump logs from time to time onto sdcard, http or others like email with the support of my other app AutoShare ...
Filtering the log is a little complicated right now but I found myself using the full log most of the time anyway ...
Find the apk is attached to this post or in Android Market.
Nice. I will try it when I get time. It seems very useful.
Ohh, for some time I've wanted something like this! Thank you _miha_!
Downloading now, will report a little bit later as my phone is currently in 'flashing' state!
Thanks _miha_! Working great on my LG Thrill 2.3.5. I would love to see it auto scroll on the pc browser side. Even without it, awesome app. Thanks again!
Wow this is work great already do a test from Browser & everything is Great
Nice
It does not work for me, because the browser URL shows up like this:
http://fe80::123:65ff:fe68:767a%wlan0:8080
Why is that?
I am using a SGS2 with CM9.
Also, the RemoteLogCat service is running all the time, even when the app is closed....
CRXed said:
http://fe80::123:65ff:fe68:767a%wlan0:8080
Why is that?
Click to expand...
Click to collapse
That is an IPv6 format address. I do not know why you have one - maybe CM9 uses v6 preferred?
Try to enter [ and ] around the numbers and ::s. Like:
http://[fe80::123:65ff:fe68:767a%wlan0]:8080
(see here: http://superuser.com/questions/242122/accessing-non-port80-web-server-using-ipv6)
You can disable webserver with the third setting (Enable - HTTP server enabled. Access using Browser...) - it is enabled default at the moment so users do not have to search it before trying the app.
I can't get it to work.
My phone has a normal IPv4 IP adres, 192.168.0.13
I tried
http://[fe80::123:65ff:fe68:767a%wlan0]:8080
http://[fe80::123:65ff:fe68:767a]:8080, because, what is %wlan ??
Anything else I can try?
Also, when disabling HTTP server and exiting the app with the back button, the logcat service is still alive.
version 1.04
CRXed said:
Anything else I can try?
Also, when disabling HTTP server and exiting the app with the back button, the logcat service is still alive.
Click to expand...
Click to collapse
Updated version 1.04 displays ipv4 adress only now. And does no longer let Android restart the service in case it is not enabled (thanks for making me aware of that)!
IPv4 is working now!
But when I disable the HTTP server, I still see a service running in the background.
Which service is this? I use SystemPanel to check.
Also, when opening the app for the first time, my entire phone get's very slow, because it is trying to retreive all logging info.
After clearing the log, everything is smooth again.
Also, when the log is very big, I get this:
Code:
W/dalvikvm(18755): threadid=21: thread exiting with uncaught exception (group=0x40a541f8)
E/AndroidRuntime(18755): FATAL EXCEPTION: Thread-333
E/AndroidRuntime(18755): java.lang.OutOfMemoryError
E/AndroidRuntime(18755): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
E/AndroidRuntime(18755): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
E/AndroidRuntime(18755): at java.lang.StringBuilder.append(StringBuilder.java:216)
E/AndroidRuntime(18755): at com.dngames.remotelogcat.a.a(HelloServer.java:85)
E/AndroidRuntime(18755): at com.dngames.remotelogcat.h.run(NanoHTTPD.java:424)
E/AndroidRuntime(18755): at java.lang.Thread.run(Thread.java:856)
W/ActivityManager( 1803): Force finishing activity com.dngames.remotelogcat/.RemoteLogCat
More info in my signature.
To stop the always running background service please disable in the settings and leave the app. This seems not to be obvious enough - so maybe I should add a button in the first menu?
After a long time a little update to version 1.08 ...
I stripped html from the browser logcat so it is no longer confused when apps log html tags. Also two error message crashes are fixed.
I am trying to pass data from activity 1 to activity 5 without using Intent. How can I do that? The data type is string.. Is there anyway I can make a class between them which handles the data?
Not a really nice way, no. The simplest to do is with intents and if you want to pass something back with the startActivityForResult(intent) and then overriding onActivityResult.
Another possibility is to save the string in a text file and then open it from the other activity.
And Google is our friend: you can do this
using a class with a lot of static variables (so you can call them without an instance of the class and without using getter/setter)
Click to expand...
Click to collapse
Which means you create your class just with static variables and methods and access them without creating an object. But I don't think that's a good way to do it, if you have a simple String, do it with an Intent.
I agree that you should not do this.
If you still want to do this, use SharedPreferences.
nikwen said:
I agree that you should not do this.
If you still want to do this, use SharedPreferences.
Click to expand...
Click to collapse
Well, read this, see if EventBus could solve your problems:
http://xenoamp.info/index.php/capta...-eventbus-a-k-a-intents-you-shall-not-paaasss
I think that using eventbus is the cleaner method
Sent from my SK17i using xda app-developers app
ssuukk said:
Well, read this, see if EventBus could solve your problems:
http://xenoamp.info/index.php/capta...-eventbus-a-k-a-intents-you-shall-not-paaasss
Click to expand...
Click to collapse
Skektox said:
I think that using eventbus is the cleaner method
Sent from my SK17i using xda app-developers app
Click to expand...
Click to collapse
Makes sense.
ssuukk said:
Well, read this, see if EventBus could solve your problems:
http://xenoamp.info/index.php/capta...-eventbus-a-k-a-intents-you-shall-not-paaasss
Click to expand...
Click to collapse
way too nerdy for me.. I haven't started with broadcasts yet..
SimplicityApks said:
Not a really nice way, no. The simplest to do is with intents and if you want to pass something back with the startActivityForResult(intent) and then overriding onActivityResult.
Another possibility is to save the string in a text file and then open it from the other activity.
And Google is our friend: you can do this
Which means you create your class just with static variables and methods and access them without creating an object. But I don't think that's a good way to do it, if you have a simple String, do it with an Intent.
Click to expand...
Click to collapse
See here's the structure of my app:
activity 1: take input
activity 2 : choose game
activity 3: choose difficulty
activity 4 : start game
activity 5: scores displayed with the name entered in activity 1
If I use:
Code:
name=edittext.getText().toString();
Intent i= new Intent( activity1.this, activity5.class);
Bundle user = new Bundle();
user.putString("key", name);
i.putExtras(user);
startActivity(i);
It would immediately start activity 5 which I dont want...So what should I DO?
For récords you need persistence. Use XML files stored in application Folder (search for getexternalfiledirectory or something similar). Instead, you can use sqlite database, I think it's the best option.
Cheers
Sent from my SK17i using xda app-developers app
First of all, I wouldnt use so many activities, that's why dialogs were invented... They are a lot simpler to use because u can pass the values back. If the name the user enters is always the same (I guess so) you should save it in the SharedPreferences. This way you can also edit it in your SettingsActivity.
If you really want to do it with five activities you could still put everything in a Bundle and pass the Bundle through all the activities with intents if every activity gets the bundle from the last one and puts it to the intent to start the next one.
SimplicityApks said:
If you really want to do it with five activities you could still put everything in a Bundle and pass the Bundle through all the activities with intents if every activity gets the bundle from the last one and puts it to the intent to start the next one.
Click to expand...
Click to collapse
Yes I thought of it. Would be really tiring.
I am tryin to fix an app created by someone else so I need to follow the main framework of his app
prototype-U said:
way too nerdy for me.. I haven't started with broadcasts yet..
Click to expand...
Click to collapse
Don't start with them, they're not worth it!
Sent by automatic reply bot from my Galaxy S2
prototype-U said:
See here's the structure of my app:
activity 1: take input
activity 2 : choose game
activity 3: choose difficulty
activity 4 : start game
activity 5: scores displayed with the name entered in activity 1
If I use:
Code:
name=edittext.getText().toString();
Intent i= new Intent( activity1.this, activity5.class);
Bundle user = new Bundle();
user.putString("key", name);
i.putExtras(user);
startActivity(i);
It would immediately start activity 5 which I dont want...So what should I DO?
Click to expand...
Click to collapse
If you really want the full screen display without using dialogs, then fragments with a viewpager would be your go-to.
A pager with multiple fragments using the fragment manager to replace each fragment into your content view is ideal.
That way, you're contained within 1 activity and don't need to pass data between fragments if you tie it back to the activity.
prototype-U said:
See here's the structure of my app:
activity 1: take input
activity 2 : choose game
activity 3: choose difficulty
activity 4 : start game
activity 5: scores displayed with the name entered in activity 1
If I use:
Code:
name=edittext.getText().toString();
Intent i= new Intent( activity1.this, activity5.class);
Bundle user = new Bundle();
user.putString("key", name);
i.putExtras(user);
startActivity(i);
It would immediately start activity 5 which I dont want...So what should I DO?
Click to expand...
Click to collapse
Well I'm not sure if you want the app to be like this, but you could try to pass the string along every activity. Like this:
Activity1 starts activity 2 while passing the string.
Activity 2 starts activity 3 while passing the string, etc until you reach activity 5.
The only problem is that you would need to go through every activity.
Sent from my awesome fridge
prototype-U said:
See here's the structure of my app:
activity 1: take input
activity 2 : choose game
activity 3: choose difficulty
activity 4 : start game
activity 5: scores displayed with the name entered in activity 1
If I use:
Code:
name=edittext.getText().toString();
Intent i= new Intent( activity1.this, activity5.class);
Bundle user = new Bundle();
user.putString("key", name);
i.putExtras(user);
startActivity(i);
It would immediately start activity 5 which I dont want...So what should I DO?
Click to expand...
Click to collapse
I know this isn't the best option or a reliable one but try a static field declared as public in the class where you take inputs and access them when you need it
Sent from my GT-S5302 using Tapatalk 2
I am not sure about ur Problem, But here is guide
One more best way to send data from one activity to other as well as Send data to main thread from other thread
is Handler U can send messages to Static handler of a activity from any of ur application...
Its so far best way i followed to alter my UI as well send data from Background service to my Main activity
CoolMonster said:
One more best way to send data from one activity to other as well as Send data to main thread from other thread
is Handler U can send messages to Static handler of a activity from any of ur application...
Its so far best way i followed to alter my UI as well send data from Background service to my Main activity
Click to expand...
Click to collapse
However, that is bad practice. What if you need two Activities like this at the same time?
Additionally, the Handler will be running in the background, even after the Activity is destroyed.
First of all I know that this title creates a lot of questions.
The problem is exactly what the title says.
While developing apps, you make mistakes (NullPointers etc)
They are thrown when the occur, normally.
Today, it's different, sometimes, when Android (Studio) feels like it wants to help me, it redirects the debugger to a class that is used to "crash" the app at an exception.
With the cool features of Android Studio, you are able to see the content of the strings during debugging. With that feature, I've been able to solve most of the problems.
But now, I ran into a problem that doesn't have the solution above.
When the app "crashes" the screen stays white, and nothing is outputted in any logcat.
All it says is
"D/AndroidRuntime: Shutting down VM"
Is this a bug in Android Studio or in Android?
Hello,
First of all make sure that you have the latest version of Android Studio.
When the app crashes is selected application above the logcat (there is a spinner which says you what app is being displayed, does it say 'com.yourpackagename'? or does it say 'No Application'?) If so I think there is a bug in Android Studio, I have faced it too several times. When your app crashes it force closes the app?
You can try these things:
Unplug your phone and plug it again and wait for a confirmation on the device's screen.
If the confirmation dialog is not showing up, while the device is connected via USB, go to the Settings and disable the USB debugging mod. Wait a few seconds and re-enable it. Wait for confirmation on the device. If still not shows. Close the Android Studio and repeat the above steps. Reopen the Android studio. Run your app, if still not getting logcat you can try getting it manually like this:
Go to the folder where adb is installed (Normally on Windows C:/Users/Username/Appdata/Android/sdk/platform-tools) via terminal with admin rights .
Run cmd.exe as admin, type:
cd ../../Users/Username/Appdata/Android/sdk/platform-tools (where Username is the username of your windows account.)
Type adb devices while your phone is connected via USB with debugging on
See if it says unauthorized, if not, you are good to proceed to the next step.
Type
adb logcat > mylogcat.txt
And quickly open your app to go to the app that causes the crash. Try to cause the bug. When the bug occurs press Ctrl+C
Now your logcat is in the mylogcat.txt within the same folder of adb.
If you need more help extracting the logcat via the above way (manually) let me know
Hmm, at the moment the crash occurs, the app freezes and stays white. Only the main thread though. I've checked the logcat in Android Studio, the app is my app, and the doesn't really matter. It shows nothing.
No logcat not even with the cmd option.
Could it be that my custom rom is causing difficulties?
Thanks,
Tim
Try to place breakpoints in every line on your code. Try step by step to run the app line by line and where the execution flow jumps some lines of code that it shouldn't or stucks at a line of code whithout going to the next lines of code that it should, there should be the problem.
Are you doing intense work on the main thread? I had experienced an issue where I was doing heavy work on a view's onTouchListener and because the touch events were bottlenecking, my UI stuck, and on logcats I didn't got any error, but got a warning that the thread is shutting down due to the fact that the onTouchListener was busy to handle the touch event.
The best option and the most reliable you have now is to debug your app line by line as mentioned above. If it does not help, try commenting lines of code where you think you may be doing intense work or inside listeners and see if your app still crashes. Then uncomment blocks of code and run again and again to see until it crashes again. In the last block of code that you uncommented should be the error.
That way you can limit your search on these lines of code.
If you could further provide any detail of what are you doing in the main thread or any sample code, I will be able to help you further
I do not think that it is related with the custom rom, otherwise logcats would have some errors of missing packages etc
Well, using breakpoints I was redirected to the piece of code that is used to output exceptions. I didn't had a breakpoint there so I don't know why it went that deep. I'm doing heavy for with the runtime.exec command.
I've discovered the exception that was thrown when I posted this question, and the exception wasn't printed anywhere so I don't know why this isn't working. I was getting the java.lang.NumberFormatException exception. This will cause the app to crash, right?
If not how do I 'enable' that?
Thanks
If you are catching that exception the app will not crash. (try catch block). It may crash when any variable from that try catch block had that Number format exception, but when referencing it from outside the try-catch block.
Numberformat exception is occured when trying to convert String to Integers or a Number, and the string does not match the Integer format. E.g. Integer.parseInt("4.3") will throw that exception.
To enable the crashing of the app during that exception, do not catch that exception (NumberFormatException). If you are catching Exception (it is a superclass of NumberFormatException and is more general, it includes this exception too) then again your app will not crash.
If you are catching any of these exceptions, your app will not crash (may crash inside the catch or outside the try catch block)
Exception
RuntimeException
IllegalArgumentException
NumberFormatException
Possibly, a string conversion to Integer or Long or Double or Float may be causing your problem The errors are "silenced" due to the try-catch block Are you printing the exceptions with e.printStrackTrace in the first line of the catch block? (e is the Exception caught)
Hmm, I'll take a look at my code so check if I used a try and catch block.
Thanks!
It was the fault of Google Analytics, I had exception reporting on and that was causing the app to freeze instead of crashing and showing the exception.
Thanks!!