Android :: Unwanted Automated Creation Of New Instances Of Activity Class
May 11, 2010
I have an activity (called Sender) with the most basic UI, only a button that sends a message when clicked.This works ok, the message is sent but every time a message is sent a new instance of Sender is started on top of the other. If I call sendSMS method three times, three new instances are started. I'm quite new to android so I need some help with this, I only want the same Sender to be on all the time
View 3 Replies
Feb 16, 2010
I added an intent filter to one of my activities, so that when a user clicks a URL like "www.mysite.com", and if my app is installed, my registered activity can be launched. It works well.
I see that this creates a new instance of my registered activity though, every time a link is clicked. Is there any way to prevent multiple instances from being created - just recycle an existing instance if one already exists?
View 6 Replies
View Related
Sep 18, 2010
I am writing a basic game engine and have an abstract class that represents any object that can be drawn in the 3D world, however inside this class is an abstract method Render() which I would like called automatically by the engine on each draw phase.
How could I implement this so that every class extending from my abstract class will automatically have Render() called? I am using java, android sdk 2.2, and opengl es
View 4 Replies
View Related
Mar 18, 2010
I have an application App1 which defines class A and uses instances of this class. What I want to achieve is - after App1 is installed on the device to be able to load App2 which defines and implements class B which is subclass of class A (imported from App1 package); and be able to get an instance of class B in the App1. Class B doesn't add any new interfaces, so using it as class A is ok. But I am not sure how to pass the instance of class B to App1 (preferrably without any user interaction).
Can anyone advise if this is feasible?
View 1 Replies
View Related
May 5, 2010
How to create arrays of class instances in JAVA. code...
View 1 Replies
View Related
Jun 3, 2010
I have an Android application with a main activity that is the tabhost. I'm adding multiple tabs to the tabhost with an intent to several activities.
My problem is that these activities are not created (onCreate is not called) until I click on the tab. This is a problem because I need to register broadcastreceivers: there may be broadcasts that are sent -before- a particular tab is opened.
I tried to work around this by:
Setting my receivers as static and registering from somewhere else. This is not possible because I need to call into methods.
Calling into tabHost.setCurrentTabByTag(the_tag) and then switching back to my root tab. This only works sometimes and this is a very ugly solution imo.
Not using activities but just using views instead. Also not a very elegant solution because it turns my tabHost activity into one huge master class doing all kinds of unrelated things.
View 1 Replies
View Related
May 10, 2010
A question that might be a bit general/basic knowledge, but for me it has a quite direct background, so i'll form it as an example:
I have an activity "entry" showing something equivalent of a blogpost, that might have comments. You can click somewhere to open a "comments" activity. But in this activity there are links back to entries, creating a nice line of activities.
If I call the "entry" activity (with an intent) on a link to show this entry, am I re-using the old activity, or am I creating an endless string of entry, comment, entry, comment activities (pretty cost- ineffective that would be).
View 9 Replies
View Related
Feb 2, 2009
I am trying to launch an activity from another activity .. Within the com.android.SingleLauncher..
I have activity launch code as ..
CODE:...........
I have set the android:multiprocess="true" in the AndroidManifest.xml of TargetSL I don't seem to see the multiple instances of TargetSL, which i am expecting ..
All i see is 2 process, where i was hoping to see an instance of TargetSL, for each launch that was invoked by the singleLauncher!
View 3 Replies
View Related
Feb 19, 2010
I want to create multiple instances of an activity in the same process. Should I use FLAG_ACTIVITY_NEW_TASK flag like the code below?
CODE:...............
This code is executed in class A to create another instance of activity A.
This question, will this code create another task? As I understand is a process can only have one task. Does it mean the two activities will exist in different tasks? That's what I want. I want the two activities to be in the same process.
View 1 Replies
View Related
Jul 1, 2010
I was wondering is it possible to create multiple instances of a single Activity in Android?
I currently start my own inCall screen for a Voip Test by using the following code...
This allows me to start the Activity fine. However when I call it for a second it just returns to the Activity already created rather than creating a new Activity and placing it on the stack.
I would like to be able to create the activity multiple times so that I have two or 3 Activities on the stack and the user can switch between them, using Home, Back buttons etc... Is this possible and if so what am I doing wrong?
View 1 Replies
View Related
Mar 31, 2010
I would like to display a an access dialog activity at the start of my application.
In other words, I would like to start another activity (in dialog theme) as soon as my Main Activity is loaded. But, I know that I can not start an activity while another is creating.
I tried to start this activity in the onResume() method : I can see the new activity called, but the Main activity do not respond after closing the new activity.
Is there a solution to do this, without using delayed intent ? May i use a special flag for my intent ? I did not find, in the activity cycle, a way to detect the end of activity loading.
View 6 Replies
View Related
Jul 18, 2010
When starting two activities of the same class within the same instance using the flag REORDER_TO_FRONT, the new extra information of the second call does not override the first starting activity. Is this the desired behavior? How do retrieve the new extras?
For example: In the StubActivity, I have this code:
Intent i = new Intent(this, A.class);
i.putExtra("foobar",1); startActivity(i);
Activity A is displayed, and then this code is called upon a button press:
new Intent(this, A.class);
i.putExtra("foobar",2);
i.setFlag(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
Activity A is re-displayed. Now check for the extras: int foobar = getIntent().getExtras().getInt("foobar")
Turns out that foobar = 1
View 2 Replies
View Related
Jul 22, 2009
I need to correctly be able to differentiate between emulator instances. I know it's easily done with real devices. With real devices, you can use getDeviceId or getLine1Number from TelephonyManager. With emulators, all the instances have the same device id, same subscriber id, and same line1 number. Is there a way to differentiate them? Using NetworkInfo, I can call the toString method and I get my ip and the port on the computer. The problem with that is that the port is always different. I would like something more stable. Like when you use "adb devices" in command line. Emulator #1 is almost always "emulator-5556" and emulator#2 is almost always "emulator-5554". Is there a way to get the same info I get from "adb devices" in my code? If not, is it possible to use a command line parameter to force the emulator to use a certain phone number?
View 3 Replies
View Related
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
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
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
Nov 12, 2010
I'm struggling with my app that launches multiple instances of the same Activity using the same intent. My main activity is of class type A and it does a startActivity() of two children that are of the same class type B. So we have B1 and B2 launched. If B1 and B2 are both paused (by pushing back button and making sure finish() is not invoked on them so they are truly paused), how can A uniquely bring either B1 or B2 to the foreground again? I do want to launch a new B activity. I want to uniquely bring B1 or B2 to the foreground.
so both B1 and B2 were created like this... Intent intent = new Intent(context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
Now I want A to bring B1 (or B2) to the foreground/front so I use the below code, but how do I distinguish B1 or B2 when starting the activity? This only brings the last instance of B that was on top to the foreground.
Intent intent = new Intent(context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);
I've tried keeping around references to B1 and B2 and doing something like this, but this also only goes to the last instance of activity class B that was on top...
Intent intent = new Intent(B1context, B.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); B1context.startActivity(intent);
I even tried this, but it still doesnt get me my unique B1 or B2... Intent intent = B1.getIntent(); // i.e. the original intent that started me startActivity(intent); // still only brings to front the last B that was on top.
View 3 Replies
View Related
Aug 19, 2009
An activity can be called from existing activity through *startActivity(intent); *
Is t possible to call an activity from non Activity class ? and how?
View 2 Replies
View Related
Apr 4, 2010
New to Android. I always used a app called Magicall on my WM device. I want to be able to block specific contacts, unknown number or anonymous numbers and also specific contacts for SMS. I can see I have the option to send a contact direct to voicemail but don't have the same facility for unknown/anonymous callers and nothing to block SMS. Any recommendations for an app that works with 2.1? (I'm using a HTC Desire)
View 6 Replies
View Related
Mar 3, 2010
I have a class defined as
public class viewGroups extends ListActivity
Somewhere in the class I have
objItem = new clsContactGroups(context);
I am wondering what is advised to be used here? Which context?
I know four choices, but maybe there are others...
this
this.getApplicationContext()
this.getBaseContext()
this.getParent()
I use this Context to show a Toast. So I would like to show on the front-most view visible.
View 1 Replies
View Related
Jan 2, 2010
I have three classes one main-activity(named MainMap), one non-activity class(named MyItemizedOverlay), and one activity class(named AudioStream). I want to start AudioStream activity from non-activity class but i don't know how to.
View 1 Replies
View Related
Aug 18, 2010
I have an activity class(Application Class ) which calls a service class(Service Class) and closes. The service class takes about 5 seconds to complete its task and calls a method which is present in another class(Callback Class). Now according to the result, the callback needs to notify the Application class.Once i get the callback from the service, I tried calling a method defined in the Application class. In this method i create a new intent of Application class and call startActivity(Application Class). But this is not working. Can anyone tell where i am going wrong and what can I do to solve this issue.
View 5 Replies
View Related
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
Aug 16, 2010
I wrote successfully TTS with some references in Activity.
However, I want to call this TTS in my own class as below.
CODE:............
View 3 Replies
View Related
Apr 19, 2009
Can i call method of Listactivity from Activity class? I have creates Intent object of myListActivity class and called startIntent() from myActivity class.
View 3 Replies
View Related
Jul 28, 2010
I've got two activities, one of them is called MyActivity. I want both of them to be able to use a function located in a class othat we may call MyClass. In MyClass, I try to use an intent to launch the activity AnotherActivity. Since the constructor takes a context as parameter, I simply tried to store a context from the activity in the constructor, and then use it when I try to create my intent.However, even thought none of the arguments are null (checked that with a simple if-statement), intent seems to be null and a NullPointerException is thrown. Why does it not work, and what can I do to solve the problem?
I'm quite new to Android and Java development, so please explain it as basic as you can.
View 2 Replies
View Related
Jan 5, 2010
I am new to Android, and I haven't developed any app regarding databases on Android yet. So I have a few basic questions. I am after a good database class sample, that will let me to run the CRUD operations. I would like to use it as a static class
like: clsDB->Select("select * from clients");
or objClient->Delete(clientid);
I am wondering if someone, can share his database classes, if more people share the best. Also I have in mind to reuse this class in multiple ways, I will have services, activities etc...
View 4 Replies
View Related
Sep 18, 2010
I've adapted the GridInputProcessor-class of the 3D-Gallery ( http://android.git.kernel.org/?p=platform/packages/apps/Gallery3D.git;a=blob;f=src/com/cooliris/media/GridInputProcessor.java;h=91dfd4783be6b21ec8ff2518a5c244752570e90d;hb=HEAD ) so that it detects upward/downward swipes.
The detection of swipes works, but I now want to start another activity (or draw a bitmap on the currently displayed activity), but I seemingly can't use startActivity(mContext, myIntent), because the class declaration is public final class GridInputProcessor implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {so it doesn't extend Activity...
Can I still start an Activity through this class, or how would I go about doing this? I have also tried sending a broadcast, but this is also not "implemented".
View 1 Replies
View Related
Nov 18, 2010
This is vinod i have been saving problem while i am starting Activity in receiver so i would know this is the way or not for start activity in receiver
View 3 Replies
View Related
May 4, 2010
For example, I have an activity that uses a utility class. I would like to be able to start an activity from the utility class and have the activity result sent back to the utility class.
The only way I could think of starting the activity was to pass the original activity to the utility class, so that the utility class could use the original activity to start the activity. The problem with this is that the activity is sent to the original activity, rather than the utility class.
I also thought of actually making the utility class an activity itself, but that would make using the utility class much more complicated.
View 10 Replies
View Related