Android :: Trap In TabHost When AsyncTask Delays Set Content View At Activity Startup

Nov 3, 2009

I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost.When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds?

Android :: Trap in TabHost when AsyncTask delays set Content View at activity startup


Android : Switch Activity Of Content Of Tab In Tabhost?

Dec 8, 2009

I have created a TabHost and in 1 of the tab, I have added the content using

mTabHost.addTab(mTabHost.newTabSpec("tab1")
.setIndicator(getString(R.string.dialerIconLabel),
getResources().getDrawable(R.drawable.ic_tab_dialer))
.setContent(intent));

Is it possible for me to switch the content's activity programatically after I called 'addTab of TabHost'?

View 1 Replies View Related

Android :: Instance Variable Of Activity Not Being Set OnPostExecute Of AsyncTask - Return Data From AsyncTask

Jul 28, 2010

I'm trying to figure out the correct way to create an AsyncTask to retrieve some data from the internet and then to take that data and bundle it up in an Intent and pass it to a new activity(A list display). So in the first activity I just have an EditText and Button. In the event of an OnClick the task should be called and when it is finished the data should be bundled inside an Intent and passed to the next Activity. The problem is when I take the results from onPostExecute and set them to an instance variable of the main activity, that instance variable is still null when the task is complete. Here is the barebones version of the code:

CODE:...........

When I debug the application I see onPostExecute does contain a valid PlacesList full of results, so why is the instance variable places set to null after the task is executed? I am going about "returning data" from an AsyncTask incorrectly?

View 1 Replies View Related

Android :: Capture / Trap For Activity Not Found Exception

Mar 16, 2009

I am playing with "android.speech.action.RECOGNIZE_SPEECH" and in the source it says to trap for ActivityNotFoundException. However, I am not sure how I can do this, the activity class doesn't support this event. I found it as part of android.content, but am not sure how to implement it. Multiple inheritance?

View 2 Replies View Related

Android :: Use Resource Id But Didnt Set Content View In Activity?

Aug 12, 2010

May I know is it possible I use the resource id but I didnt set the Content View in the activity?

For example: abc.xml have one TextView id = "R.id.Text". Can I use the use TextView name = (TextView)findViewById(R.id.Text); method in the activity which was setContentView(R.layout.def);?

View 2 Replies View Related

Android :: Clear Completely Whole TabHost And Replace With Other Content?

May 9, 2010

I have a code for populating content for tabs dynamically. First time it works ok, but when I want to replace tabs (and their content) with new content - tabs are changed but tabs' contents are not, how can I clear completely whole TabHost and replace with other content? code...

View 2 Replies View Related

Android :: Replace Existing TabHost Content / Activities?

Nov 16, 2009

Since the TabHost API does not offer a way to change existing views or activities, what is the preferred means to replace an existing tab?

I only know of: clearing the tabs and adding them again. Is there an alternative? Or is this really not provided by design?

View 2 Replies View Related

Android : Restart An Activity Within A Tabhost?

Jan 13, 2010

I've searched and I know it seems some people frown upon using activities within tabs, but moving past that...how would I restart a tabbed activity while still keeping the tabs visible? I have an activity in a tab, I use the menu to create a new activity to update the tab's activity displayed info, when I return from the menu activity I want the new information to be displayed in the tab's activity. I am using startActivityForResult() from the menu choice, but when I return and try to restart the activity...it wipes out the tabs above(I guess as expected, but I want to re-launch the refreshed activity within the tab).

Creating the tabs:

TabHost host = getTabHost();
Intent home_intent = new Intent(constants.HOME_ACTION,
null, this, homeTab.class);
Intent inbox_intent = new Intent(constants.INBOX_ACTION,
null, this, inboxTab.class);
Intent stats_intent = new Intent(constants.STATS_ACTION, null,
this, infoTab.class);

