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

unable to startActivity master-detail from another activity

I've an activity WelcomeActivity.java in which theres a button bContinue. In the OnClick method of the button, I tried this.. startActivity(new Intent(this, MenuItemDetailActivity.class)); //startActivity(new…
iaL
  • 376
  • 9
  • 18
-1
votes
1 answer

Intent to recall activity error

I made a layout xml for the settings of my app. I had a preference and I would like clicking on this will be sent to another activity. In the file of settings.java I put the following code to invoke the other activity but I get an error. This is the…
-1
votes
1 answer

ANR while trying to load Activity after FragmentDialogDismiss

I have an activity that sends a BC and waits 5 seconds for the response using AlarmManager. Once i get the broadcast i: 1. remove the FragmentDialog using mDialog.dismiss(); 2. start a new activity using getActivity().startActivity(myIntent); I'm…
codeScriber
  • 4,582
  • 7
  • 38
  • 62
-1
votes
1 answer

Navigation between the screens in android

In my application consider i am having 2 screens screen A and screen B.In screen A i have 2 edit boxes and 1 spinner,When coming first time the screen will not show the 2 edit boxes.And if user selects any value from spinner it will go to screen…
prakash .k
  • 635
  • 2
  • 12
  • 24
-2
votes
3 answers

Kotlin RecyclerView start new activity

I would like to start a new activity from a RecyclerView with Kotlin. I am still exploring Kotlin and currently stuck on how to open a new activity from a RecyclerView. class HomeScreenRecyclerAdapter :…
-2
votes
2 answers

Nullpointerexception by changing activity

I want to change activity with startActivity(intent), but i got a NullpointerException. I try everything what I read in the web. My Code public void starteFehler(int fall){ Intent fehler = new Intent(this, Fehlermeldung.class); …
Taylan Kaya
  • 41
  • 1
  • 4
-2
votes
3 answers

Which is the better way of declaring intent and start activity?

I have seen some Intent declarations on Youtube, Stack Overflow and elsewhere, and I have found two types of Intent declarations. First type : Intent intent = new Intent(FirstActivity.this, SecondActivity.class); startActivity(intent); Second type…
cleanrun
  • 549
  • 6
  • 20
-2
votes
3 answers

Change start of screen animation

I want one of my activites to come from the bottom of the screen when it starts and when it finishes I want it to dissapear back to the bottom. Is it possible to do it? And if yes - any idea how? Thanks in advance.
Netanel
  • 477
  • 2
  • 11
-2
votes
2 answers

Starting a 3rd Activity setting up interfaces and listeners

So my MainActivity was able to start my second activity from a btn click fine. Now on my second activity, I have a drag and drop type game where what I want is one the correct image was dropped, I want it to start a 3rd Activity but I am getting a…
-2
votes
2 answers

How to store value into different activity

In my android application, there's an EditText for name in MainActivity and I want to send user's input into 2 different activity. How to do that ? It's my sample code in MainActivity : EditText Name = (EditText) findViewById(R.id.editText1); String…
-3
votes
3 answers

Start activity from a AdapterRecyclerView

I have a viewPager with some fragments (in a fragment I have a recyclerView ), recyclerView contains more items, so, I want to when I click a item on recyclerView,it trans to BBBBActivity. But I don't figure out. it errors thank you very much
-3
votes
7 answers

how to start new activity via gridview onitemclick?

i want to open new activity on itemclick listner in gridview.like this. Click position 1(india) ->open activity 1.Click position 2(brazil)->open activity 2.Click position 3(canada)->open activity 3. how to possible it? This is my code. …
I m Android
  • 85
  • 2
  • 9
-3
votes
4 answers

android StartActivity crash

i'm trying to go to my next activity , which is Nieuw_huis1 This is my code of the mainactivity where SetupNieuwHuis should redirect to the next page package com.jan.energyservice; import java.io.FileInputStream; import…
Yalz
  • 1
  • 1
-3
votes
1 answer

How to start an activity which is in Android?

I want to start auto reject list with intent. Like this code: Intent intent = new Intent("WHICH SHOULD I WRITE CODE IN HERE?"); startActivity(intent); How can I this?
-3
votes
4 answers

App crashes at startActivity(intent)

this app crashes when i push over botonRegistro. The intent is created but i think is saved as null and i don´t know why. This is the code: import com.example.pestanasholacampus.R; import android.os.Bundle; import android.view.View; import…
Asier
  • 461
  • 9
  • 19
1 2 3
31
32