Questions tagged [start-activity]

Launch a new Activity by using Intent in Android.

This public method launches a new Activity and use an Intent. An Intent is an object that provides runtime binding between separate components (such as two activities). The system receives this call and starts an instance of the Activity specified by the Intent. You will not receive any information about when the activity exits.

For example, you are in ActivityA and want to launch ActivityB. You do as follows:

// Create a new intent with current activity and new activity
Intent intent = new Intent(Activity1.this, ActivityB.class);
// Call startActivity to launch the new activity with intent
startActivity(intent);  

An Intent can pass datas to new Activity, see Start the Second Activity topic from Google Documentation. Also, you can use the method startActivity(Intent, Bundle) where Bundle is additional options for how the Activity should be started.

Note: You must declare the new activity in your Manifest file as the old one, like the following example:

<activity 
    android:label="@string/app_name"
    android:name="com.package.name.ActivityB" />

About this method, see the startActivity(Intent intent) Documentation
And the SO question How to start new activity on button click
Related tags: , , ,

470 questions
0
votes
1 answer

Android - calling startActivity() from LocationListener.onLocationChanged(), Is this really what I want?

I am writing a foreground service to receive GPS notifications, send system notifications and make calls. The application has no Activity attached to it, only a service that is launched from a boot receiver. When I was trying to start the calling…
Elist
  • 5,313
  • 3
  • 35
  • 73
0
votes
1 answer

Getting noactivityfound to handle intent error android

I am making an app where user will be able to add any url as a bookmark. In my main activity once the user clicks a button, i am starting another activity. protected void BookMark(){ if(check){ Intent intent=new…
manishpro
  • 141
  • 8
0
votes
3 answers

retrieving image from sdcard in android

in my android application, when i click on button new activity starts and retrieves image info from sdcard n display it.when i click one of thumbnail of image i want to send that image to 1st activity.how can i do this using…
yuva ツ
  • 3,707
  • 9
  • 50
  • 78
0
votes
4 answers

onActivityResult is not working properly

I have an activity 1 which send intent to activity 2 as bellow: activity 1 periodDatetv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub …
Android Developer
  • 1,039
  • 1
  • 9
  • 33
0
votes
0 answers

onbackpressed exits the application

I have an application that has a Main menu (MainMenu.java) which starts an activity (ActivityBlah) on a menu button press: public void onClick(View v) { switch (v.getId()) { case R.id.AcitivityBlahButton: startActivity(new Intent(MainMenu.this,…
0
votes
2 answers

send email activity in new instance

I'm trying to send an email from my email class but when the program gets to startActivity it crashes I think it might has something to do with the manifest. Below is my main activity import android.app.Activity; import android.os.Bundle; import…
Sam Stephenson
  • 5,200
  • 5
  • 27
  • 44
0
votes
3 answers

Android onActivityResult Query

I have two Activities A,B From Activity A, I do open my gallery and I want that when the picture is selected from the gallery it should go on Activity B and not on Activity C. Is this possible?? share_picture.setOnClickListener(new…
Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143
0
votes
1 answer

Android start activity

I am using MonoDevelop for Android with the MapsAndlocationDemo and I have a question about starting another activity. Here is my code: public void loadActivity (Context ActivityContext) { var second = new Intent(ActivityContext,…
Garry
  • 1,251
  • 9
  • 25
  • 45
0
votes
1 answer

Android: reload the activity

I have the following situation: Activity A Activity B (marked on manifest as singleTop) When I go from A to B, I call B.startActivity setting the flag "FLAG_ACTIVITY_REORDER_TO_FRONT" (in this way when already open I don't recreate the…
0
votes
3 answers

RuntimeException: Unable to start activity (Android)

I am working on an app and am getting a strange error. Two out of the three devices that have been used so far to test the app work perfectly when the log in button is tapped and a new activity is started. The two phones that work are both running…
localhost
  • 1,062
  • 3
  • 15
  • 35
0
votes
2 answers

Is it normal to call two activities from two buttons in sequence

I didn't know how to phrase the question properly so let me explain. I have noticed that on the android platform that when you press two buttons in one activity in quick sequence (press one button then the other before the activity has a chance to…
Raigex
  • 1,205
  • 12
  • 32
0
votes
2 answers

How to start a new activity for a result from a tab activity in android

Possible Duplicate: start Activity from an other Activity with Tabs I have a TabHost containing 3 tabs. Having Act1, Act2, Act3 for 3tabs. Now i want to start a new activity (say Act4) onclick of a button in Act1. I should see the tabs when I'm…
0
votes
1 answer

Getting error at opening preference screen in Android 2.2 (android.view.InflateException)

I getting an error in my app with android 2.2. The error is the following: java.lang.RuntimeException: Unable to start activity ComponentInfo{dev.luizmoratelli.cowpea.three.m.ui/dev.luizmoratelli.cowpea.three.m.ui.Preferences}:…
0
votes
1 answer

Update calling activity after PreferenceScreen close?

I have an activity A from where I invoke a PreferenceAvtivity P via a normal startActivity. The user can update some settings there, and after the P is closed, activity A should update itself to get the new settings. Now I've read here How to return…
Toni Kanoni
  • 2,265
  • 4
  • 23
  • 29
0
votes
2 answers

I can't start an activity from a broadcast receiver

I have a broadcast receiver from which, when it receives an intent, I would like to start/resume an activity. Up to point to start the activity everything works fine, I get the intent etc. But I cannot start my activity. Here is my android manifest:…
giorgos.nl
  • 2,704
  • 27
  • 36