intent in android code example

Example 1: intent android open activity

Intent intent = new Intent(this, DisplayMessageActivity.class);
        intent.putExtra(key:,value:);
        startActivity(intent);

Example 2: intent android

Intent intent = new Intent(MainActivity.this,Activity.class);

Example 3: intent in fragment android

Button button = (Button) rootView.findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(getActivity(), AnotherActivity.class);
        startActivity(intent);
    }
});

Example 4: android studio intent usage

Intent i = new Intent(MainActivity.this, ActivityTwo.class);
startActivity(i);

Example 5: intent android

Intent intent = new Intent(MainActivity.this,MainActivity2.class);
 intent.putExtra("key",value);
 startActivity(intent);
////////////////////
 String string =getIntent().getStringExtra("key");

Example 6: intent class for url and phone and others

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.vogella.com/"));
startActivity(i);