Android :: Android: Why Doesn't Activity Appear Immediately After Calling StartActivityForResult
Sep 25, 2009
The application I'm currently working on consists of several dialogs and there is an issue with one dialog I still haven't found the cause.
Running the debugger the execution reaches the following two lines:
CODE:.................
And then the onCreate() method in DlgLogin class executes as well
But the login dialog doesn't appear. If I leave the device idle for such long period of time that the screen turns off and then press any button on the device to turn it on the login dialog appears.
The dialog of course should appear immediately but so far haven't found the cause of the problem.
View 1 Replies
Sep 3, 2010
I'm pretty sure that android services are going to be the end of me.I have almost no hair left after the last few days.At first I was having a heck of a time getting the service to bind on an onclick of a button, got that straightened out from help here yesterday. Now I actually want the service to bind in the onCreate() method of the activity. That part is no problem, works as intended.My service is actually a socket service to connect TCP sockets to a socket server that I wrote.If I put the call to the method from the bound service mBoundService.StartSocketServer() inside a button click, bingo, works great. But I need this to fire up immediately when the activity loads, so directly under my bindService() call within my onCreate() method of the activity.When I place the call to start the socket inside my onCreate() I get a force-close.
This method (StartSocketServer()) spawns a new thread then opens the socket on that thread to my remote machine.I'm guessing that the problem lies with the new thread generation before the activity fully loads not sure.LogCat is fairly cryptic here. It does say something about thread attach failed, then shows an uncaught handler exception that has "Caused by: java.lang.NullPointerException" within it.Again, if I put this call to the method inside a button click, I"m in business, if it's in the onCreate() it fails. Is there some way inside an activity (presuming that my assumption is correct that it needs to fully load before spawning a new thread) to call the StartSocketServer() after it's loaded: ala body.onLoad() in html?
View 1 Replies
View Related
May 17, 2010
I have MainActivity which is an Activity and other class(which is a simple java class), we`ll call it "SimpleClass".
now i want to run from that class the command startActivityForResult.
now i though that i could pass that class(SimpleClass), only MainActivity's context, problem is that, u Cant run context.startActivityForResult(...);
so the only way making SimpleClass to use 'startActivityForResult; is to pass the reference of MainActivity as an Activity variable to the SimpleClass
something like that:
inside the MainActivity class i create the instance of SimpleClass this way:
SimpleClass simpleClass=new SimpleClass(MainActivity.this);
now this is how SimpleClass looks like: code...
now its working, but isnt a proper way of doing this? I`am afraid i could have some memory leaks in the future.
View 2 Replies
View Related
Nov 23, 2009
I have two buttons in an activity/view A0, b1 and b2 that respectively starts (for result) the activities A1 and A2. After tapping/clicking b1 I quickly tap b2 aswell. The result will be that both A1 and A2 are launched. Is there any obvious way to not have this behaviour, i.e. to "lock" A0? I am thinking of overriding dispatchTouchEvent to consume everything after the call to startActivityForResult, but it seems a bit much...
View 2 Replies
View Related
Nov 12, 2010
I got a question about Activity.finish(). In my Android code, there are 4 activities(A,B,C,D). The starting activity A calls startActivityForResult(intent, reqCode) to start activity B. B starts C, and then finish(), not waiting for result. C does exactly the same as B, starts D and then finish(). D will return some result, by setResult(resultCode).
When my code runs and activity D returns some result, A will catch a RESULT_CANCELED on onActivityResult(), even if RESULT_OK is returned in D. I guess the RESULT_CANCELED is from activity B, which has been terminated before D returns a result, rather than from D.
But, my question is, why activity A catch RESULT_CANCELED after D returns some result, rather than immediately after B is terminated? And, what should I do to make A catch results from D? Do I have to keep B and C alive, to pass results from D to A?
View 2 Replies
View Related
Mar 23, 2010
I have 3 classes in my example:
Class A, the main activity. Class A calls a startActivityForResult:
Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");
Class B, this class is a TabActivity:
Intent intent = new Intent(this, ClassC.class);
tabHost.addTab...
Class C, this class is a regular Activity:
Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();
onActivityResult is called in Class A, but the resultCode is RESULT_CANCELED instead of RESULT_OK and the returned intent is null. How do I return something from the Activity inside a TabHost?
I realize that the problem is that my Class C is actually running inside of Class B, and Class B is what is returning the RESULT_CANCELED back to Class A. I just don't know a work around yet.
View 4 Replies
View Related
Jul 19, 2010
Is there an exception in the lifetime rules for a parent activity that's in the background after invoking startActivityForResult()? From my understanding, in low memory scenarios, the background activities are killed before the foreground. Does this rule still apply even if the background activity started the foreground one for the purpose of obtaining some result?
In this case, I think it would make sense for the foreground child activity to get killed first or to equalize the lifetime of the parent and child.
View 5 Replies
View Related
Aug 6, 2010
I have an activity A which uses SharedPreferences to share data with a service S, which is called from within A.Now when I call the stopService() method from A, the onDestroy() method in S is not called immediately.I thought that all the activities and services under a single apk run in just one process. Why then does the jump to onDestroy() not take place immediately instead I can see the output from onDestroy() after the further code in the activity A is executed.
View 5 Replies
View Related
Jul 9, 2010
I have a Contact Activity which is derived from ListActivity, which displays list of contacts, and on click of item, a new Activity Message Activity derived from ListActivity is initialized.Now I know, I can pack some information in Bundle and pass it before creating activity, but is there a way I can get instance of "ContactActivity" in onCreate method of "MessageActivity"?
View 1 Replies
View Related
May 18, 2010
I have this scenario
onResume of an activity:
CODE:............
Adapter has been defined as:
CODE:.............
And the onContentChanged event is not fired, although the onResume and the call to the adapter is issued.
View 1 Replies
View Related
Dec 7, 2009
I have a TabActivity subclass that attempts to start a new activity via a menu item selection in onOptionsItemSelected.I am receiving the following exception which eludes me at the moment.I'm not sure why it thinks I am *not* in an activity!
View 2 Replies
View Related
Nov 19, 2010
i am writing an app in which i need a background service to call an activity and show some result.
View 4 Replies
View Related
Apr 4, 2010
me and my partners are working on developing a pwa client for android Am getting an error while calling an activity from another activity.the error is as follows...
View 3 Replies
View Related
Oct 28, 2010
I am developing an app where a single activity is instantiated multiple times by itself. I guess you could think of it like a book where each activity is a page. At the end of the page (activity) the user presses a button to go to a new page. I fire off an Intent for the same Activity, but I push different data into the Bundle so that a different page is loaded. This works fine, and I like the fact that the user can back up to a previous point, but my question is whether this will eventually be a problem? What happens if this activity is instantiated 10 times, or 50, or 100? Will the device run out of memory, will GC come along and clean up old activities, or what? If GC does clean them up, what happens when the user presses Back and the previous Activity is no longer on the stack? Is it better to keep track of the user's path, finish() the activity, and override the Back button so that whether the user is moving forward or backwards, I only load a single Activity? Another approach I could take is to refresh all the data on the page so that it's still the same activity, but with new data. The Back button would not work as expected in this case.
View 2 Replies
View Related
Apr 23, 2010
I'm writing an android application which listens the phone calling events. What I want to do is, if there is a call incomes or outgoes, an activity shows with my customized info.I want to this screen keeps showing during the calling period. However, if a call is coming, the system UI which shows the contact always appears on top of my activity.I've found some apps already realized this function, but mine can't.
View 1 Replies
View Related
Sep 11, 2010
I'm using an AlarmManager to trigger an intent that broadcasts a signal. The following is my code:
CODE:................
I'm calling this code from an activity, so I don't know how I could be getting the following error...
CODE:....................
Is this really what you want?
View 1 Replies
View Related
Oct 12, 2010
I have implemented a ListView in my Android application.
I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside the overridden ArrayAdapter.getView(...) method, I assign an OnClickListener. In the onClick(View v) method of the OnClickListener, I want to launch a new activity.
I get the exception:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
How can I get the context that the ListView (the current Activity) is working under?
View 2 Replies
View Related
Apr 26, 2010
The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is this even the best approach, or would this be better done with some kind of Intent Flag?
Is it correct to call finish() after calling startActivity() on the new activity?
CODE:...................
I'm still taking in the whole 'Message Queue' method of doing things in Android, and my assumption is that calling startActivity() and then finish() from my first Activity's onCreate() will log each respective message in the message queue, but finish execution of onCreate() before moving on to starting the next Activity and finishing my first one. Is this a correct understanding?
View 1 Replies
View Related
Feb 2, 2010
Can any one guide me how to achieve this?
View 4 Replies
View Related
Dec 3, 2009
I'm having this strange issue where upon exiting a subactivity that is translucent (android:theme="@android: style/Theme.Translucent" ) the onStop() method doesn't appear to be called. have a TimerTask that runs and is supposed to be terminated when the subactivity ends in the onStop() method, but I'm instead left with an orphaned thread running in the background. It go particularly bad when I ran the subactivity several times. When I revert to no theme, the onStop() method is called and the activity behaves properly. Is there something I missed about how Translucent activities'lifecycles differ from standard activities?
View 4 Replies
View Related
Jul 23, 2010
I have two activities:
"a" that spawns thread for generating a dynamic array of values inside public void run() function.
"b", graphics activity that will help me draw rectangular pulses based on array values calculated in activity "a" (calculated in a's thread to be precise).
When I am in thread inside "a", how do I pass values of array to activity "b" and
call activity as well.
activity A
CODE:..........
activity B
CODE:..............
View 1 Replies
View Related
Jul 1, 2010
I have an image which is taken from andorid by calling image _capture how do i upload it to a windows server?
View 1 Replies
View Related
Jan 12, 2010
I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it starts from splash screen. Android Platform 1.6
I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it always starts from browse screen instead of splash screen why is that..............
View 1 Replies
View Related
Feb 25, 2010
Hopefully the title wasn't to confusing but what I meant was the following:
Lets say activity A starts activity B by calling:
Intent myIntent = new Intent(Activity_A.this, Activity_B.class);
Activity_A.this.startActivity(myIntent);
Could I save/free up some memory by finishing Activity_A after Activity_B is begun (if thats even possible). Maybe through the following:
Intent myIntent = new Intent(Activity_A.this, Activity_B.class);
Activity_A.this.startActivity(myIntent);
Activity_A.finish();
Or would Acitivty_A call startActivity() and wait for Activity_B to finish before it called finish()?
The idea would then be that when the users end with Activity_B, it would just restart Acitivity_A (and finish itself in a similar fashion)? Would this create too much overhead? Thanks for any answers and I apologize if the formatting of this post isn't correct.
View 2 Replies
View Related
Nov 5, 2010
I created a thread in my activity, and that thread will print out the value of my instance variables in my activity after running for about 10 seconds. I pressed the back key to destroy my activity before the thread prints out the values, and when the thread reaches that line of code, it can still print out the values correctly. That means even though the activity is finished, the java object of the activity is still there. Will the object always be there? Or it is just waiting to be GCed? Or it will be killed only when Android needs memory?
View 2 Replies
View Related
Jul 2, 2010
I am trying to call my service class's stopService() method from my activity. But I don't know how to access stopservice method from my activity class. I have the below code but its not working. This is HomeScreen class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
enablecheck = (CheckBox)findViewById(R.id.enablecheck);
enablecheck.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(enablecheck.isChecked()){
startService(new Intent(HomeScreen.this, AutoService.class));
} else {
stopService(new Intent(HomeScreen.this, AutoService.class));
} } });
}
This is Service Class:
public class AutoService extends Service {
private static final String TAG = "AutoService";
private Timer timer;
private TimerTask task;
@Override
public IBinder onBind(Intent intent) {
return null;
} @Override
public void onCreate() {
Toast.makeText(this, "Auto Service Created", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
int delay = 5000; // delay for 5 sec.
int period = 5000; // repeat every sec.
timer = new Timer();
timer.scheduleAtFixedRate(task = new TimerTask(){
public void run() {
System.out.println("done");
} }, delay, period);
}
@Override
public boolean stopService(Intent name) {
// TODO Auto-generated method stub
timer.cancel();
task.cancel();
return super.stopService(name);
} }
View 3 Replies
View Related
Jun 29, 2010
Is there a way that a Service can report back to the calling activity when the Service has reached a particular stage of processing? Consider a music player activity that initiates the actual music playing in the background as an Android Service. I want to detect and inform the Activity when the Service has reached the Mediaplayer's onPrepared. Is there a way that the Service can tell the calling Activity when the MediaPlayer's onPrepared is called, to let the Activity know that the audio is prepared and ready to play?I am basically looking to see if there is work around, rather than having a thread in the activity, pinging constantly to check if the Service has reached onPrepared.
View 2 Replies
View Related
Aug 4, 2010
My MAIN activity is spawning a child activity that contains a ListView. While this ListView is being populated (through an AsyncTask), an indeterminate progress bar is shown.However, assuming that I am an impatient user and I press the BACK button, the progress bar is cancelled but I am left with a blank screen. I have to press BACK one more time to go back to the MAIN activity.I would like the app to go back directly to the MAIN activity by pressing BACK only once. Can somebody point me in the right direction? I am thinking I should call finish() somewhere but I don't know where to put it.
View 3 Replies
View Related
Sep 13, 2010
I am having two activities, say activity A and B. Activity A is an ListActivity, and when the items in the list is selected, it will call startActivity() to bring up B. The problem here is that when I am in B and click the home key, and then go to the application launcher to resume my application, A will be brought up again. This time when I click a different item in A, it will bring up B with the old data of the previously selected item before the home key was clicked.
After examinzing the code, I found that the startActivity does not update the intent of B. I found a post here about the similar question, and the answer was to overwrite the onNewIntent. However, I found that it doesn't work, because this method never get called when the second time I call startActivity. I am sure that this is the same instance, because I've printed out the instance number. Is there any other ways to update the intent of the activity? Or I need some other settings to make the onNewIntent get called? I didn't set any flags or launch modes, so everything is default.
View 1 Replies
View Related
Sep 7, 2009
Got new magic with rogers network and have caller i.d on it. for some reason it doesn't display the name of the person who's calling,only the number.talked to tech support in rogers,was told device doesn't support name display,which doesn't make any sense.please advise if anybody has the same issue.
View 4 Replies
View Related