Android :: On Which Thread Callbacks From Sensors Executed?
Aug 17, 2010
We are supposed to make UI actions only from the main UI thread. But it is not clear to me if callbacks like LocationUpdateListener (and other callbacks from sensors) are already in the UI thread or they require special care to access the UI components.
View 2 Replies
Jul 23, 2010
I have an AIDL service that is intended to be used by both out-of- process remote users and in-process local users. As a result, my common interface methods will either be invoked on the UI thread or in a binder background thread. The logic between the two is not the same. How do I distinguish between these two cases?
View 4 Replies
View Related
Nov 7, 2010
On what thread are event handlers (like onAnimationEnd, onTouchEvent, onKeyEvent, onClick) executed? Are they called sequentially or can two handlers may execute simultaneously?
View 1 Replies
View Related
Oct 12, 2010
There are a lot of Android SDK APIs where callback handlers are registered. For a concrete example, with MediaPlayer you can set an onCompletionListener callback. Will these callbacks be called from the main (UI) thread? If the answer is "it depends", then I'm looking for some general rules for what callbacks will be called from the main thread versus another thread. The SDK documentation doesn't seem to spell it out. (Maybe I missed it) It seems important to know, because if I'm guaranteed main thread callbacks, then I can skip some thread synchronization on data shared between different places in code. If I'm forced to be pessimistic out of ignorance, then I have to write extra synch block code and worry about deadlocks, data integrity, and reduced performance.
View 4 Replies
View Related
Feb 25, 2010
Here I update my world to include the canvas size. world.getViewPort().updateViewPortSize(width,height); Is there a better way to do this? Is there a way that I can automatically update my world object without having to manually call it in the setSurfaceSize method but instead call it from My world class? My guess is that I can use some sort of callback, but I don't understand them!
/* Callback invoked when the surface dimensions change. */
public void setSurfaceSize(int width, int height) {
// synchronized to make sure these all change atomically
synchronized (mSurfaceHolder) {
mCanvasWidth = width;
mCanvasHeight = height;
world.getViewPort().updateViewPortSize(width,height); }
View 1 Replies
View Related
Apr 6, 2009
I need to create a daemon to monitor traffic, and I am using similar method as uuidd.rc to create a daemon. However, I can't the way(code) that the Uuidd.rc can be started? neithor from init.rc or system ("Uuidd.rc").
can someone let me know how the daemon or (.rc) can be executed? code....
View 2 Replies
View Related
Oct 18, 2010
I am trying to update TextView in my Activity with text messages from DatagramServer ( see below) The problem I have is that "backgound UDP server receives plenty of traffic, but onProgessUpdate is ever executed only once so only the first of the messages appear in the TextView.
public class MyActivity extends Activity {
TextView txtStatus; // txtStatus initialized
new BackgroundAsyncTask().execute();
public class BackgroundAsyncTask extends
AsyncTask<Void, String, Void> {
public static final String SERVERIP = "127.0.0.1";
// 'Within' the emulator! public static final int SERVERPORT = 2222;
private DatagramSocket socket;
protected Void doInBackground(Void... params) {
try { InetAddress serverAddr = InetAddress.getByName(SERVERIP);
Log.d("UDP", "S: Waiting for connection...");
socket = new DatagramSocket(SERVERPORT, serverAddr);
while(true) { byte[] buf = new byte[1024];
DatagramPacket packet = new DatagramPacket(buf, buf.length);
Log.i("telemetry server", " waiting for packet");
socket.receive(packet);
Log.i("received", new Integer(packet.getLength()).toString());
Log.i("UDPServer received:", new String(packet.getData()));
publishProgress(new String(packet.getData()));
} } catch (Exception e) { Log.i("Dbg server", e.getMessage());
} // end of try Log.i("Dbg server", "Dbg server: Done.");
socket.close(); return null;
} @Override protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
//it will never been shown in this exercise...
} @Override protected void onPreExecute() {
// TODO Auto-generated method stub
} @Override protected void onProgressUpdate(String... values) {
txtStatus.append(values[0] + " ");
} }
View 2 Replies
View Related
Oct 13, 2010
If it must implement with AIDL? And please kindly provide an example. There are several solutions, Does anyone know which is better?
View 1 Replies
View Related
Sep 18, 2010
I have an android application. Based on the current geo location of user, I want to fetch some remote data in background and store it. My implementation is: At specific interval a alarm fires up my service. Service uses an anonymous class to query current location and registers a locationListener callback. On call of onLocationChanged() I initiate the remote data fetch from server.
However once my service is done registering the location listener using anonymos class, it returns as expected; as it doesn't wait for callback to happen before finishing. Since callback takes some time and makes a call when service has already returned, it throws an error saying: java.lang.RuntimeException: Handler{43e82510} sending message to a Handler on a dead thread
Which is quite understandable. One quick workaround for me now is that I can use getLastKnownLocation from locationManager as that doesn't respond back by callback; but what if I do want the latest location right now, in a service and not activity? How can I wait for callback to happen and stop my service from returning.
Also, at what point does lastKnownlocation gets updated? Everytime GPS registers a new location; does it update it? What I want to know is that if it's not latest can it still be closed to latest? As I didn't see an option in android emulator to configure the time period between subsequent updates.
View 1 Replies
View Related
Oct 10, 2009
A simple question: How do I register for multiple sensors? I just switched from registerListener(SensorListener listener, int sensors, int rate), which is deprecated, to registerListener(SensorEventListener listener, Sensor sensor, int rate). Previously, I could use " | " to indicate multiple sensors, but now " | " is undefined, so how?
View 4 Replies
View Related
May 21, 2010
I'm programming an Augmented Reality application. It's development it's in an advanced state but I can't place the icons on the screen so still as anothers programs does (Layar, in example). This is because of the continuous variations of the sensors. I've tried the three modes of the sensors (FAST, GAME, and NORMAL) but I only get them to move more or less fast. The shivering is the same at different speed.
Finally I thougth I could reach my goal with a digital filter, averaging historical values. But again the icons continues moving, specially the most far placed ones (in the z axis). Please, could some one help me with some clue?
View 8 Replies
View Related
Sep 17, 2010
I am doing authentication with a third-party site that's supposed to redirect back to my app with auth token (OAUTH).
I have the callback working properly if I open the 3rd party site in a separate browser process via this.startActivity(new Intent(Intent.ACTION_VIEW, uri));
But, if I embed a WebView component in my layout, and open the url in that, the callback does not work. Webview says "You do not have permission to open myapp://callback?token=...." and quickly refreshes to "Web page not available...temporarily down..."
View 1 Replies
View Related
Jul 7, 2010
I'm working on a service for my application whose purpose is to allow easy access to various web services we are running. The service is used to maintain a login state across any applications that want to use it so the user only has to log in once when the service is first started.
What is the best way to go about making the service run asynchronously and call back to the application when it is finished. Currently I am using static classes that extend Thread such as
CODE:.....
And to make it easy to call
CODE:....................
But these functions can only be called by my own application. I want anyone to be able to make a one or two line function call and be able to handle the response easily, preferably in a simple callback method.
I figure it has to be done using Intents to start the Threads, but if I do that I can't pass a callback.
View 2 Replies
View Related
Jan 12, 2012
Last night i have downloaded Dolphin to play Wii Games. As you can imagine, play with the mouse is not as comfortable to emulate Wiiremote.
My idea is basically:
Control WII emulator with Android Sensors (As accelerometer, gyroscope, inclinometer) like Wiimote does
It seems to be quite interesting, I think that may be connectable by wifi and bluetooth with receiver (pc).
View 2 Replies
View Related
Sep 28, 2010
This is the class that calls my Service:
public class TicketList extends ListActivity {
private ArrayList<Tickets> alTickets = new ArrayList<Tickets>();
private boolean listCreated = false;
private static Drawable background = null;
private Resources res;
private Tickets ticket = null;
private TicketConnector localService;
[Code]
Here is the output of LogCat at verbose mode while activating the TicketList Activity:
09-28 23:22:11.420: INFO/ActivityManager(795): Starting activity: Intent { cmp=org.mw88.cmdb/.gui.TicketListActivity }
09-28 23:22:12.340: WARN/ActivityManager(795): Binding with unknown activity: android.os.BinderProxy@4410bf30
09-28 23:22:16.090: INFO/ActivityManager(795): Displayed activity org.mw88.cmdb/.gui.TicketListActivity: 4606 ms (total 4606 ms)
View 1 Replies
View Related
Feb 18, 2010
private class ExecuteLocations extends AsyncTask<String, Void, Void>{
private final ProgressDialog dialog = new ProgressDialog(ListProfiles.this);
protected void onPreExecute() {
//this.dialog.setMessage("Starting pre-execute...");
//this.dialog.show();
} @Override protected Void doInBackground(String... arg0) {
check_profiles_lm=(LocationManager) ListProfiles.this.getSystemService(LOCATION_SERVICE);
myLocListen = new LocationListener(){
@Override public void onLocationChanged(Location location) { HashMap params = new HashMap();
params.put("lat", Double.toString(location.getLatitude()));
params.put("long", Double.toString(location.getLongitude()));
postData("http://mydomain.com",params);
} @Override public void onStatusChanged(String provider, int status,Bundle extras) {
} @Override public void onProviderDisabled(String provider) {
} @Override public void onProviderEnabled(String provider) {
} };
check_profiles_lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30000, 0, myLocListen);
return null; } protected void onPostExecute(final Void unused) {
if (this.dialog.isShowing()) { //this.dialog.dismiss();
} //Do something else here
} }
Basically, my objective is:
Constantly post the latitude/longitude to my website every minute or so. Of course, I want to do this in another thread, so it doesn't mess up my UI thread. This AsyncTask is supposed to solve that but it's bringing up an error and I don't know why. What can you do to accomplish my objective? It's very simple...just scan location and post to web every minute, in the background. By the way, my onCreate method is like this. That's basically it.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new ExecuteLocations().execute();
setContentView(R.layout.main_list);
}
View 2 Replies
View Related
Nov 13, 2010
I am looking for a way to get sensors' data ( especially Accelerometer) directly without using Listener approach. Actually I need to have the data really fast! I can not find any way to read sensor data by myself. Anybody knows anything about it? Is it possible to read data with more than 50Hz?
View 9 Replies
View Related
Sep 23, 2010
I just switched over from iPhone to Android and am looking for something similar to where in the iPhone SDK, when a class finishes a certain task, it calls delegate methods in objects set as it's delegates.I don't need too many details. I went through the docs and didn't find anything (the closest I got was "broadcast intents" which seem more like iOS notifications).Even if someone can point me to the correct documentation, it would be great.
View 1 Replies
View Related
Mar 19, 2009
I am now beginning an app which will use the compass and tilt sensors to determine a persons heading and line of sight. Can I assume the sensors on devices such as the G1 are fairly accurate or can I expect to run into problems such as the compass being 5-10 degress off etc?
View 4 Replies
View Related
May 24, 2010
I have following code:
CODE:...........
Code is working but here goes my problem: when I call it from main activity in this way:
CODE:........
Then i can see 10 times result of 'doing sth else!!!' and when loop is over i can see then result from activity. So sensor activity waits for some reason and then when main activity has nothing to do, sensors are doing their job.
of course I have well implemented: onActivityResult(int requestCode, int resultCode, Intent intent)
I want to read sensord data directly, not using listeners, is it possible?
View 1 Replies
View Related
Dec 8, 2009
Anyone know if it's possible to obtain the physical height or altitude of your device, using the sensors or by any other means?
View 4 Replies
View Related
Jan 20, 2009
The accelerometer turns off when the screen is off. I'm guessing this is a bug but I haven't seen it logged. Am I missing something?
Perhaps the power management features need some improvement - the ability to specify what components are needed during a partial_wake_lock so that power can be conserved as efficiently as possible.
BTW, there is a bug logged noting that onSensorChanged() continues to be called for the orientation sensor (during sleep) but the values are not being updated.
View 6 Replies
View Related
Jul 9, 2010
I'm implementing the onBackPressed() method in my activity. It's crucial to my app that I have this functionality. But, the control never enters this function. It enters onPause() instead, when I press the back button. But the problem is I can't have the same logic in onPause() because when I call another activity, the current activity calls onPause() and I don't want it to execute what should be in onBackPressed().
public void onBackPresed(){
Log.d(TAG,"inside onBackPressed()");
if(STATE == PREVIEW){
} }
View 3 Replies
View Related
Jan 29, 2010
I can't seem to find this info on the droids temperature sensor (the one available in the SDK):
Does it indicate ambient temperature or is it the temperature of the phone or chip?
Also, does the pressure sensor indicate atmospheric pressure?
View 3 Replies
View Related
Jul 15, 2010
Is there a way to obtain the time zone from the callbacks received
void onLocationChanged(Location location)
using the time information that can be obtained from the location parameter
long Time = location.getTime();
Or if there is another way please provide info!
View 2 Replies
View Related
Sep 10, 2009
In Android , Native code is written as follows.
JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject obj) {
printf("THIS IS TEST");
}
View 7 Replies
View Related
Sep 15, 2010
I try to execute shell commands, this does work as it should. Even the result comes back (as is see on LogCat). The problem ist the last line of the result. Every time a readLine() on the last line occurs (which shouldn't occur, temp should be null), the app hangs forever and doesn't come back from the readLine call. Maybe you find the error. I tried readUTF and standart read(), all the same problem. And yes, the app got su-rights.
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
DataInputStream osRes = new DataInputStream(process.getInputStream());
for (String single : commands) { os.writeBytes(single + " ");
os.flush(); String temp = new String();
while( (temp = osRes.readLine()) != null) { Log.v("NITRO", temp);
result2 += temp + " ";
} } os.writeBytes("exit");
os.flush(); process.waitFor();
} catch (IOException e) { Toast.makeText(Main.this, "Error", Toast.LENGTH_LONG);
} catch (InterruptedException e){ Toast.makeText(Main.this, "Error", Toast.LENGTH_LONG);
}
That is the StackTrace where it hangs when I stop debugger when hanging:
OSFileSystem.readImpl(int, byte[], int, int) line: not available [native method]
OSFileSystem.read(int, byte[], int, int) line: 118
ProcessManager$ProcessInputStream(FileInputStream).read(byte[], int, int) line: 312
ProcessManager$ProcessInputStream(FileInputStream).read() line: 250
DataInputStream.readLine() line: 309
Main$2$1.run() line: 84
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
View 1 Replies
View Related
Aug 11, 2009
I am having a difficult time figuring out a way to read the sensor data from a home screen widget. I can successfully create a home screen widget that extends AppWidgetProvider. I can successfully create a stand-alone application that reads sensor data (extends Activity). What seems to be impossble (for me) is combining them into a home screen widget that reads sensor data. The classes that you have to use, like SensorManager, SensorListener all seem to require an Activity which the AppWidgetProdiver doesnt have. I have also tried keeping my sensor data reader in a separate class that extends Activity and then instantiating that class in my widget. Makes sense in my head but no data is ever read from the sensors.
View 6 Replies
View Related
Aug 3, 2010
I want to get the size of a view that is in my activity but I am not able to get that information in any of the activity lifecycle callbacks (onCreate, onStart, onResume). I'm assuming this is because the views have not been drawn yet. At what point are views drawn and is there a callback I can put my code so I can get the size of the view?
View 2 Replies
View Related
Jun 1, 2010
I was wondering if it's possible to call specific methods defined within the AsynTask class from another class and/or service ?
In my specific case I have a Service playing some sounds, but the sound is selected from a List with available sounds...
When a sounds is selected it is downloaded from my home server, this takes some time (not much, let's say around the 3-4 seconds, the sounds/effects aren't big in size)...
So my problem at the moment is that I have a service to play those sounds, and when I select one I wanted to show a progressdialog... The way (if I understood correctly) is to use an AsyncTask, but the only thing the AsyncTask will do is telling my Service to play a specific sound from my server... So there is no "callback" from the service to the Asynctask...
How can I call a running AsyncTask, which sits in another class, and tell him all work is done and thus he can stop showing the ProgressDialog ? Or am I over-engineering it and there are other ways ?
View 2 Replies
View Related