host.addTab(host.newTabSpec(constants.HOME_TAG)
.setIndicator(getText(R.string.home_label),
getResources().getDrawable(R.drawable.icon))
.setContent(home_intent));
host.addTab(host.newTabSpec(constants.INBOX_TAG)
.setIndicator(getText(R.string.inbox_label),
getResources().getDrawable(R.drawable.icon))
.setContent(inbox_intent));
host.addTab(host.newTabSpec(constants.STATS_TAG)
.setIndicator(getText(R.string.stats_label),
getResources().getDrawable(R.drawable.icon)).setContent(
stats_intent));

Return from the menu activity in the tab's activity(updating database info): code...

View 2 Replies View Related

Android :: Tabhost Working In Activity Class

Nov 17, 2010

I must be overlooking something because I am unable to get my TabHost to display in my Activity class.I am getting the dreaded force close when I try to run the app.It will work if I extend TabActivity, but I can't do that [details at the bottom] because once I move the code from my prototype project its going to be in a custom class that inherits from Activity.

View 2 Replies View Related

Android :: Can I Use Wrap TabHost Containing MapView Displays AdMob View Below It

Sep 18, 2010

I'm very new to Android (like 2 days), but I'm experienced with other layout toolkits. I'm trying to put an AdView below a TabHost, and it seems that I can either get the TabWidget or the AdView to display correctly, but never both.

First, here's an ASCII art version of what I'm trying to accomplish:

--------------------------------------------
| Tab 1 | Tab 2 |
--------------------------------------------
| MapView when tab 1 is selected |
| |
| |
| |
| |
| |
| |
--------------------------------------------
| AdView that stays no matter what tab |
--------------------------------------------

As you can see, I'm trying to get the AdView outside the TabWidget or FrameLayout. I want it to be below the whole tabhost contents.

Here's the layout I've got before adding the AdView...

Unfortunately, in that one, my MapView in the first tab puts the Zoom controls on top of the AdView. Is there some simple layout I'm missing? Cuz I can get the TabWidget to wrap_content for height, or the AdView to wrap_content for height, but only when they go above the "@android:id/tabcontent."

Anything below the tab content gets eaten by the MapView.

View 1 Replies View Related

Android :: Showing Indeterminate Progress Bar In TabHost Activity

Jul 16, 2009

I know that the following code should show and hide a tiny circular progress bar with the following code in Android:

CODE:.............

The problem is that I am using a TabHost and I need to be able to do this from one of the "child" activities. Is there any way I can go about doing this?

View 2 Replies View Related

Android : Return A Result (startActivityForResult) From A TabHost Activity?

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

Android :: Access Progress Bar In Main-activity Containing Tabhost From One Of Tabs?

Nov 14, 2010

I am developing an android application where I have a main-activity that contains a progress bar and a tabhost. the tabhost has 3 tabs.How do I from a tab-activity access the progress bar in the main activity? I want to be able to start and stop the progress bar when things changes inside each tab ativity.

View 1 Replies View Related

Android :: AsyncTask And UI Activity

Aug 9, 2010

