

User interface is created declaratively in XML or programmatically inĬode. Android provides a sophisticatedįramework for dealing with rotation within applications, whether the Overviewīecause mobile devices are easily rotated, built-in rotation is a It covers how to work with the Android resource system to automatically load resources for a particular device orientation as well as how to programmatically handle orientation changes. In the following code we are creating a new Intent and passing parameters on clicking button.This topic describes how to handle device orientation changes in Xamarin.Android. Now open your FirstScreenActivity.java and Type the following code. This layout contains simple form with a button.ĥ. Now insert the following code in screen1.xml to design a small layout. Right Click on Layout -> New -> Android XML file and name it as screen1.xmlĤ. Create a new xml file in layout folder or rename the main.xml to screen1.xml Now you need to create user interface for the FirstScreenActivity.javaģ. While creating a new project give activity name as FirstScreenActivity.Ģ. Create a new project File -> Android Project.

Now lets start by creating a simple project.ġ. The following diagram will give you an idea about the file structure you will be need in this tutorial. In this tutorial i created two xml layouts( screen1.xml, screen2.xml) and two Acvities( FirstScreenActivity.java, SecondScreenActivity.java). So now we have all the code snippets related to activities. To run our application you should enter your new activity in AndroidManifest.xml file. Setting resultCode to 100 to identify on old activity Sending param key as 'website' and value as '' Sending result back to old activity when StartActivityForResult() is used String mywebsite = data.getExtras().get("result") get("website") 'website' is the key value result data Storing result in a variable called myvar Super.onActivityResult(requestCode, resultCode, data) Function to read the result from newly created void onActivityResult(int requestCode,

StartActivityForResult(i, 100) // 100 is some code to identify the returning result And once new activity is closed you should you use onActivityResult() method to read the returned result. In that situations startActivityForResult() method is useful. In some situations you might expect some data back from newly created activity.

Opening new Activity and expecting result String myemail = i.getStringExtra("email") and storing the value in a variable named myemail Example of receiving parameter having key value as 'email' To receive parameters on newly created activity getStringExtra() method will be used. Example of sending email to next screen as To send parameter to newly created activity putExtra() methos will be used. Intent i = new Intent(getApplicationContext(), SecondScreen.class) To open new activity following startActivity() or startActivityForResult() method will be used.
