Android :: Calling StartActivity From Outside Of An Activity Context

Oct 12, 2010

I have implemented a ListView in my Android application.

I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside the overridden ArrayAdapter.getView(...) method, I assign an OnClickListener. In the onClick(View v) method of the OnClickListener, I want to launch a new activity.

I get the exception:

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

How can I get the context that the ListView (the current Activity) is working under?

Android :: Calling startActivity from outside of an Activity  context


Android :: Calling StartActivity From Outside Of An Activity Context Requires The Flag_activity_new_task Flag

Sep 21, 2010

I tried to create a edittextbox, and button next to it, in the status bar.! I created it and tried to launch the browser activity, when somebody enters a URL in the textbox & click that button.

I get runtime exception as below.Can anyone please help what is the issue with this exception ? I know that Status bar is not a seperate activity. It is part of 'PhoneWindow'.

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

View 7 Replies View Related

Android :: Calling StartActivity From Outside Of An Activity

Dec 7, 2009

I have a TabActivity subclass that attempts to start a new activity via a menu item selection in onOptionsItemSelected.I am receiving the following exception which eludes me at the moment.I'm not sure why it thinks I am *not* in an activity!

View 2 Replies View Related

Android :: Calling StartActivity From Outside Of An Activity - Getting Error

Sep 11, 2010

I'm using an AlarmManager to trigger an intent that broadcasts a signal. The following is my code:

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

I'm calling this code from an activity, so I don't know how I could be getting the following error...

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

Is this really what you want?

View 1 Replies View Related

Android :: Update Intent Of An Existing Activity While Calling StartActivity

Sep 13, 2010

I am having two activities, say activity A and B. Activity A is an ListActivity, and when the items in the list is selected, it will call startActivity() to bring up B. The problem here is that when I am in B and click the home key, and then go to the application launcher to resume my application, A will be brought up again. This time when I click a different item in A, it will bring up B with the old data of the previously selected item before the home key was clicked.

After examinzing the code, I found that the startActivity does not update the intent of B. I found a post here about the similar question, and the answer was to overwrite the onNewIntent. However, I found that it doesn't work, because this method never get called when the second time I call startActivity. I am sure that this is the same instance, because I've printed out the instance number. Is there any other ways to update the intent of the activity? Or I need some other settings to make the onNewIntent get called? I didn't set any flags or launch modes, so everything is default.

View 1 Replies View Related

Android :: Exclude Own Activity From Activity.startActivity - Intent

Oct 17, 2010

My app works with pictures. It can take multiple pictures as an input, process them, and send them again to another app.

