Android :: Activity - Sometimes - Throws Wrong State Class Exception When Being Resumed After Kill

Nov 24, 2009

I'm testing how my app behaves when killed by the OS due to low memory conditions. I always have three activities on the stack, like: A B C (then C launches maps or some other heavy process)

when my app is killed, and I return to it, C starts itself up again ok. When I hit the back button to go to B, I [sometimes] get an exception thrown which I can't trace. Output is below. I don't know where to go from here. I've only seen one other post mentioning this exception, but it was related to a reproducable error when rotating the device. This only happens sometimes.

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

Android :: Activity - sometimes - throws Wrong state class exception when being resumed after kill


Android :: Confusion With Activity Stack And Restoring State / Whats Wrong?

Jan 11, 2010

I have a start activity page for my game (which is the root activity for my app) that just lists "Play", "Help", and "About" TextViews on the screen. Each TextView has a click listener which start the appropriate Activity for each. The GameActivity (started with explicit intent from clicking "Play") has onSaveInstanceState implemented to save state of the game. Its onCreate checks for non- null Bundle to restore this state. My problem is this:

1. Turn on Phone/Emulator 2. start my game with icon in launcher 3. Start page is displayed 4. click "Play" to start my GameActivity 5. play game for a few seconds 6. click home 7. state is saved (proven with debugger calling onSaveInstanceState) 8. start my game with the icon in launcher 9. start page is displayed

I was under the impression that by clicking the app icon from the launcher that my existing task activity stack would be restored with my GameActivity being on top and its onCreate being called for me to restore the state I saved. Instead I am getting a brand new instance of my start page. Also, if I long press home and choose my running game icon, then my game comes back exactly as I left it. However, this apparently is NOT using my onCreate restore state logic as onCreate is never called.

All of the documentation seems to say that the entire stack of activities will be restored when clicking the application icon from the launcher, but I just get a fresh instance. What might I be doing wrong?

View 2 Replies View Related

Android :: Unable To Find Explicit Activity Class - Not Found Exception

Aug 22, 2010

The error I receive is, "android.content.ActivityNotFoundException: Unable to find explicit activity class {com.droidea.birthday/ EditBirthdayActivity}; have you declared this activity in your AndroidManifest.xml?"
The error seems simple enough, but I don't see a problem with the way I have identified this activity in my manifest file. I have also been unable to see any problems with the activity class itself..............

View 4 Replies View Related

Android :: Public Class Preference Extends Activity - Null Pointer Exception

Jun 19, 2010

My app crashes with a null pointer exception on the code below. I have an xml preference file under res/xml/defaults.xml
public class Preference extends Activity {
public Preference() {
} public String getPreference(String key)
{ //it still crashes here
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
String result = settings.getString(key, null); return result;
} }

View 4 Replies View Related

Android :: Attempt To Stub Android Activity Class Using PowerMockito Throws RuntimeException - Stub

Sep 17, 2010

I found this example where they used PowerMock and EasyMock to stub/mock the Menu and MenuItem classes for android. I have been trying to do something similar with PowerMock and Mockito with the Activity class.

I understand that a lot of the methods are final and that in the Android.jar they all just throw RuntimeException("Stub!").

I also understand that this test isn't complete but I just wanting to see if it is possible to mock the android Activity class.

But given that PowerMock allows you to mock classes with final methods shouldn't this code work?

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

I would think that the RuntimeException would no longer occur and "Title" would be returned but it still throws the exception.

I have tried all sorts of different things like doReturn("Title").when(mockActivity).getTitle(); and suppress(constructor(Activity.class));

View 2 Replies View Related

Android :: IsUserAMonkey Throws Exception

Oct 17, 2010

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

I get the following exception when trying to use the isUserAMonkey API on a keydown. mAM = (android.app.ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); if (mAM.isUserAMonkey()) {return true;} Any reason why this may be happening?

View 9 Replies View Related

Android :: ProgressDialog In AsyncTask Throws An Exception

Jun 25, 2010

I'm trying to make a simple ProgressDialog appear while my AsyncTask is fetching data. In my onPreExecute() method I have this: pd = ProgressDialog.show(c, "Loading...", "Please wait");

c is the context passed into the constructor of my AsyncTask from this.getApplicationContext(). Unfortunately, I keep getting an exception with this message: Unable to add window -- Token null is not for an application

What am I doing wrong?

Using this instead of this.getApplicationContext() has revealed another problem. When I call ProgressDialog.show(..., a ProgressDialog is displayed, but not until after the AsyncTask has completed. In other words, the data loads and then the dialog is displayed. If I include pd.dismiss() in my onPostExecute() then I never even see the dialog (presumable because it is closed before it ever gets opened).

It turns out that fetch.get() was hogging the UI thread and not letting the ProgressDialog display.

View 2 Replies View Related

Android :: Calling NotifyDataSetChanged() Throws Exception

Oct 7, 2010

I have a ListView that I'm binding to an adapter. The adapter is a protected member of my main class. I have a listener thread that receives data and updates the source list for my adapter. When I call the adapter's notifyDataSetChanged() method, an exception is thrown:

Runtime Exception: PhoneLayoutInflater(LayoutInflater).inflate(int, ViewGroup, boolean) line: 322

I've read that the notifyDataSetChanged() method has to be called on the UI thread, and I'm doing that. In fact, just to be sure, I even update the ListView's data source on the UI thread. All I do in my listener thread is update a protected member that houses the data. Here's an example of what I'm doing (note that I don't have the part of the code that calls the AsyncTask, but it's fired from a listener):

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

Does anyone have any pointers or ideas as to why I'm getting this exception? Any help is much appreciated.

Here are the layout files, as requested:

main.xml:

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

row.xml:

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

View 1 Replies View Related

Android :: PreferenceScreen - Intent - Element Throws Exception

Sep 17, 2010

I've got a probleme with an exception, but I don't know why I get this exception.

The project is about implementing an AbstractAccountAuthenticator with an AbstractThreadedSyncAdapter to sync certain data on a server with a content provider.

I made everything and both adding accounts and syncing is running without any problems.

Now I've tried to add a Preference-Screen just like suggested in the android reference (search for AbstractAccountAuthenticator, it is explained there) via xml like this:

autenticator.xml:

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

The Preference-Screen-xml looks like this:

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

The screen is promted how it should be, but and that is the problem: When I click on the PreferenceScreen with the intent it leads to a crash of the system (both in the emulator and my HTC-Desire).

Logcat says:

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

Here the part of the manifest, where the activity is defined:

CODE:.......

The whole test-code (it is my project on the essentials to find the problem) is to find at googlecode (http://code.google.com/p/ cleanproject/source/browse/) (Eclipse-Project)

View 2 Replies View Related

Android :: Application Throws Exception When Rotate Device

Jul 11, 2010

I have developed simple application of progress bar in that when I hit the button then it will do some work in background and one progress bar is visible on foreground. afte completing back ground work it display the same screen. It works fine if I don't rotate mobile but when I rotate mobile then it throws java.lang.IllegalArgumentException: View not attached to window manager

I know when we rotate the device or open keypad it starts activity restarted. But How to avoid this error. My code is.

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

View 3 Replies View Related

Android :: Starting Service From Other Apk - Throws NoClassDefFoundError Exception

Jul 31, 2010

I have two projects in Eclipse: service and UI client.

In onCreate in UI client I have:startService(new Intent(this, ExampleService.class));

But this fragment: ExampleService.class throws NoClassDefFoundError exception at runtime. I have installed ExampleService.apk, and ExampleUiClient.apk. Project compiles, and everything looks fine. What I am doing wrong?

Is it possible to start service from other apk?

View 2 Replies View Related

Android :: Database Reading Problem Throws Exception

Mar 30, 2010

I am having this problem with the android database. I adopted the DBAdapter file the NotepadAdv3 example from the google android page.

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

The error that i am receiving is from Log.e(TAG, e.toString()) in the methods retrieveKey() and storeKey() "no such table: myuserkey: , while compiling: SELECT userkey FROM myuserkey"

View 2 Replies View Related

Android :: How To Handle Throws Clause In Java Exception Handling

Sep 4, 2010

I have class A in which I have a method openfileConnec().

It was written like the below:

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

Now I come to class B where I will call this method like the below:

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

I was asked a question in an interview as follows:

Why does the method have a throws Exception in its declaration? Is it that on of the methods called in the implementation throws the base class exception? Also If we get a exception during calling the method (fileConnect( )) control goes to catch block. After executing catch where should the control go, what should be sent to base case?

View 2 Replies View Related

Android :: Handler From A Runnable Throws Null Pointer Exception

Sep 20, 2010

I have a Thread that downloads data from internet

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

There is an activity that needs to be updated according to downloaded data.

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

Whenever I run above code I get NullPointer Exception .Please help me to update the view.

View 1 Replies View Related

Android :: Way To Detect Why Activity Was Resumed In Phone

Aug 24, 2010

I'm developing an Activity that does some of its own state management. I'm trying to differentiate the following onResume cases:

New launch
task switch (home button long-click)
resume after other activity in the same application
wake-up after sleep
orientation change

Is there something in the Activity's intent, or elsewhere, that can help me differentiate these?

For the curious and some context... I'd like to preserve my internal history stack on 4 & 5. On cases 2 & 3, I would preserve the same current page, but erase the history (allow the normal back button functionality to take over at that point). Case 1 would initialize to the activity's internal start page (and can be detected easily enough with some help from ocCreate).

View 2 Replies View Related

Android :: Previous Set Instance Variables Null When Activity Resumed

Apr 20, 2010

I am using an Application object to store app-wide instance data--data that I need to remain in existence for the entire lifetime of the app, so the Application class seems like the proper place to put it. I have just finished reading this thread http://groups.google.com/group/android-developers/browse_thread/threa... that goes into pretty good detail and receives confirmation from Googler hackbod as to how the Application class performs--and from that info it seems this strange behavior I am receiving should not be happening...

Basically, every once in a while when I resume my app in any of its Activities (it is still running in memory so onCreate is not called) I get NullPointerExceptions because instance variables in my Application class are returning null when I request them from my Activity (via a getter method in my custom Application class). It seems as if sometimes Android saves the states of my Activities but deletes all my instance variable data... This can't be an Android problem--there must be something wrong with my code.

Has anyone else ever ran into an issue of this kind? Any ideas as to what may be causing this? I'm not going to post my code here as that won't help anyone, but hopefully someone can point me in some helpful directions.

View 11 Replies View Related

Android :: Can't Kill Running Process When Exception Through

Aug 9, 2010

I am a freshman and my English is poor.In some cases, I terminate the application and the DVM process couldn't be killed when a exception through, why is this? and how the problem is to be tackled?

View 2 Replies View Related

Android : Starting A New Activity Throws Me Into Debug Mode - Stops App

Jul 22, 2010

I have a listview. Whenever I strike an item of listview the debugger gets opened instead of starting a new activity (i.e. what I want). Code...

P.S. all the xml files are correct.

View 3 Replies View Related

Android :: Runtime Exception ListView Whose Id Attribute Is 'droid.R.id.list' / What's Wrong?

Jun 14, 2010

I am getting a run time exception
java.lang.RuntimeException: Your content must have a ListView whose id
attribute is 'android.R.id.list'

I don't know what is wrong> code...

View 1 Replies View Related

Android :: Communicating Between Receiver Class And An Activity Class

Jul 14, 2010

I'm just getting into Android development, and I have a question about communicating between a receiver class and an activity class. I'm very new to JAVA and Android so I hope I don't sound too stupid. I'm developing an application where I intercept an SMS message and then based on various elements of that SMS I might delete it once it's been saved to the inbox. I have a receiver class that intercepts the txt message, and I am also able to delete messages from my inbox with code in the activity class using a button at the moment. The problem I have is communicating between the receiver class and the activity class where the code to delete a message resides. I tried putting that code directly into the receiver class but as I'm sure most of you already know the BroadcastReceiver class doesn't seem to support what I need to delete messages. I've been searching for an answer to this for a while, but haven't been able to find anything. Honestly I'm not sure I know enough about JAVA and Android to even recognize a solution if I saw it.

View 2 Replies View Related

Android :: Access Application Class From Class Other Then Activity

Sep 8, 2010

I'm new to Java and android development. In my application I need data which is accessible for a few activities. I've read that a good solution is to use Application class for this. So I use it like this:

public class MyApplication extends Application {
private String str;
public String getStr(){
return str;
}
public void setStr(String s){
str = s;
}
}

and I can access this variable from activity like this:........................................

View 2 Replies View Related

Android :: Call Activity Class From Other Java Class?

Oct 8, 2010

I have just started android. I just want to know that how can i call activity class from other java class. i just want to pass class object to activity class.

public class GsonParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MagazineThread thread=new MagazineThread();
thread.start();
}
public GsonParser(JsonMagazineParser Obj)
{

}
}

and i am just doing like from other class. GsonParser obj=new GsonParser(this);passing obj to activity class.how can i achieve that.

View 1 Replies View Related

Android :: Not Found Exception For Compiled Class

Nov 15, 2010

I am writing an application and due to various reasons I had to build it using make (froyo code) and not SDK. When I run my app on emulator it works fine. I have an Android device and code to build image for the device. When I build my app with device code, it builds fine. How ever, when I run the application, I get
java.lang.ClassNotFoundException:
<package.class> in loader dalvik.system.PathClassLoader[.]

A source file in my code is actually doing
sourceClass = classLoader.loadClass(sourceName);
sourceName here is pointing to a class I actually build (I have classname.java file in my code under correct package directory and package name). Note that this app is running fine on emulator, but on a device it is failing.

I verified that the .class file exists in out/target/common/obj/APPS/ xxxApp_intermediates/classes.jar, classes-full-debug.jar, classes-full- names.jar

View 2 Replies View Related

Android :: Jar Dependencies / No Class Definition Found Exception

Mar 29, 2010

I resolved this issue myself. It turns out that the activation framework requires some libraries that aren't native to android, myjava.awt.datatransfer, org.apache.harmony.awt.*, and org.apache.harmony.misc. Once i added those libraries everything worked fine. Code...

View 2 Replies View Related

Android :: MediaRecorder Class To Record A Video - Exception

Jun 17, 2010

I try to use the MediaRecorder class to record a video but I get an exception : failed to get Camera parameters. Prepare failed.

Here's my code :

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

View 1 Replies View Related

Android :: How To Save An Instance Of A Custom Class In On SaveInstance State?

Jul 3, 2010

I created an instance of a custom class RestaurantList to hold my data (a list of restaurant data received from a web service as json data).How can I save it in onSaveInstanceState? Code...

View 1 Replies View Related

Android :: Class Cast Exception When Inflating A Custom Relative Layout

Jul 23, 2010

I get this exception when I try to inflate

07-22 19:15:39.903: ERROR/AndroidRuntime(3810): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout

I have a base class:

public class UIBase extends RelativeLayout {}

And a more specific class:

public class Countdown extends UIBase {}

Then I try to inflate and it exceptions:

UIBase newView = (UIBase) inflater.inflate(layoutId, parent, true);

Here's the XML file:

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

View 1 Replies View Related

Android :: Kill A Service By Another Activity?

Feb 16, 2010

Activity 1 starts a Service, using the standard Intent. Activity 1 starts Activity 2. Then, Activity 1 gets finished().

Now, there's only Activity 2.

How does Activity 2 kill the Service, since that Intent was generated in Activity 1? I don't want to pass the Intent everywhere...

View 2 Replies View Related

Android : Kill All Activity At A Time?

Dec 7, 2009

Any one knows how to Kill my all the activity at a time ?

Am inside so many sub menu if i click exit button there it should close all teh activity and show the OEM Screen.

View 12 Replies View Related

Android :: How To Kill Programmatically Camera Activity?

Nov 11, 2010

What happens here is I call the crop image activity and then the camera activity runs in background. When I finish this activity, the camera is still alive at the background. So how can I kill programmatic the camera activity running in background?

View 3 Replies View Related







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