I know this is not how an async task should behave but my question is how to "block" the user while executing it.My need is the following: I have my own backup/restore process and I have an async task to run these two actions. The backup is fine, I can warn the user when the backup is done and that's just fine But my problem is about the restore process. When the user click on restore he shouldn't be able to make any change in the application (and anyway don't want to because he would lose all his changes).I understand that having the user blocked while restoring (or maybe with a progress bar) is not a best pratice but I do not see any other possibility in this context.

View 7 Replies View Related

Android :: OnSaveInstanceState Function In Main Activity Of TabHost-based Application

Aug 30, 2009

I've implemented an onSaveInstanceState function in the main activity of my TabHost-based application. I need to save the state of various objects I am keeping in memory that I have all marked as serializable, as well as some basic int and string values. I have stepped through my application and watched it call the onSaveInstanceState function and presumably save everything without any manner of exception or problem. The issue is that my onCreate function is being called with a null Bundle value every time after I start the application again. I'm really at a loss and unsure why it would call the save but not pass anything into the create.

View 1 Replies View Related

Android :: Scroll View Doesn't Resize - Content Of Child View Changes

Aug 18, 2010

I have a WebView inside the ScrollView. The content of WebView dyanamically changes when it displays different html page. I have the following issue: For example I have A.html, and B.html. The content of B.html is larger than A.html, so the page is longer. When WebView load B.html, the ScrollView stretches its size to enable itself scroll for B.html, then if I go back to A.html, ScrollView doesn't resize itself. (The scroll area is exceed the content of A.html) What I want to have, is dynamic change the scroll area of scroll view to fit the webview's content.

View 3 Replies View Related

Android :: Update View When AsyncTask Finished In Service

Oct 12, 2010

I have an activity which starts a service. In the service there is a network lookup in an AsyncTask. Results from the lookup are saved to a database.

The activity queries to database and shows the newest entries. But at the very first run the database is empty, so there is nothing to show. In this case I would like to show a progress dialog to the user while the network lookup is taking place. I would like to dismiss the progress dialog when the first lookup is finished.

Is there a way to access the progress dialog created in the activity from the service? Or how to do it?

View 2 Replies View Related

Android :: Executed ASyncTask In Activity But Not Working

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

Android :: AsyncTask Won't Stop Even When Activity Has Destroyed

Mar 27, 2010

I have an AsyncTask object which starts executing when the activity is created and does stuff in the background (downloads upto 100 images). Everything works fine but there is this peculiar behavior which i'm not able to understand.For eg: when the android screen's orientation changes then the activity is destroyed and created again. So I override the onRetainNonConfigurationInstance() method and save all the downloaded data executed in the AsyncTask. My purpose of doing this is to not have AsyncTask run each time activity is destroyed-created during orientation changes, but as i can see in my logs the previous AsynTask is still executing. (The data is saved correctly though)I even tried to cancel the AsynTask in the onDestroy() method of the activity but the logs still show AsynTask as running.This is really strange behavior and would really be thankful if someone can tell me the correct procedure to stop/cancel the AsynTask.

View 1 Replies View Related

Android :: Activity.finish() With AsyncTask Still Running In Background?

Apr 28, 2010

What happens on Activity.finish() with an AsyncTask still running in background?

Does it just pop the Activity off the Activity Stack, but wait to destroy the Activity object until the AsyncTask fully completes (since the AsyncTask is an inner class of my Activity)?

Also, would it act any differently if the AsyncTask were a public, non-inner class that held no references to the instance of the Activity?

View 1 Replies View Related

Android :: Problem Long Running AsyncTask With Reference To Activity

Jul 24, 2010

I have an AsyncTask that scans the file system and publishes progress through Notifications. To do this I need a reference to the current Activity in the AsyncTask.

I also don't want to kill the task when the activity is destroyed. How do I avoid leaking the activity and everything it references on each configuration change?

One possibility is to remove the reference in OnPause() to be sure it is gone when the Activity is destroyed, but that would mean notifications stops coming as soon as you leave the activity which is no good.

Isn't there a recommended way of dealing with AsyncTasks in this way?

View 12 Replies View Related

Android :: AsyncTask To Run On Activity Start Fails After Previously Getting Cancelled

Sep 10, 2010

I am using an AsyncTask to fetch the ring tone for a contact when my application starts, it works fine until after my Activity closes a couple of times during the AsyncTask, after this happens the AsyncTask will only ever get to onPreExecute() and never doInBackground, so I can never fetch the ringtone then until either a force stop or device restart.

Why this might be happening? Why the AsyncTask would get to onPreExecute but then never run doInBackground()?

Here is my code: (Following the Shelves source code)

CODE:.....................

And onAddRingtone() is used in onCreate and onCancelRingTone() is used in onDestroy() as well as where you can see if in the code above. I have spent 3 days on this and I haven't been able to find a solution? Am I taking the wrong approach? Using cancel wrong? Is there a bug?

View 1 Replies View Related

Android :: Soft Keyboard On Activity Startup

Jan 12, 2010

I am struggling trying to have the soft keyboard appear in a search screen and from the looks of numerous pleas on various forums, I am not the only one. I have tried many variants, culling from the byzantine attempts of those others.

InputMethodManager imm = (InputMethodManager) getSystemService
(Context.INPUT_METHOD_SERVICE); imm.showSoftInput (query, 0);
(for 0, substitute InputMethodManager.SHOW_FORCED or InputMethodManager.SHOW_IMPLICIT.)

The problem seems to be that showSoftInput doesn't work from onCreate. This is a very common need. Surely there is a reasonable solution to this problem, or is it botched here?

View 3 Replies View Related

Android :: How To Scroll To Bottom On Activity Startup?

Jul 22, 2010

I am displaying some data in a ScrollView. On activity startup (method onCreate) I fill the ScrollView with data and want to scroll to the bottom. I tried to use:
getScrollView().fullScroll(ScrollView.FOCUS_DOWN).
This works when I make it as an action on button click but it doesn't work in the onCreate method. Is there any way how to scroll the ScrollView to the bottom on activity startup? That means the view is already scrolled to the bottom when first time displayed.

View 1 Replies View Related

Android :: Show Dialog When Application / Activity Startup

Aug 24, 2010

Can we show the dialog when our application/activity startup?

View 4 Replies View Related

Android :: Specify Which Item Gets Default Focus On Activity Startup?

Apr 11, 2009

How can you specify which item gets the default focus on Activity startup? Using requestFocus programmatically does not work. On setContextView the first focusable item listed in the XML is given the default focus. When using RelativeLayout, the first item listed is not always the desired item or necessarily on top.

View 3 Replies View Related

Android :: Simple Program - Class Extends Activity At Startup

Oct 1, 2010

I have a simple activity program in android. Basically the class just extends Activity.
But when I start it I get a ClassCastException in the constructor of my class. I don't even have a constructor defined, so it must be in the constructor of the superclass which is Activity. Unfortunately the debugger doesn't give any detailed information on what class it is trying to cast. Here is the stacktrace:

Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread$PackageInfo.makeApplication(boolean, Instrumentation) line: 649
ActivityThread.handleBindApplication(ActivityThread$AppBindData) line: 4232
ActivityThread.access$3000(ActivityThread, ActivityThread$AppBindData) line: 125
ActivityThread$H.handleMessage(Message) line: 2071
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
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]