As a consequence, my main Activity has declared an intent filter on ACTION_SEND_MULTIPLE for image/* mimetypes and can result in issuing a new Intent with the same action and data type using Activity.startActivity(Intent).

Is there a way to exclude my own activity from the list of apps that is displayed to the user after the startActivity() call ?

View 1 Replies View Related

Android :: Start An Activity In Different Apk Using StartActivity - Using The Activity Name Or Similar

Apr 20, 2010

I have tried to write an Android application with an activity that should be launched from a different application. It is not a content provider, just an app with a gui that should not be listed among the installed applications. I have tried the code examples here and it seems to be quite easy to launch existing providers and so on, but I fail to figure out how to just write a "hidden" app and launch it from a different one.

The basic use case is:

App A is a normal apk launchable from the application list.

App B is a different apk with known package and activity names, but is is not visible or launchable from the application list.

App A launches app B using the package and class names (or perhaps a URI constructed from these?).

I fail in the third step. Is it possible to do this?

View 3 Replies View Related

Android :: Get Calling Context In Service

Aug 30, 2010

So I'm working on a service that will handle requests to send data to a socket.I've done socket programming in a service before, but only within the same application. I'd like this to just sit and do nothing until any application wants to give it data to send. That's all well and good.I have register an intent filter and the usual stuff and can process the data. But I want to process the data coming from different activities in different threads (subsequent calls from the same application will be computed on the same thread).Is there a way to get the calling package or app or whatever? I'd prefer not to require passing in an identifier as an extra to prevent spoofing. (It's not a serious security concern, it's just each application needs its data processed in the order that it's received.)

View 1 Replies View Related

Android :: Activity Events On StartActivity

Sep 28, 2010

Is there any event triggered on an activity when I call startActivity("activity_id", myIntent);

If the Activity exists already. I pass a parameter to the activity via i.putExtra("someID", someSerializableObject ); and would like to call a method to refresh a WebView. Right now, the call on startActivity brings the activity in the foreground but the webview does not display what i want.

View 1 Replies View Related

Android :: StartActivity -ForResult - At The Creation Of Main Activity

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

Android :: StartActivity -intent - And Resume To Main Activity

Jul 2, 2010

I've got an app that creates an intent for the last.fm android app in which it will start the "recommended" station for my account when i press a button. The trick i'm trying to figure out is how do i get the phone back to my app without the user having to navigate back manually? Once it start the last.fm intent it takes you to the playlist and i need it to resume back to my app automatically.

View 2 Replies View Related

Android :: Pass Intent Via StartActivity() To A Running Activity

Aug 10, 2010

MyService and MyClient are both running, although MyClient is currently in the background. If MyService sends an Intent to MyClient via:

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

How do I get this Intent in MyClient? Running this code triggers onResume() in MyClient, but because it's already running, calling getIntent() returns the Intent that initially created MyClient, which is always android.intent.action.MAIN

View 2 Replies View Related

Android :: How To Get Calling Activity Instance From Called Activity?

Jul 9, 2010

I have a Contact Activity which is derived from ListActivity, which displays list of contacts, and on click of item, a new Activity Message Activity derived from ListActivity is initialized.Now I know, I can pack some information in Bundle and pass it before creating activity, but is there a way I can get instance of "ContactActivity" in onCreate method of "MessageActivity"?

View 1 Replies View Related

Android :: Context To Use In A Activity Class?

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

Android :: Get Activity Object While In View Context

Oct 10, 2010

This is a followup to this post: http://stackoverflow.com/questions/3897176/findviewbyid-in-a-subclassed-surfaceview-throwing-runtimeexception Based on Romain Guy's feedback (which I'll accept shortly as it is a solution), I'd like to obtain the calling Activity from within the View, so that I can use it to obtain the desired Text View resource. I don't see any methods in View that return Activity. What is the proper way to do this? Or is there a better alternative for working with TextViews from within another View context. Basically, I am calling setContentView(R.layout.xxx) in onCreate() (as usual), so I don't really have a way to pass in references to additional TextViews unless I awkwardly retrieve the View after setContentView and then make calls on it.

View 1 Replies View Related

Android :: Difference Between Activity / Application Context?

Nov 8, 2010

This has me stumped, I was using this in Android 2.1-r8 SDK: Code...

View 1 Replies View Related

Android :: Start An Activity From A Non-context Class?

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

Android : Access Context Of A Class Which Is Not An Activity?

Jan 28, 2009

Can anyone tell me how to access context of a class which is not an activity?

View 10 Replies View Related

Android :: Theme.Dialog Activity And Context Menu

Jun 22, 2009

i have dialog style activity android:theme="@android:style/Theme.Dialog"The menu appears about 50 px from the bottom of this dialog. So if activity screen is too small - it right in the middle of the screen. Is there any way to anchor menu to the bottom of the screen?

View 5 Replies View Related

Android :: How To Display Images In Activity's Context Menu?

Jan 20, 2009

Does someone know how to display images in an activity's context menu? I've tried setIcon(resId) and it doesn't work (although it does work in the Options Menu).

View 2 Replies View Related

Android :: Opening A Context Menu In OnCreate Of An Activity

Aug 9, 2010

I have a need to capture some user input when an activity opens for the first time. I'm hoping to give the user a list of options to select from, which will be pulled in dynamically. I'll then store the selected value locally for future use. I'm not finding a way to do what I'm after and was wondering if anyone has run into this before and how they solved it.

Fantasy Football<http://chriswstewart.com/android-applications/fantasy-football/>- Android app for fantasy football fanatics and MFL owners Social Updater<http://chriswstewart.com/android-applications/social-updater/>- An easy way to send your status blast to multiple social networks

View 9 Replies View Related

Android :: Pass Activity Context To Constructors To Use Internally / Is This Bad?

May 26, 2010

Is is bad practice to pass the Context to a constructor and save it as a private variable for internal use? The other option is to pass the Context as a parameter to methods that need it.

Which is the better option?
I have a feeling that passing to the constructor might result in memory leaks accidentally.

View 3 Replies View Related

Android :: Invoking A Context Menu When An OnClickListener Is Applied To An Activity

Aug 3, 2010

Please find the code sample below:

public class Abc extends Activity implements OnClickListener{
private ListView displayList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
displayList =(ListView)findViewById(R.id.addressbooklistview);
addressbookAdapter = new CustomListAdapter(this,addressbookList);
displayList.setAdapter(addressbookAdapter);
registerForContextMenu(displayList);}
I am not able to invoke the context menu on long press. Please let me know any solution for the same.

View 2 Replies View Related

Android :: Calling Activity From Service

Nov 19, 2010

i am writing an app in which i need a background service to call an activity and show some result.

View 4 Replies View Related

Android : Error While Calling An Activity From Another / How To Fix

Apr 4, 2010

me and my partners are working on developing a pwa client for android Am getting an error while calling an activity from another activity.the error is as follows...

View 3 Replies View Related

Android :: Context Menu In List Activity - When Make Long Press

Oct 18, 2010

I have list activity with custom array adapter and I can't to get context menu when make long press on list item.

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Why I do not see context menu? What I do wrong? How to get context menu with array adapter and ListActivity.

View 1 Replies View Related

Android :: What Is The Significance Of Context In Various Constructor Of Intent Class When Starting An Activity

Mar 4, 2010

I had come across a code snippet which calls for an activity without referring to any context. Before, i was considering that context is used to tell about the calling component. But as i came see that another component can be called without any reference to context, it makes me wonder what purpose it might be serving. please put some light on it.

Here is the code which calls for an activity without referring to 'context'

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

View 1 Replies View Related

Android :: Need To Take Into Account When Repeatedly Calling Same Activity?

Oct 28, 2010

I am developing an app where a single activity is instantiated multiple times by itself. I guess you could think of it like a book where each activity is a page. At the end of the page (activity) the user presses a button to go to a new page. I fire off an Intent for the same Activity, but I push different data into the Bundle so that a different page is loaded. This works fine, and I like the fact that the user can back up to a previous point, but my question is whether this will eventually be a problem? What happens if this activity is instantiated 10 times, or 50, or 100? Will the device run out of memory, will GC come along and clean up old activities, or what? If GC does clean them up, what happens when the user presses Back and the previous Activity is no longer on the stack? Is it better to keep track of the user's path, finish() the activity, and override the Back button so that whether the user is moving forward or backwards, I only load a single Activity? Another approach I could take is to refresh all the data on the page so that it's still the same activity, but with new data. The Back button would not work as expected in this case.

View 2 Replies View Related

Android :: How Can I Show My Activity On Top Of In-calling Screen?

Apr 23, 2010

I'm writing an android application which listens the phone calling events. What I want to do is, if there is a call incomes or outgoes, an activity shows with my customized info.I want to this screen keeps showing during the calling period. However, if a call is coming, the system UI which shows the contact always appears on top of my activity.I've found some apps already realized this function, but mine can't.

View 1 Replies View Related

Android :: Calling Finish() After Starting A New Activity

Apr 26, 2010

The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is this even the best approach, or would this be better done with some kind of Intent Flag?

Is it correct to call finish() after calling startActivity() on the new activity?

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

I'm still taking in the whole 'Message Queue' method of doing things in Android, and my assumption is that calling startActivity() and then finish() from my first Activity's onCreate() will log each respective message in the message queue, but finish execution of onCreate() before moving on to starting the next Activity and finishing my first one. Is this a correct understanding?

View 1 Replies View Related







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