Android Explicit Intent code [duplicate] - android

This question already has answers here:
Using Intent in an Android application to show another activity
(11 answers)
Closed 7 years ago.
How can I pass the control from one Activity to another using the explicit Intent?
I had an issue in androidManifest.xmnl as it marked the Mainactivity file As an error.

If you just want to navigate from one activity to another you can use explicit intent as :
Intent next = new Intent(YourCurrentActivity.this , NextActivity.class);
startActivity(next);

Related

How send data(extra) from a map activity To an other activity [duplicate]

This question already has answers here:
How do I pass data between Activities in Android application?
(53 answers)
Closed 4 years ago.
I am new to programming and i want to know how to send data (dual coordinates) from my map activity to another activity. I tried the conventional method but it only works when I send data from the activity to another activity and not from my fragmentmaps activity to another activity.
A map fragment is implemented in the activity only. So, normal activity intent will work here.
Intent intent = new Intent(YourMapActivity.this, NextActiity.class);
intent.putExtra("Latitude", latitude);
intent.putExtra("Longitude", longitude);
startActivity(intent);

opening Add new contact page in Android phone programatically [duplicate]

This question already has answers here:
Insert a new contact intent
(9 answers)
Closed 5 years ago.
I need to open "Add new contact" page in phone. I searched for relevant Android code. But i didn't get results. please somebody help me by posting the code for opening add new contact page in Android phone programatically(I just need to open alone).
For this you have to create one activity with all the parameters you want like name, phone number etc.
If you want to open this page only then you are done, but if want to open this activity from any other activity then declare this activity in android manifest inside application tag like below:
<activity android:name="MainActivity"></activity>
After this, create Intent in your class from where you want to open this activity like:
Intent intent = new Intent(Activity1.this, MainActivity.class)
startActivity(intent)

Moving from one activity to another activity in android studio [duplicate]

This question already has answers here:
How do I pass data between Activities in Android application?
(53 answers)
How to use putExtra() and getExtra() for string data
(18 answers)
Closed 5 years ago.
I'm writing an application in android studio IDE which shows the models,brands ,prices and etc of the cars and I want to move from one activity to another one.can I use putExtra?if yes i wonder if anyone would like to tell me how can i use it.
You can pass data between activities in easiest way like this.
In the first activity use out extra to send the data
Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("YOUR_DATA_KEY", data);
startActivity(intent);
Access that intent on next activity like this
String s = getIntent().getStringExtra("YOUR_DATA_KEY");
try this
Intent intent=new Intent(this,YourActivity.class);
intent.putExtra("key",value);
startActivity(intent);
Try the following
Intent intent =new Intent(FirstActivity.this,SecondeActivity.class);
StartActivity(intent);

how to add a button in the running activity [duplicate]

This question already has an answer here:
Which is the best way to add a button?
(1 answer)
Closed 7 years ago.
I am very new to android development and I am having problem displaying a new button to a activity which has already run. I am using this tutorial http://developer.android.com/training/basics/firstapp/starting-activity.html. Here they display Hello World in the new activity. I would like to add a button called "SKIP"! So that the user can go to a another new activity called Functions. How do I do that with the intent? My intent is already being used to display the string hello world! I am using android studio.
Appreciate any help thanks
To create a button you need to go to your main XML file, add a button. Then in your Activity create a onClick listener for the button.
When it comes to going to another activity you need to create a new Intent with
Intent intent = new Intent(this, Functions.class);
startActivity(intent)
You would call your new activity with the following snippet within the OnClickListener of your button:
Intent intent = new Intent(this, Functions.class);
startActivity(intent);
And define your Functions class in your AndroidManifest.xml file similar to what the originally defined Activity is defined as. But you should only have one launcher Activity.

how to start a new intent from a service class (android) [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to start an Activity from a Service?
apologies for my terminology in advance I am very new to android programming.
What i am trying to do:
i am trying to create an alarm clock application.
What i have so far:
so far i have a class that starts an alarm service after 5 seconds (this works fine). then when this service class starts i want it to start another class (called AlarmRinging) but this is where I come unstuck.
Any answers or avenues to check out would be greatly appreciated.
android.app.Service is descendant of android.app.Context so you can use startActivity directly. However since you start this outside any activity you need to set FLAG_ACTIVITY_NEW_TASK flag on the intent.
For example:
Intent i = new Intent();
i.setClass(this, MyActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
where this is your service.

Categories

Resources