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
2
votes
3 answers

Android three activities, pass data from third activity to parent activity

I have 3 activities. Let's say A, B, C. Main activity is A. I'd like to start B from A then start C from B, then close B when C opens. Finally upon closing of C pass data to A. How's this possible especially with Intent and startActivityForResult?…
user1319668
  • 329
  • 1
  • 4
  • 16
2
votes
0 answers

How to make a phone call without saving the number?

I'm using the following code to make a call in Android but I would like to hide the number being called, and not save it in the call log. Is it possible? String num="xxx-xxx-xxx"; String number = "tel:" + num.trim(); Intent callIntent = new…
2
votes
0 answers

Startactivityforresult() and Don't keep Activity option in phone settings

I have came across a weird experience and so far i couldn't find a solution for this and hope someone here can help me..The Issue is, I have 2 activities(say Activity A and Activity B) and i started Activity B from Activty A using…
Sam
  • 4,046
  • 8
  • 31
  • 47
2
votes
1 answer

How to tell which third-party app called startActivity into my app

Suppose there are two apps on my device, GoodApp and EvilApp. I didn't write either of them. Both apps can use an ACTION_SEND Intent to start an exported activity in my app, passing data in. They both call startActivity, not…
2
votes
2 answers

Back and volume buttons not working when app is resumed in certain conditions

I'm starting a new activity to display a leaderboard in my Android App. When the leaderboard activity is displayed, and the user presses the home key and then resumes the app (so the leaderboard activity comes up again), and then navigates back to…
2
votes
1 answer

Cannot find symbol method startActivity(android.content.Intent)

I am a beginner in making android applications. I have made a web view which shows my web page. My web page consists contact buttons that i want to be opened in external apps like mail and dial. Therefore i got some help and got a code like this…
Stumpp
  • 279
  • 4
  • 7
  • 16
2
votes
1 answer

how to use on activity result for going through more then one activity in android

I have made a form in that I have a textView field called"CategoryID",now when the user click on it it will go to a categoryListActivity,In that activity a List with categories are them ,In that List some of categories having subcategories and some…
2
votes
0 answers

finishActivity (int requestCode) not working

I start an activity using the following code for a given result: startActivityForResult( new Intent( getActivity(), StudentDetails.class ).putExtra( GeneralFunctions.EXTRA_STUDENT_ID, (String)…
Stephen Lynx
  • 1,077
  • 2
  • 14
  • 29
2
votes
1 answer

how do you limit intent chooser to show only specific apps?

Objective: I want to open an intent chooser to show only the native Camera app and the native Gallery app. What I have right now: I have the native Camera app, native Gallery app and all other apps that can open files(Astros File Manager, Photos…
xiaowoo
  • 2,248
  • 7
  • 34
  • 45
2
votes
2 answers

java.lang.SecurityException: intent has extas while passing to other activity

I receive error in S4 but not in any other device please help me to figure out error My Logcat 12-16 17:44:14.296: E/InputEventReceiver(18735): Exception dispatching input event. 12-16 17:44:14.296: E/MessageQueue-JNI(18735): Exception in…
Passion
  • 662
  • 1
  • 11
  • 29
2
votes
1 answer

Passing ArrayList of objects between activity using Parcelable class

I have two activity (A and B). Activity A launches Activity B using startActivityForResult. From Activity B, for coming back in the Activity A I used the following code: ArrayList selectedArticlesList =null; ... Intent data = new…
GVillani82
  • 17,196
  • 30
  • 105
  • 172
2
votes
3 answers

Intent values not being passed back to starting activity

I am new to Android development and am using the Android Studio after a short sting with AppInventor. I have read up on starting an activity and getting the result back as well as examining the examples. On my MainActivity I have a Login button…
2
votes
2 answers

Resume activity after startActivity(Intent)

I'm implementing a code that verifies if there is an internet connection. If not, it starts the settings of the WiFi so the user can choose an Internet Connection. The problem is that i want that when the user choose the connection and click back…
Manuel Pires
  • 637
  • 3
  • 19
2
votes
0 answers

My activity closes down when i cancel or accept bluetooth enable request?

There is no error in the logcat just the current activity closes down and previous activity opens. Here is the code where am puttin bluetooth enabling request: bt.setOnClickListener(new OnClickListener() { @Override public…
DoYou EvenLift
  • 319
  • 3
  • 7
  • 16
2
votes
2 answers

Launch an SL4A script from an SL4A script

I would like to start a background SL4A script (on a remote device) from within a different SL4A script. I can launch a script from a terminal by running something like this: $ am start -a…
Jeff Darcy
  • 69
  • 8