Force redraw of View - Hero, G2 Touch General

hi guys,
i hope this is the correct section in the forum. I have a question concerning to an application some friends and me are developing currently. We have class which extends View.
Now, in regular intervals, this View object (which is a subcomponent in an Activity using Relative Layout) has to be refreshed. The refresh itself is done by mView.postInvalidate in a background thread (lets say, every 300ms). The problem we noticed is, that the postInvalidate() as well as the invalidate() (which we could use if the UI Thread would call it) do NOT force a refresh (thus, calling onDraw(canvas)) immediately! Unfortunately, the view is only updated every 1-3rd second..
Does anyone of you have an idea, how to force an android view, to refresh immediately?
Thanks,
Felix

possibly anddev.org might be a better place?

youre right i think, i posted it also there, thanks!
http://www.anddev.org/view-layout-resource-problems-f27/immediately-view-redraw-problem-t15425.html

you are placing this inside a specific _device_ development forum. It are mostly ROM builders (and users) you are going to find here.
Place questions about app-developing in the genera Android dev forums here on XDA, that's where all the app builders / hackers are

Related

[Q] Android app auto starts again when device rotated

Hello all,
I've written a simple audio player app and testing it in Samsung Galaxy S.
It is a simple app with can create playlist and some buttons to play the mp3 file.
However, there's a funny bug in it.
After starting the app, whenever I rotate the phone, the running app will launch another instance of the app. If I rotate again, another instance (3rd) would be started. So u can hear 3 copies of the same audio being played simultaneously.
What could be wrong with it?
Is there some code which can prevent program re-entry?
Thanks.
It's not a bug, that's the way andorid OS works. You need to account for this in OnCreate for your activity. I assume you are spawning off the actual playing of the MP3 in a thread or service. You need to check if the service is already running in OnCreate and attach, else spawn a new one.
Hello Gene,
How do I check if an activity is already running?
I could not find the answer on the android developer page (the topic on application fundamentals).
And no, I'm not converting it to a service yet as this is my first app.
Haven't explore service yet.
Thanks.
I read on another article, a simple way to prevent this is to add overwrite the onConfigurationChanged function
@Override
public void onConfigurationChanged(Configuration newConfig) {
//ignore orientation change
super.onConfigurationChanged(newConfig);
}
and modify the androidmanifest.xml
<activity android:name="selectCategories" android:configChanges="orientation|keyboardHidden"></activity>
But it still launch multiple instance of the app.
Thanks.
This is a good question and should be in an FAQ somewhere.
As already mentioned, changing the display orientation basically restarts your app. Read the Android dev page on Activity lifecycle for more info.
A short answer for your question is: the Bundle parameter for onCreate() will be null when your app is first run. When your app is paused and restarted, that Bundle will be non-null. You can store data in that Bundle by overriding onSaveInstanceState(), then check for that data in onCreate(). It's a good idea to learn how to do this (save/read app data on pause/restart). Once you start testing apps by rotating the display at various times, you'll find a lot of them FC at unexpected places.
This is indeed a topic that keeps surprising people who are new to android (ahem, like me 4-5 months ago ).
The solutions above are perfect, however in certain situations there's another trick that might make your life much easier. I suspect it won't help you in this case, but it might help others who tackle the problem and see this thread.
Certain applications, mainly games, should be fixed in a single orientation. I.E. you won't be playing angry birds on portrait - that game is locked to landscape, as it should be. In order to lock your activity in a certain orientation you add this attribute to the manifest under the Activity tag. So a standard activity might look something like that, combined with the ignore tag from the previous posts:
Code:
<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
android:name="whatever">
The great thing about this combination is that your activity will not restart at all when the phone is rotated. Of course, for a standard activity you'd usually want to support both landscape and portrait, but if you need your app to be in a fixed orientation this is the way to go - no weird FCs or annoying bugs
Hi,
How do I check the bundle?
And also, what to do if the bundle is not null? Just return?
Thanks.
regards
r_p_ang said:
This is a good question and should be in an FAQ somewhere.
As already mentioned, changing the display orientation basically restarts your app. Read the Android dev page on Activity lifecycle for more info.
A short answer for your question is: the Bundle parameter for onCreate() will be null when your app is first run. When your app is paused and restarted, that Bundle will be non-null. You can store data in that Bundle by overriding onSaveInstanceState(), then check for that data in onCreate(). It's a good idea to learn how to do this (save/read app data on pause/restart). Once you start testing apps by rotating the display at various times, you'll find a lot of them FC at unexpected places.
Click to expand...
Click to collapse

[Q] long time reader, first time poster!

Hello hello! Ive been reading up on the forums for about a year now (sorry for the leeching!), but it's my first time posting.
First I'd just like to introduce myself as a proud owner of an xperia play r800i (not yet rooted).
Here are my questions if anyone would be kind enough to answer:
1. Is there a way to show more than 8 apps in the Recent Apps list? (where you long hold the home button). Oh and without the use roms, apps, and other substitutes. Perhaps somewhere in the manifest?
2. Also how does one exclude certain applications and tasks from appearing on the Recent Apps list?
Hopefully I posted this in the right section, couldn't decide between the general section or development section, so apologies if I mis-posted.
You did well. Development section is a section you want to avoid in order to ask questions and so on. Ideally, only people who are bringing something to the table (ROMs, programs, kernels) should start threads there.
That said, there are third party Apps with more recent Apps to show. Launcher Pro allows a swipe function which shows the 16 most recent Apps, but you can't summon them from the Home button easily like the native function.

[Q]New to the forums, and Android developement

Good afternoon everyone! I have been looking for a forum to hit up that isn't stack-overflow for android developing and a friend pointed me here. Currently my experience with android is very minimal, I am working on a simple (simple is read, "Dear god what did I get myself into") project for school with no background in this sort of platform. I program in PHP and C# primarily and thought that this project would be a fun way to immerse myself in Android.
The application I am writing is a sort of life style app to gather daily eating habits from the user in an attempt to make you feel bad about your terrible eating choices and get you to eat better. If anyone is familiar with Good Eats I am basing the app around Alton Brown's 4 list diet.
Here is where the issues have started:
I constantly feel like I am coding myself into a corner and have started over a number of times, there seem to be many ways of gathering this information from the user but non of which seem very cut and dry with database interactions.
What I am looking for is a way to gather the day and list choices from a user (for the lists I was using dialog check boxes spawned from buttons but this doesn't seem to be the best way to do it as I cannot figure out how to store the checked off boxes within the dialog).
So my noob question is, are there any tutorials dealing with basic data gathering and storage?
Thanks for your time and look forward to hanging out on these forums more regularly.
ZachM86 said:
So my noob question is, are there any tutorials dealing with basic data gathering and storage?
Click to expand...
Click to collapse
Try this link -- developer.android.com/training/basics/data-storage/index.html
ZachM86 said:
Here is where the issues have started:
I constantly feel like I am coding myself into a corner and have started over a number of times, there seem to be many ways of gathering this information from the user but non of which seem very cut and dry with database interactions.
What I am looking for is a way to gather the day and list choices from a user (for the lists I was using dialog check boxes spawned from buttons but this doesn't seem to be the best way to do it as I cannot figure out how to store the checked off boxes within the dialog).
Click to expand...
Click to collapse
this may help:
create variables for each checkbox that can be checked
in your dialog interface onClick if (isChecked) { variable = 'which';}
then enter it into your database when submitted. Then when you query just correlate the variable to the corresponding string name
this may help as well (go down to the multi/single choice list)
http://developer.android.com/guide/topics/ui/dialogs.html

[Q] Com2USPoker? Not in GroupPlay? And other first time Andriod user questions...

Hi everyone,
Just transferred from iPhone 4 to the Galaxy S4 and am experiencing comething of a shock between the two operating systems. I am NOT going to be rooting or changing the factory OS in any way, just using the sotck OS and systems provided by Samsung. My biggest questions are:
1) Disabling/Enabling pre-installed apps (AT&T junk, etc.): If I disable a pre-installed app, find that it affects a function I like (Google I'm looking at you...) and then re-enable it, will that adversely affect my phone in any way? Ie. will I get back the funcionality that I originally had? Can I brick my phone completely accidently by disabling a key application?
2) Com2USPoker: WHERE IS THIS APP? I like to know that every function on my phone works before committing but I cannot for the life of me find this app. It is not in GroupPlay, App screen, anywhere but Application manager and it says that it is enabled. Does the App only show up in GroupPlay when there are multiple samsung devices connected to the GroupPlay app? As a pefectionist, this is really bugging me that I cannot find this app.
Any advice would be appreciated! Please go easy on me as I am new to Android
I suggest you read the "pinned" threads in the General and Q & A sections before you do ANYTHING to your phone. Also, use the Q & A section as an area to bring up or ask about new or previously un-discussed issues and topics only after you have read and searched for existing topics and answers. Searching, reading, and learning will get you what you need around here.
If I were you it'd stick with the iphone. This is a development forum. Not a user forum.

[Q] Andriod Quiz App - Radio Buttons

Okay, so I've been surfing the web for a few weeks/months now but I can't seem to find any decent tutorial for my query.
With high hopes, can anyone show me how to do it on a single activity with at least 10 questions each?
I'm currently developing an M-Learning application. So aside for all the reading materials and somewhat simulations,
I need to present a quiz that will ask users at least 10 - 15 items per chapter.
I'll be presenting it on a graph as well for the user's profile. (But that's another issue I'd tackle later on)
Currently, all I have now was moving from one activity to another and vice versa.
Can anyone please guide me? I'd modify this if it doesn't clarify anything.
Please take interest. Am still a student though.
iamreverie said:
Okay, so I've been surfing the web for a few weeks/months now but I can't seem to find any decent tutorial for my query.
With high hopes, can anyone show me how to do it on a single activity with at least 10 questions each?
I'm currently developing an M-Learning application. So aside for all the reading materials and somewhat simulations,
I need to present a quiz that will ask users at least 10 - 15 items per chapter.
I'll be presenting it on a graph as well for the user's profile. (But that's another issue I'd tackle later on)
Currently, all I have now was moving from one activity to another and vice versa.
Can anyone please guide me? I'd modify this if it doesn't clarify anything.
Please take interest. Am still a student though.
Click to expand...
Click to collapse
Since you have a quiz app I'd recommend a swipe view with 4 radio buttons and a spinner with the chapter in the action bar or chapter list in the navigation drawer. Use 1 fragment and dynamically change the text for each fragment and inflate the swipe views. That way lesser resources.
Sent from my Moto G using XDA Free mobile app
Hi there once again.
I was able to pull off the Swipe View. However, I wanted to ask if this scenario is possible.
I wanted to build the quiz in a single activity only. Is this possible?
Button A ---> QuizActivity(Set1)
Button B ---> QuizActivity(Set2)
I want the quiz to happen on a single activity only but with different set of questions as triggered by different buttons.
Is this possible? And how will I pull this one.
Thanks.
So you want to have a set of buttons and depending on the button (category of questions) clicked you want to start a quiz of that category?
Simple answer to your question though is yes, u can have a quiz in a single activity if you wish.
Sent from my GT-I9300 using XDA Free mobile app

Categories

Resources