Skip to content

Instantly share code, notes, and snippets.

@hellosagar
Created April 26, 2019 10:45
Show Gist options
  • Save hellosagar/ff1bf30e2d89c75eef3bbb8dfa8c1bd1 to your computer and use it in GitHub Desktop.
Save hellosagar/ff1bf30e2d89c75eef3bbb8dfa8c1bd1 to your computer and use it in GitHub Desktop.
main activity
package com.wotinstitutes.greetings;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)findViewById(R.id.button2);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
int b=sum(20,80);
intent.putExtra("a",b);
startActivity(intent);
}
});
}
public int sum(int x,int y){
int a=x;
int b=y;
int z=a+b;
return z;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment