Android :: Handling Expensive Operations In UI Thread

Sep 16, 2009

OK I'm reading this page:
http://developer.android.com/guide/appendix/faq/commontasks.html#thre...

The code is as in the example (see below). In my application, the worker thread has done loading of large bitmaps, and I need to notify the UI thread the filename of the bitmap that was loaded as they get loaded. How can I notify the UI thread of the filename of the bitmap just loaded? I can see anyway to for updateResultsInUi() to be able to take a parameter from the example below.

public class MyActivity extends Activity {
[ . . . ]
// Need handler for callbacks to the UI thread final Handler mHandler = new Handler();
// Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi();
} };
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
[ . . . ]
} protected void startLongRunningOperation() {
// Fire off a thread to do some work that we shouldn't do directly in the UI thread
Thread t = new Thread() { public void run() {
mResults = doSomethingExpensive();
mHandler.post(mUpdateResults);
} };
t.start();
} private void updateResultsInUi() {
// Back in the UI thread -- update our UI elements based on the data in mResults
[ . . . ]
}

Android :: Handling Expensive Operations in UI Thread


Android :: Best Way Of Handling UI Code From Thread?

Feb 7, 2010

I know how to use handlers to update UI elements such as progress bars toasts etc. The problem I am having is when the context goes away such as the user pressing the back button or the Activity finishing for some reason. This causes my application to crash often. I tried using
getApplicationContext()
(Thinking that this would be available throughout my entire application) but this did not work, ever - instead my application crashed! I put try catch blocks around all UI update code, this works but is it necessary? What is the bast way to handle this?

View 1 Replies View Related

Android :: SurfaceViews Handling / Thread And General Game Design

Jul 14, 2009

I'm a new Android developer. I would like to make a simple game using the SurfaceView (Canvas drawing).the game has a a custom Object name Box. Box can draw itself and need to get an event when it is clicked. when it does, there is an animation sequence coming out of the box like a "jumping clown". I have several Boxes on the screen when each of them can be activated. Several Boxes animation can also be presented simultaneously.Here it gets tricky: Since I have a "complicated" animation sequence, each Box extends SurfaceView. The problem is I haven't figured it out how can I handle several SurfaceView's drawing using only one Thread (in order to present an animation I need to use one) and also how can I get the onClick/ onThouch event from my Activity to each of my Boxes.

The LunarLanding example in the SDK uses only one Thread but also uses only one SurfaceView which manage the animation of the game components (there are no several game components SurfaceViews). Also, there is no need to get onTouch event, so this example doesn't match to my case. I have several questions about what is the right approach do code this:

1. Should I use Box extends SurfaceView?

2. Can SurfaceView gets user events like onTouch/onClick?

3. Is there a way to add to the "main" SurfaceView another SurfaceView (Box)?

4. If none of the above questions is positive, should I use one SurfaceView (and one Thread) and try to map the other Boxes on the screen for user event handling. I mean Box only paints itself but the user event is being handled by me (not by the OS).

5. Should each Box (SurfaceView) should handle it's own Thread in case of animation (it is not good design but it is also an option)?

6. do you have any other proposal?

View 4 Replies View Related

Android :: How To Distribute Expensive App?

Aug 21, 2010

I have a $300 iPhone app that I might like to port to Android.It is for a very narrow set of users, so no matter how low I make the price, I will never sell very many.But for those few users, it is definitely worth it, as evidenced by my iPhone sales.So the $300 price point is necessary. However I have heard that the Google Android Market puts a limit of $200 on apps.I have also heard that it is possible to distribute apps independently of the Market, in which case I suppose I could charge as much as I wanted. But then I would have to devise my own licensing scheme.Are these assumptions right?

View 10 Replies View Related

Android :: Least Expensive Phone With OS?

Nov 12, 2010

I'm looking for a Verizon phone that I can afford to buy without the contract. Can someone either list for me the phones that use the Android OS or tell me the least/less expensive ones? I've been having trouble finding this information.I was at the Verizon store today and liked the Motorola Citrus. I didn't realize until I looked it up later that it was released just yesterday. Any info on this phone? Are there even less expensive phones?Also, do all android phones have google maps/gps? Can the google browser be used with all of them?

View 4 Replies View Related

Android :: Least Expensive AT&T Or GSM Phone Besides G1?

May 27, 2010

Just need a phone for 2 months but it has to be an Android phone, any suggestions for what to look into that is GSM unlocked or locked to AT&T?Only other requirement is that it can run Google Voice.

View 2 Replies View Related

Android :: RelativeLayout More Expensive Than LinearLayout?

Nov 1, 2010

I've always been using RelativeLayout everytime I needed a View container, because of it's flexibility, even if I just wanted to display something really simple.Is it ok to do so, or should I try using a LinearLayout when I can, from a performance/good practices standpoint?

View 1 Replies View Related

Android : Want Bluetooth Headphones / Are Expensive?

Apr 19, 2010

Anyone use in ear bluetooth headphones? Looking to buy some but never had a pair before so no idea who makes good bluetooth ones. Are they all really expensive? I wouldn't want to pay more than like 65 for a pair really..

Mainly to be used with my Desire.

View 10 Replies View Related

Samsung Captivate :: Gel And Hard Caces For Phone That Isn't Expensive?

Aug 17, 2010

What is a good case for the captivate that isn't expensive. I'm looking at gel cases and hard cases.

View 32 Replies View Related

Android :: Do Network Operations In Appwidget?

Aug 22, 2010

I'm developing a Android AppWidget for my application. For updating my appwidget I need to download data from network. But when I try to do that in onUpdate method, my appWidget is killed by Android system. I learnt that time consuming operations can't be done in receivers so I launched a service from onUpdate method and launched a thread from that. But still the problem persists.
Can anyone please let me know how to do network operations in Appwidget?

View 1 Replies View Related

Android :: Stop Threads With Long Operations?

Aug 28, 2009

Android experts, I have a tricky question that I would like some advice on. code...

View 8 Replies View Related

Android :: Composite Operations In Droid Canvas?

Mar 31, 2010

I'm just starting with Android development and I'm coming from JavaScript/HTML world so I'm currently investigating the possibilities of the Android SDK.

The HTML 5 canvas supports composite operations (See here).

Is this possible in an Android Canvas? I scanned the API of the Canvas class but couldn't find anything useful. I need at least the composite operation "source-in" or (if this isn't possible) "source-atop".

View 3 Replies View Related

Android :: JUnit Testing Database Operations?

Oct 18, 2010

I'm developing an Android application with database storage.

I want to test some classes that I use to access database.

I've found ActivityInstrumentationTestCase2 to test Activities but I haven't found anything to test classes.

How can I do that? I haven't used jUnit before.

View 1 Replies View Related

Android :: Low Level Operations With SD Card On Droid?

Nov 13, 2010

Is it possible to have low level access in Android with Java/NDK to create for example card scanner like scandisk or card defragmenter? I move a lots of stuff around my card and it gets fragmented quickly. I have experience with FAT32 defragmenting on Windows, but I'dliek to do this on Android.

View 2 Replies View Related

Android : Some Tutorials About Operations On Droid Emulator?

Mar 6, 2010

Can any body give me some tutorials about operations on the android emulator ?

View 2 Replies View Related

Android :: Avoiding Float Operations In Game Design

Jun 8, 2010

I've read this in a few articles, that one should avoid floating point operations within the physics update of a game.

But how do you really achieve this? Surely all half decent games are going to involve this kind of maths?

Does it mean, convert all your variables to int, or use double instead, or simply just cut it out as much as possible?

View 9 Replies View Related

General :: Galaxy S4 Android 4.4 / Program Crashes Operations

Nov 27, 2013

I've downloaded the android 4.4, but when i'm going to settings, security, the program crash the operations.

gti9505G
I9505XXUEMJ7
COMPILATION: KRT16S.S005.13116

I want to mark the option install apps out of play store.

View 1 Replies View Related

Android : Java - Implement A Run Method Of Thread If Create A Thread Global

Sep 7, 2010

How can I implement a run() method of thread if I create a Thread Global?

I mean If I create a Thread Globally then can I implement its run() method {" public void run()"} anywhere in my Application?

In the run() method I have to write the code to perform some action.

IF I can do it then please can anyone show me briefly how to do it particularly.

View 2 Replies View Related

Android :: Need Droid Apps That Alter Normal Phone Operations

Feb 19, 2010

So i was wondering if its possible to for an application that i would write to be constantly running in the background and alter regular phone operations. For example this could be something like as soon as you receive a text from anyone you forward it automatically to another number. Is something like this at all possible? Just to be clear I don't want to solve that particular problem through some other means, just want to know if apps can accomplish that. Also if that is possible is it possible for an app that i write to alter more immediate and instant things, like an incoming call.

View 1 Replies View Related

Android : Handle Messages Between The Main Thread(the Deafult UI Related Thread) And The User Created Gamethread

May 21, 2009

I am writing an application in which i need to handle messages between the main thread(the deafult UI related thread) and the user created Gamethread.

The requirement is like this.

An activity(say "Activity_X") is setting the view by "setContentView(some "View_Y")". In "Activity_X" i have implemeted "onCreateOptionsMenu()" and "onOptionsItemSelected()" fucntions for creating menus & a switch case for action to be taken on selecting those menus.Menu has items like "resume/pause/zoom/" .

All action to be take on selecting these menus are implemented in "View_Y" in a separate Gamethread by extending "Thread" class.

So whenever a menu is selected in "Activity_X" i need to send a message to "View_Y". And on receiving this ,a particular action/method should be called in View_Y(GameThread).

How can i achieve this using Handlers?Is there any other way of doing this? Please do share with me some code snippets for these.

View 3 Replies View Related

Android :: File Operations Extremely Slow On Emulator - Totally Stuck

Jul 19, 2010

I am finding that file operations are extremely slow on emulator. The same operation which takes less than a few seconds in a real device, takes minutes on an emulator. I am using a ubuntu linux machine with 2.4Ghz CPU, 2 GB Ram. I would really appreciate any help in resolving this. I am totally stuck due to this.

View 2 Replies View Related

Android :: Design Application With Multiples Activities And Operations Running In Background?

Nov 22, 2010

I am designing an app that will have some activities separated in tabs. Some of them will have to perform tasks in the background will the user is in another tab. What is the best strategy for designing an app like this? I was thinking about using a service but it can be killed by android dalvik, isnt it?

View 1 Replies View Related

Android :: Update ListView In Main Thread From Another Thread

May 27, 2010

I have a separate thread running to get data from the internet. After that, I would like to update the ListView in the main thread by calling adapter.notifyDataSetChanged(). But it does not work. Any workaround for that?

View 1 Replies View Related

Android :: Use Thread With SurfaceView - Ie Draw In Separate Thread?

Jul 22, 2009

I want to do the drawing in another thread to speed up the game(it is way to slow right now). I was told to do this but don't quite understand why that would speed things up. Is it GameView that should implement Runnable? Should I make the thread sleep when not drawing? where should I start the thread? package com.android.WWS;

import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.SurfaceView; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; import java.lang.Runnable; import java.lang.Thread;...................

View 4 Replies View Related

Android :: Least Expensive Android Phone For TTS SW Development

Oct 6, 2010

I know many developers ask about the best Android phone for development, but my question is almost opposite: What is the least expensive Android phone that I can get away with TTS (text-to-speech) and ASR (automated-speech-recognition) software development?

To further clarify my question:

Do all Android phones support
TTS and ASR?
Do all Android OS versions
support TTS and ASR?
If the answer to either of the above
is 'No', then which brand/model will
provide me with TTS and ASR functionality
while minimizing out-of-pocket
expense?

View 1 Replies View Related

Fake Permissions And Unauthorized Operations?

Apr 11, 2014

I do a lot of Android app testing. I use my regular phone, where I have my contacts and my regular gmail account. I never used a credit card on this account. I mostly use APK files to install the apps. I have 2 questions:

1. can an app display some permissions when installing, but have others hidden permissions ?

Example: instal APK file > says permissions "Network access" and that's it.

Can this app also read my data or make phone calls, even though those permissions were not displayed ?

What is I use an app to display ALL permissions ? Can it really display all or is there an way to still have hidden permissions ? I use Android 2.3.7 root and 4.1 no root.

2. Can an app make unauthorized hidden operations, like place phone calls or send texts or steal my gmail password ?

Like I said, I never used a credit card, so at least that's not a problem. But I have my SIM card - can an app place a value added call or SMS (I don't know the exact English term - expensive call), without me knowing about it ?

Or compromise my Gmail account ? I have an alternate email for recovery.

View 1 Replies View Related

General :: How To Get Tab Back To Normal Operations

Nov 1, 2013

How to get my tab back to normal operations.After changing fonts it req for restarting and it's just hanging at booting process. Try to recover but it doesn't work. Then i try to use install 86vebc ROM by using CWM v6.0.2.8 and now it's keep on entering CWM again and again even after rebooting.I only able to give the specification as below because i couldn't find the exactly brand or model for my tab.

View 2 Replies View Related

Android :: Suspend / Resume Thread From Another Thread In Same App

Feb 20, 2009

I need to suspend/resume a thread from another thread in the same process. I tried to look into thread apis,but I couldn't figured out a way to achieve this.Can anyone pls point me some references to look or give a tip to do this.

View 2 Replies View Related

HTC Droid Eris :: Remove Certain Texts From Thread In Easily Instead Of Whole Thread?

Dec 28, 2009

Does anyone know how to delete certain texts from a thread in an easy manner instead of having to delete a whole thread??

View 7 Replies View Related

Android :: Main Thread The Same As UI Thread?

Jul 16, 2010

The Android doc says "Like activities and the other components, services run in the main thread of the application process." Is the main thread here the same thing as UI thread?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved