Android :: Intent Filters - Prevent Creation Of Multiple Activity Instances?
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
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
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
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
Aug 1, 2010
Is there a way to know which Intent Filter is responsible for launching an Activity which has two Intent Filters defined in AndroidManifest.xml? I want a slightly different set of logic, but not enough that should require a whole new Activity.
View 1 Replies
View Related
Jun 10, 2010
I am interested in activating another application's activity. I know from reading the Android SDK that it's probably better to do this with an implicit intent. However, this activity doesn't reside in an application I own, so I don't know the action and category and data flags on the intent-filter.
How can I examine an Android applications metadata like the activity classes and the intent-filters for those activities (if declared in the manifest)?
View 2 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
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
Oct 1, 2010
If I have a button that starts an activity, and the activity sometimes takes a second or two to throw up its own view, how can I most simply and reliably protect against the button being clicked multiple times and kicking off multiple (identical) activities?
View 12 Replies
View Related
Jul 3, 2010
I've read lots of articles about intent filters and I really can't understand exactly what they do? so please if anybody can explain to me with a clear example what is the role of intent filters exactly ?
View 4 Replies
View Related
Jul 23, 2010
In my android app, I wanted to start an activity 'B' from initial activity 'A'. I have created classes for both of these. However when using following code to start B, I get runtime error as application has stopped unexpectedly, try again.
CODE:..........
When I added a new entry in AndroidManifest.xml/manifest/application/activity/intent-filers for activity B then the application worked.
I have two questions:
When there are multiple activities entries in AndroidManifest.xml, how does android know which activity to start first?
I could not understand intent-filters.
Here is my partial AndroidManifest.xml
CODE:...................
View 1 Replies
View Related
Oct 31, 2010
I'm writing a client application for an Italian social network (Meemi) and I'd like to give the possibility to users to share their calendar events via my client. I noticed on my device (HTC Desire) that is possible to access to a "share chooser" from the Calendar event list: in fact I can share via email, sms, and bluetooth. I'd like to add my client to the this sharing list: but I'm not able to found the right intent filter to use.
View 2 Replies
View Related
Nov 4, 2010
I have search Android docs and for some insane reason I am not able to find the list of all available intent filters.
I am finding an intent filter, which would do something like , notifying me through Broadcast Receiver that a particular Activity (example browser, or email ) has been started or in foreground. Can anyone help me with that .
View 1 Replies
View Related
Feb 22, 2009
I've been grappling with an issue all day.
I am trying to create a program to deal with .torrent files that are clicked on and/or downloaded by the browser. Currently the downloader reports "Cannot download. the content being downloaded is not supported on the phone"
Im fairly sure this is doable as i recently encountered the same issue with pdf files untill i installed a pdf reader.
View 4 Replies
View Related
Sep 16, 2010
I created a widget that when clicked activates a PendingIntent.The problem is when I have more than one widget on the screen only the latest one will start the PendingIntent.I have read some about a unique request code, but not figured this out.Any ideas how I can have multiple widgets and the PendingIntents work for each?
View 1 Replies
View Related
Apr 15, 2010
I'm currently exploring Broadcast Receivers and Broadcast Intent. There are some aspects of the tutorials which are ambiguous to me. To my knowledge this is how the process works. I can broadcast an intent from my application and any receiver on the phone can act on that intent as long as the actions match. I can register a broadcaster receiver on anything that extends Context and when I do so I must provide a filter which will allow the receiver to act on one or more intent actions.The part which confuses me is defining a receiver via the manifest. Must the name of said receiver match a class name? Why should I ever define an intent filter with an action in the project manifest if I always have to provide another intent filter when I register my receiver in code?
View 1 Replies
View Related
Sep 14, 2010
is it possible to run multiple instances of the same app on android? What I mean if the app does not support multiple identities is it possible to install it twice and configure each instance separately?
View 1 Replies
View Related
Apr 15, 2010
I would like to do this, let me know if it possible in android?
App1 --> bindService() or startService() to AndroidService1 App2 --> bindService() or startService() to AndroidService1 (same service)
I would like App1 and App2 to get different instances of AndroidService1. Why I want to do this is say App2 doesn't need the service any more & it calls stopService() then App1 should still continue to work with its own instance of service app.
View 2 Replies
View Related
Jan 12, 2010
I've been attempting to use the <include> tag in some layouts and it seems that these are of limited use because of the flat namespace of the R.id.x approach.
Suppose I have a layout (attribs and xml namespace decl omitted for clarity).
CODE:.......
Now in my java code I have a conundrum. I am not able to identify each individual instance o f the children included layouts root view. In the include tags I can replace the root id with "row1" and "row2" so I can find the individual linear layouts using findViewById
eg:
CODE:.........
However, I can't easily access the two instances of the TextView which are children of row1 and row2 because all I have to play with is the single id "text"
ie:
CODE:..........
In this case, which instance (row1.text or row2.text) does this refer to, both of them, or none?
I guess I would need to use another means of accessing the children of row1 and row2.
View 3 Replies
View Related
May 13, 2014
I'm wanting to install 2 instances of the same APK.The app is: Star Wars Force Collection..Once you install the app and login to your account, theres no way to change accounts without uninstalling / reinstalling and logging into new account.
View 4 Replies
View Related
Jul 19, 2010
I love how SharedPreferences work in android and I would like to know if there is an easy way to save them to another file so I could load a previous instance of the prefs and vice versa. Basically when you load this file, all the preferences would change to how you had it before at once. I want to be able to swap 3 or 4 different versions of the same pref keys in this way. Is there an easy way to do this?
View 1 Replies
View Related
Jan 25, 2012
I was tinkering and editing an apk, and i managed to compile it and install it fine and it works and is suited to me. So i was wondering ( not too good with xmls ), is it possible to edit the manifest file to rename the apk so I can install multiple copies ( i.e. have the original unmodified one and the modified one at the same time ). I need this for testing purposes. Which lines do i need to edit exactly so the phone doesn't give me the "installing this application will replace the current..." warning, so I can multiple instances of it?
APKs are managed by package name, not by file name, but you can't simply change the package name in the manifest of a compiled APK.
Even assuming you manage to do it without messing up the file, which is not a simple task, there will still be code referring to the package name, so the app will crash.
View 4 Replies
View Related
May 3, 2010
OK, here goes my first post.
I have the calendar syncing with my gmail calendar, which has multiple calendars inside (mine, my wifes, ours, baseball schedule, cavs schedule, etc..)
I also have the stock "mail" (not Gmail) application syncing with my exchange at work.
Since I got 7 home screens to work with, I wanna put my Gmail calendar on home screen #1, and my exchange calendar on home-screen #7. Sort of a seperation of home and work
So I put the stock widget on home-screen#1, and again on home-screen#7. But a widget is basically just a frontend for an app running in the background. When I go to home-screen#1 and select MINE, WIFES, and CAVS.......that selection affects the widget on home-screen #7 as well. I go to screen #7, tell it to display Exchange only.......and when I go back to #1, it is switched to exchange.
So.....any way to do what I want?
1) Have a calendar on home-screen#1 that shows my Gmail calendar(s)
2) Have a calendar on home-screen#7 that shows my Exchange calendar
View 2 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
Aug 27, 2010
I have an intent filter to intercept urls from the browser on my domain. This will give the user the the choice of using the native application or the browser. I have setup the following intent filter as so.
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="myDomain" android:pathPrefix="/custom/" android:scheme="http" />
</intent-filter>
Now, it's not my intention to trap the user in the native application as there is much benefit from using the browser. So I would like to give the user some ability to go back to the browser within the application. I have created a button with an onClick that simply creates an intent for View and the url that would represent it. This will present the user with the choice dialog again. The catch to this is that a user is also allowed to select a checkbox to always use the native application. While that is well and good, sometimes absolutes are wrong.
So if I am reading a blog post that mentions a specific url and a specific part of that document, intercepting the url is not what the user intended but will send them to the native application. Also then upon selecting the button with the intent, they will immediately be sucked back into the application. How can you structure a ACTION_VIEW intent for the system browser or at least detect that the user has selected always use the native app so that you can use the ACTION_WEB_SEARCH (it has a different UI behavior with the history stack, which is why I wouldn't opt to use this action all the time).
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 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
Aug 12, 2010
I'm working on an app that launches the browser activity to perform a Twitter OAuth authorization. This process uses a callback url which will re-launch the activity that started the browser activity in the first place.My problem is that the browser pages remain in the history stack and when the user then clicks back from the preferences activity that launched the browser in the first place, they don't go back to the app's main activity, but instead are brought back to the browser. I've tried adding flags to the launching intent to prevent history and reset on clear, but it doesn't seem to work when running on my phone, only on the emulators.
View 1 Replies
View Related