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

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)

Related

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);

Android Explicit Intent code [duplicate]

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);

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.

Open android app programmatically

I would like to open another app when clicking a button in my app. How can I achieve that?
Intent intent = new Intent("com.test.test");
You don't start "applications" in Android, but "activities". If the activity is not in your process, you need the full class name - just as you did in your demo code.
You need to know the exact activity name in order to open it.

Which function does intent have? [duplicate]

This question already has answers here:
What is an Intent in Android?
(14 answers)
Closed 8 years ago.
I dont know much about intent (or android) so.. Can someone please explain me what is it exactly? i have search on the internet, A LOT.
Also what does each line of this code do?
Intent intent = new Intent (this, DisplayMessageActivity.class);
intent.putExtra("a", "b");
Thanks in advance
I suggest reading Android Intents
You couldn't have search for very long, since this is very basic topic.
I suggest you read more of Android's API guides.
Line 1 = Create message that describes what to do, in this case start "DisplayMessagActivity"
Line 2 = Add content to the message
Intent intent = new Intent (this, DisplayMessageActivity.class);
For this line, its function is to create a navigation from the current activity/page to the displaymessageactivity page.
it is like from here to there.
For this intent.putExtra("a", "b"); the purpose of this is to put like a temp storage/variable to pass to the next page for retrieval. In this case, you put the value "b" in the variable "a". With this method, you can use the value on the other activity or page.
All the above are just storing of info, it is not executed yet. if you want to execute the intent do the following
startActivity(intent);
The best example to state the behavior of Intent is it behaves like a POSTMAN that delivers message to the stated address.
Whether it may be calling service ,BroadCastRecivers ,Activity they are used in number of occassion.
Intents are asynchronous messages which allow application components
to request functionality from other Android components. Intents allow
you to interact with components from the same applications as well as
with components contributed by other applications. For example, an
activity can start an external activity for taking a picture.
Intents are objects of the android.content.Intent type. Your code can
send them to the Android system defining the components you are
targeting. For example, via the startActivity() method you can define
that the intent should be used to start an activity.
An intent can contain data via a Bundle. This data can be used by the
receiving component.
Intents can be used to start Service, call Activty, call Sub Activity, transfer the data between Activity or retrieve the data from Activity

Categories

Resources