And when I look into this runtimeexception I get:

detailMessage "Unable to instantiate application com.test.MyApp: java.lang.ClassCastException: com.test.MyApp" (id=830067694464)
The only code is:
package com.test;
import android.app.Activity;
public class MyApp extends Activity {
}

View 3 Replies View Related

Android :: Possible To Start Surface View With Game Thread Anytime / Other Than At Startup Of Program?

Aug 7, 2010

I've read several example programs and tutorials to try and solve my problem but they all seem to go the same way.I've used a couple Activities and xml documents to create a menu that loads when my game starts. When the user clicks the "Start The Game" button, it loads a new Activity that sets the view with my game thread and all of the game properties.I know this activity works because I've run it alone as its own project, but every way I've tried to start it after the Menu, I get a nullPointerException and it force closes.I read the SurfaceViewOverlay tutorial and attempted to use that implementation, but I'm using a SurfaceView, not a GLSurfaceView. I'm debating rewriting my entire program to use OpenGL but I figured I would see if anyone else knows what I'm doing wrong here.If you need the code snippets I can paste some here, but it's not really the specific code that's wrong, I think it's the way I'm using(abusing) the language.

View 1 Replies View Related

Android :: Add Content View Behind Gridview?

Oct 4, 2010

How do i add the content view behind gridview? i could only addContentView on top of gridview. I setContentView() of the gridview for the activity.

View 2 Replies View Related

Android :: Way To Extract And View Content Of .apk File?

Aug 30, 2010

Is there a way to extract and view the content of an .apk file?

View 2 Replies View Related







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