Android :: How To Change ClassLoader Of Activity?
Jun 25, 2010
I newed a DexClassLoader to load one jar file dynamicly.I think I have to set my cl to be default ClassLoader of Activity.to achieve similar thing. However, it does not work. So event I changed Thread's context classloader, Activity's classloader is not my cl.My question is how to change Activity's ClassLoader?
View 5 Replies
Jan 10, 2010
I'm still in the concept stage so I don't need implementation details. My question is whether it is possible is transfer a JAR file over a socket and use a classloader to launch an activity.
View 5 Replies
View Related
Dec 17, 2009
I have a ClassLoader in Activity's onCreate which loads a specific class from a library, and is working fine, except that when activity is destroyed, the memory resources about the loaded class are not released.If the same activity gets created multiple times very quickly (by launching it, and destroying it by pressing the Back button), and the process doesn't happen to be killed by Android yet, the memory usage of the corresponding process grows continuously until the app crashes,and process dies.The problem is that this happens even if no objects are instantiated using the loaded class. There seems a problem with garbage collector, which doesn't seem to release resources about the loaded class on Destroy even if there are no references to it.If android would have killed the process right away when the last activity of the process gets finished, there wouldn't be a problem, but this is managed by Android system, and it doesn't always kill the process right away. A workaround may be to kill the process explicitly on destroy, but this is not encouraged way to do, as Android is supposed to manage the process.
An alternative is to have a functionality that allows a class to be unloaded onDestroy, but this doesn't exist. By design, the garbage collector is supposed to take care of this.Is there a solution regarding this?
View 8 Replies
View Related
Jan 21, 2010
When views with different type have same id and screen orientation changes,
either java.lang.ClassCastException: android.view.AbsSavedState$1 or java.lang.IllegalArgumentException: Wrong state class -- expecting View State will occur. (depends on the view's order)
Because View.dispatchRestoreInstanceState() checks id only.
You may wonder why anyone would make views with different type to have same id.
But it can happen when you use tab activity.
Imagine you have tab activity with two children activity.
Tab1 is ListActivity and Tab2 is ExpandableListActivity.
Both activity have id of "@android:id/list" but the type of view is different.
This means we cannot use ListActivity & ExpandableListActivit at the same in one tab activity.
View 4 Replies
View Related
Jul 30, 2009
I have a notification that starts my activity and passes a messages using the intent's putExtra() function. The message is then displayed to the user in the activity's onCreate function. When the application is restarted due to a orientation change, the message is shown again as it is still in the intent's bundled data.
How can I remove the extra data?
I tried the following:
Bundle bundle = getIntent().getExtras();
if (bundle.getBoolean("showMessage")) {
// ... show message that is in bundle.getString("message")
// remove message
bundle.remove("showMessage");
}
But the message will still be shown after the orientation changed, seems like the intent used is not the one I changed, but the original one. The only workaround I found is to save the showMessage additionally in onSaveInstanceState(). Is there another way? Or is this the way to go?
View 2 Replies
View Related
May 9, 2010
I read some documentations about classloaders, but im still not sure where and why they are needed. The Android API says: Loads classes and resources from a repository. One or more class loaders are installed at runtime. These are consulted whenever the runtime system needs a specific class that is not yet available in-memory.So if i understand this correct, there can be many classlaoders which are responsible for loading new classes. But how the system decides which to use? And in which situation should a developer instantiate a new classloader? In the Android API for Intent there is a method
If activity A which is located in Project A (in Eclipse) defines an object which i want to send to Activity B in Project B using putExtra of the Intent object. If this object which is send over the Intent is not defined (source code in project B), then there is a NoClassDefFoundException. So can i use the method setExtraClassloader to avoid this exception? If yes, how can i decide which classloader object i have to pass? And how do I instantiate it correctly?
View 2 Replies
View Related
Aug 20, 2010
I have two tabs each with an activity. Now I implemented an TouchEvent where I will change the activity of one tab. How can I do that. I heard about ActivityGroup and I tried it but If I call that ActivityGroup teh activity switch to fullscreen and the tabs are gone.
View 4 Replies
View Related
Jun 23, 2010
How to change background of activity and background of the application name at the top of your activity?
View 2 Replies
View Related
Nov 24, 2010
i am using
Window w= getWindow();
w.setTitle("adf as afsa");
to change title of my current activity but it not seem to work.. can any one guide me how to change this?
View 1 Replies
View Related
Oct 5, 2010
I need to change Activity to ListActivity. But I can't start my project... do ı need change manifest.XML for it? Or how can I change screen from Activity to ListActivity? Is there any difference to startActivity(new Intent(this, list.class))? Code...
View 2 Replies
View Related
Mar 5, 2010
How can I change the titlebar color in an Android app? I tried: this.setTitleColor(Color.BLUE); but it changes color of written text on it not title bar color.
View 1 Replies
View Related
Jul 28, 2010
Everywhere I look online, it seems that I must use an animation to change views dynamically (like slide in, out). Do I have to do this, or can I simple just setContentView() on each new activity?
View 1 Replies
View Related
Aug 25, 2010
I have two Activities A and B . When i swithc between activity A to B the Activity b comes with 3d transition animation.when i press a back button in Activity B the Activity B exits with Animation.
View 1 Replies
View Related
Feb 18, 2009
Is there a way to change the font size on a tabbed Activity? I can add an icon but I'd like to shrink the font a bit?
View 3 Replies
View Related
Mar 17, 2010
how can i change value of a Activity label in AndroidManifest.xml file through the code in java. welcome your response.
View 3 Replies
View Related
Apr 8, 2010
Suppose I have ActivityA and ActivityB, also suppose that ActivityA is active. I need to:
Programmatically set a text of EditText in ActivityB from ActivityA
Launch ActivityB
Here's my code:.............
ActivityB starts, but without any text in txtResult.
View 1 Replies
View Related
Sep 2, 2010
I have created the meat and guts of my application but I want to add a different activity that will be the starting point (sort of a log-in screen).
Couple questions:
1) I have a fairly decent handle on how to switch between activities (based on this article: http://www.linux-mag.com/id/7498) but I'm not sure how to go about creating a new one (with eclipse).
2) once I have a new activity created, how can I set it as the default activity of my application? I presume I could just change the name of the classes...but is there a more elegant way to handle that (maybe within the AndroidManifest.xml)?
View 1 Replies
View Related
Mar 16, 2010
I am trying to develop a simple application where users need to answer certain questions. I want that the textview should be changed dynamically in the same activity with sliding to left or right animation.
Can someone let me know how to do this?
View 5 Replies
View Related
Jul 14, 2010
When we create a new activity, in the Android.manifest file, we can set some text for the activity's label. It looks like:
<activity class="MyActivity" android:label="Some text here!">
Is there anyway to access that programatically and change it during runtime? Regards Dileep
View 2 Replies
View Related
Jul 13, 2010
I think I already know the answer to this, but I just wanted to confirm (I think no horrible ramifications)...
View 5 Replies
View Related
Sep 28, 2009
It is possibile to start an outcoming call without change screen? I've a widget that perform a call for get remaining credit, but I don't want to change screen... If this isn't possibile, is possibile to return to the home screen when the call is terminated? Now the screen remain on last call log.
View 2 Replies
View Related
Nov 13, 2009
I think I've missed something in how Android is supposed to work! I have the main Activity with a menu option that opens the preferences screen. What I need is a way for any changes that were made to be communicated back to the main Activity as soon as the preference is activated. At the moment the only way I could get it working is by using the intent data that gets sent back when the prefs activity closes but this isn't really enough. The reason why it needs to be instantaneous is that one of the preferences is a 'Clear cache' button, so I would like the data to be deleted when the user requests it and no later!
View 4 Replies
View Related
May 6, 2010
I m currently working on landscape mode for android app in which i want to know how to maintain the state of the activity and views displayed on orientation change i.e from portrait mode to landscape mode ?
View 3 Replies
View Related
Apr 5, 2010
I am working on a MVC implementation for Android (to be subsequently hosted on SF and/or GC).
It works like this:
Activity (View) <=> Application (Controller) <=> Data (Model) <=> Persistence (DB/Network etc)
The scenario is:
1. Activity launch (main/launcher)
2. Notifies Application about performing a data transaction
3. Upon receipt of data response, controller devices which Activity to launch (or update existing)
4. Application has overridden the method onConfigurationChange
Problem: When the orientation is changed, the Application is notified about onConfigurationChange but:
a) The "current" activity is Destroyed and recreated -- which is fine to some extent b) The new instance which is created is automatically => onCreate, onPause, onStop, onDestroy.... now that's catastrophic.
View 4 Replies
View Related
Sep 11, 2010
My MainActivity (the one that is started by the android application) is a TabActivity which contains several tabs (which are implemented as activities as well). In a certain tab/activity I want to prevent the change of orientation/rotation when the phone is turned. What is the easiest way to achieve this?
View 2 Replies
View Related
Apr 6, 2010
i've developed an android app that's fetches an xml file and displays this data via several markers on the map. This works fine so far. The problem right now is that when i switch the orientation of the phone (portrait->landscape or vice versa) the markers disappear for a small moment, the xml processing is started again and then they reappear. Is there a way to prevent this re-loading of the file? It only takes about 2-3 seconds.
View 2 Replies
View Related
Jun 22, 2010
I have created 3 tab in my application and every tab has it's own view. in tab 1 i have a button on top which load another view on same tab but when that view load tab has been hidden this is my problem, i want view switching with in single tab by click on button.
I am not able to change the activity with tab by clicking on button.
View 2 Replies
View Related
Nov 20, 2010
I am creating an android application in which uses tabs. There are three tabs which runs different activities. Activity which runs tab 1, has a button. I want to change content of Tab 1 by clicking on that button. But If I call another activity it doesn't start in tab1 but replaces tab.
View 5 Replies
View Related
Mar 12, 2010
I'm trying to find a way to properly handle setting up an activity where its orientation is determined from data in the intent that launched it. This is for a game where the user can choose levels, some of which are int portrait orientation and some are landscape orientation. The problem I'm facing is that setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) doesn't take effect until the activity is fully loaded. This is a problem for me because I do some loading and image processing during startup, which I'd like to only have to do once.
Currently, if the user chose a landscape level:
the activity starts onCreate(), defaulting to portrait discovers from analysing its launching Intent that it should be in landscape orientation continues regardless all the way to onResume(), loading information and performing other setup tasks at this point setRequestedOrientation kicks in so the application runs through onPause() to onDestroy() it then again starts up from onCreate() and runs to onResume() repeating the setup from earlier
Is there a way to avoid that and have it not perform the loading twice? For example, ideally, the activity would know before even onCreate was called whether it should be landscape or portrait depending on some property of the launching intent, but unless I've missed something that isn't possible. I've managed to hack together a way to avoid repeating the loading by checking a boolean before the time-consuming loading steps, but that doesn't seem like the right way of doing it. I imagine I could override onSaveInstanceState, but that would require a lot of additional coding. Is there a simple way to do this?
Solution:
As per Daniel's answer, this was actually quite easy to fix. I just needed to make a few small changes. In my 'menu' Activity, where the player would choose which level to play, I just had to add an if/else check to choose which class would be started by my Intent. This was done with a simple int representing portrait or landscape, determined when the player selected a level. I then created a second class extending my 'GameLogic' class; this is the class which contained most of the code for the game itself, rather than the menus, instructions, etc.
public class GameLandscape extends GameLogic{}
Literally that simple and completely empty. That way it inherited all the code from my previous activity where I had already coded it to handle things differently depending on the orientation. Lastly I just had to add a line to the manifest stating that GameLandscape would always run in landscape, and GameLogic would always run in portrait.
View 2 Replies
View Related
Mar 10, 2010
I have written code to display images in sequence. when click on next button it shows next image.and so on. i m using android 1.5 and save landscape images with same name(as portrait images have) in drawable-land folder. when i rotate the device it takes all landscape image from drawable- land folder. but the problem is ,it again start showing images from the beginning. how to solve this problem.
View 2 Replies
View Related