Monday 31 October 2016

SharedPreferences

The SharedPreferences class gives a general system that permits you to spare and recover determined key-esteem sets of primitive information sorts. You can utilize SharedPreferences to spare any primitive information: booleans, coasts, ints, yearns, and strings. This information will continue crosswise over client sessions (regardless of the possibility that your application is executed).

There are two methods of SharedPreferences.

1) get SharedPreferences()
2)get Preferences()

 Example Code for  SharedPreferences.

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="vertical" 
 tools:context="com.kiranapp.MainActivity" 
 android:background="#be2f2f">

<EditText 
 android:layout_width="match_parent" 
 android:layout_height="wrap_content" 
 android:id="@+id/editText" 
 android:layout_marginTop="20dp" 
 android:background="#f3e8e8" 
 android:allowUndo="false" 
 android:hint="Name" />

<EditText 
 android:layout_width="match_parent" 
 android:layout_height="wrap_content" 
 android:id="@+id/editText2" 
 android:layout_marginTop="20dp" 
 android:layout_gravity="center_horizontal" 
 android:background="#e8dfdf" 
 android:hint="Location" />

<Button 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="Save" 
 android:layout_marginTop="20dp" 
 android:id="@+id/button" 
 android:layout_gravity="center_horizontal" />

<Button 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="Show" 
 android:layout_marginTop="20dp" 
 android:id="@+id/button2" 
 android:layout_gravity="center_horizontal" />
</LinearLayout>

showactivity.xml :-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="vertical" android:layout_width="match_parent" 
 android:layout_height="match_parent">

<TextView 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:textAppearance="?android:attr/textAppearanceLarge" 
 android:id="@+id/textView" 
 android:text="Large Text" 
 android:layout_gravity="center_horizontal" />

<TextView 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:textAppearance="?android:attr/textAppearanceLarge" 
 android:id="@+id/textView2" 
 android:text="Large Text" 
 android:layout_gravity="center_horizontal" />
</LinearLayout>
 
MainActivity.java :-

package com.kiranapp;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    Button savebtn,showbtn;
    EditText uname,uloc;

@Override 
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 savebtn=(Button)findViewById(R.id.button);
 uname=(EditText)findViewById(R.id.editText);
 uloc=(EditText)findViewById(R.id.editText2);
 showbtn=(Button)findViewById(R.id.button2);
 savebtn.setOnClickListener(new View.OnClickListener() {
@Override 
 public void onClick(View v) {
 String s1=uname.getText().toString();
 String s2=uloc.getText().toString();
 SharedPreferences sp=getSharedPreferences("myfile",MODE_PRIVATE);
 SharedPreferences.Editor e=sp.edit();
 e.putString("name",s1);
 e.putString("loc",s2);
 e.commit();
 Toast.makeText(MainActivity.this, "Saved", Toast.LENGTH_SHORT).show();
 }
 });
 showbtn.setOnClickListener(new View.OnClickListener() {
@Override 
 public void onClick(View v) {
 Intent in=new Intent(MainActivity.this,ShowActivity.class);
 startActivity(in);
 }
 });
}
}

ShowActivity.java :-

package com.kiranapp;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

/** * Created by Dell on 10/31/2016. */
 public class ShowActivity extends AppCompatActivity {

    TextView t1, t2;

@Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.showactivity);
 t1=(TextView)findViewById(R.id.textView);
 t2=(TextView)findViewById(R.id.textView2);
 SharedPreferences sp=getSharedPreferences("myfile",MODE_PRIVATE);
 String s1=sp.getString("name",null);
 String s2=sp.getString("loc",null);
 t1.setText(s1);
 t2.setText(s2);
 }
}
 

Output :-

























Android Storage

Android gives a few choices to you to spare determined application information. The arrangement you pick relies on upon your particular needs, for example, whether the information ought to be private to your application or open to different applications (and the client) and how much space your information requires.

There are five different types of android storage.

1) Shared Preferences :-

Store private primitive information in key-esteem sets.

2) Internal Storage :-

Store private information on the gadget memory.

3) External Storage :-

Store open information on the mutual outside capacity.

4) SQLite Databases :-

Store organized information in a private database.

5) Network Connection :-

Store information on the web with your own particular system server.

Android gives an approach to you to uncover even your private information to different applications — with a substance supplier. A substance supplier is a discretionary segment that uncovered read/compose access to your application information, subject to whatever limitations you need to force. For more data about utilizing content suppliers, Content Providers documentation.

BroadCast Receiver

 BroadCast Receiver is also called as "Communicate Collector". It is a component.

A communicate collector is an Android segment which permits to enlist and listen for gadget introduction changes like sms message received , telephone call received/pick/cut ,battery status changed, the Wi-Fi went ahead.

Android working framework and even different applications time to time communicate messages about things that are occurring like sms messsage recieved , telephone call recieved/pick/cut ,battery status changed, the Wi-Fi went ahead.

With the assistance of communicate recipient you will find Android working framework particular occasions and after that you can code your application for that occasion.

Example :-
                      Your Battery Getting low.
                      Your Phone has suddenly Turn off.
                      Your Battery 10% to 20% remaining.
                      Image Capture also broadcast receiver.

Syntax :-
                In android mainfest.xml,

                   <receiver android:name="MainActivity">  
                   <intent-filter>
                    <action android:name="com.kiranapp.BroadCast Receiver">
                    </action>
                    </intent-filter>  
                  </receiver>

          In MainActivity.java,

               public class MainActivity extends Broadcast Receiver
              {
                 public void onReceive(Context context, Intent intent)
                  {
                  }
              }
   
  Example Code for BroadCast Receiver  shownbelow.

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="vertical" 
 tools:context="com.kiranapp.MainActivity" 
 android:background="#a69090">
<TextView 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:textAppearance="?android:attr/textAppearanceLarge" 
 android:text="Battert status is : " 
 android:id="@+id/textView" 
 android:layout_gravity="center_horizontal" 
 android:background="#f3ecec" />
</LinearLayout>

MainActivity.java :-

package com.kiranapp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
 TextView t1;

@Override 
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 t1=(TextView)findViewById(R.id.textView);
 registerReceiver(new MyBro(),new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
 }
class MyBro extends BroadcastReceiver{
@Override 
 public void onReceive(Context context, Intent intent) {
 int bstatus=intent.getIntExtra("level",0);
 t1.setText("Battery Status is : "+bstatus);
 }
 }
}

Output :-

BroadCast Receiver
BroadCast Receiver Figure

Thursday 27 October 2016

Services

A Service is an application part that can perform long-running operations out of sight and does not give a UI.
 Another application segment can begin an administration and it will keep on running out of sight regardless of the possibility that the client changes to another application.
Also, a segment can tie to an administration to cooperate with it and even perform interprocess correspondence (IPC).
For instance, an administration may handle arrange exchanges, play music, perform document I/O, or collaborate with a substance supplier, all from the foundation.
It is subclass of ContextWrapperclass.

Example :-  Music player and Alarm.

Services of lifecycle,There are  types of service.

1) Start Service :-

 We can begin an administration from a movement or other application part by passing an Intent (determining the administration to begin) to startService().
The Android framework calls the administration's onStartCommand() technique and passes it the Intent. (You ought to never call onStartCommand() straightforwardly.)

     Syntax :-
                    Using Intent Class
                    Intent in=new Intent(Currentclass.this,TargetClass);
                    startService(in);

2) Stop Service :-

A began benefit must deal with its own particular lifecycle. That is, the framework does not stop or decimate the administration unless it must recuperate framework memory and the administration keeps on pursuing onStartCommand() returns.
 In this way, the administration must stop itself by calling stopSelf() or another part can stop it by calling stopService().

     Syntax :-
                     Using Intent Class
                     Intent in=new Intent(Currentclass.this,TargetClass);
                     stopService(in);

3) Bound Service :-

A bound administration is one that permits application parts to tie to it by calling bindService() keeping in mind the end goal to make a long-standing association (and by and large does not permit segments to begin it by calling startService()).
You ought to make a bound administration when you need to interface with the administration from exercises and different parts in your application or to uncover some of your application's usefulness to different applications, through interprocess correspondence (IPC).

Code For Service in Android :-

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="vertical" 
 tools:context="com.kiranapp.MainActivity">
 
<Button 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="Start Service" 
 android:id="@+id/button" 
 android:layout_marginTop="20dp" 
 android:layout_gravity="center_horizontal" />
 
<Button  
 android:layout_width="wrap_content"  
 android:layout_height="wrap_content"  
 android:text="Stop Service"  
 android:id="@+id/button"  
 android:layout_marginTop="20dp"  
 android:layout_gravity="center_horizontal" /> 
 
</LinearLayout>

MainActvity.java :-

package com.kiranapp;

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
 {
    Button startserbtn,stopserbtn;

@Override
    protected void onCreate(Bundle savedInstanceState)
   {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    startserbtn=(Button)findViewById(R.id.button_start);
    stopserbtn=(Button)findViewById(R.id.button_stop);
    startserbtn.setOnClickListener(new View.OnClickListener()
   {

@Override
    public void onClick(View v)
   {
    Intent in=new Intent(MainActivity.this,MyServices.class);
    startService(in);
    }
    });
   stopserbtn.setOnClickListener(new View.OnClickListener()
  {

@Override
    public void onClick(View v)
   {
    Intent in=new Intent(MainActivity.this,MyServices.class);
    stopService(in);
    }
    });
    }
}

Output :-

                     Run the app on emulator or on mobile phone  

Monday 24 October 2016

PopupMenu

A popup menu shows a rundown of things in a vertical rundown that is secured to the view that conjured the menu. It's useful for giving a flood of activities that identify with particular substance or to give choices to a second part of a summon. Activities in a popup menu ought not specifically influence the relating substance—that is the thing that relevant activities are for. Or maybe, the popup menu is for stretched out activities that identify with areas of substance in your action.

Example :-
               PopupMenu ppm = new PopupMenu(this,view);
               getMenuInflater().inflate(R.menu.main,ppm.getMenu());
                ppm.show();

Code for PopupMenu in android.

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="vertical" 
 tools:context="com.kiranapp.MainActivity">
<Button 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="Popup" 
 android:id="@+id/button" 
 android:layout_marginTop="20dp" 
 android:layout_gravity="center_horizontal" />
</LinearLayout>

popup_menu.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<menu 
 xmlns:android="http://schemas.android.com/apk/res/android">

<item 
 android:id="@+id/android" 
 android:title="Android"/>
<item 
 android:id="@+id/ios" 
 android:title="IOS"/>
<item 
 android:id="@+id/phonegap" 
 android:title="Phonegap"/>
<item 
 android:id="@+id/blackberry" 
 android:title="Blackberry"/>
</menu>

MainActivity.java :-

package com.kiranapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.PopupMenu;
import android.widget.Toast;
public class MainActivity extends Activity {
    Button popupbtn;

@Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 popupbtn = (Button) findViewById(R.id.button);
 popupbtn.setOnClickListener(new OnClickListener() {

@Override 
 public void onClick(View v) {

 PopupMenu popup = new PopupMenu(MainActivity.this, popupbtn);
 popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
 popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
 
 public boolean onMenuItemClick(MenuItem item) {
 Toast.makeText(MainActivity.this,"Click menu:" + item.getTitle(),
                                                  Toast.LENGTH_SHORT).show();
 return true;
                    }
 });
 popup.show();
 }
 });
 }
}

Output :-

PopupMenu 1
PopupMenu fig :1





















PopupMenu2
PopupMenu fig :2





















PopupMenu3
PopupMenu fig :3















































ContextMenu

A Context menu is a skimming menu that shows up when the client plays out a long-tap on a    
    component. It gives activities that influence the chose substance or setting outline.

   Example :-
                     @override
                        public boolean onContextItemSelected(MenuItem item)
                        {
                        AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
                        Switch (item.getItemId())
                       {
                        case R.id.contacts:
                        contacts(info.id);
                        return true;
                        case R.id.settings:
                        settings(info.id);
                        return true;
                        default:
                        return super.onContextItemSelected(item);
                        }

Code for ContextMenu in android below shown .

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  xmlns:tools="http://schemas.android.com/tools"  
  android:layout_width="match_parent" 
  android:layout_height="match_parent"  
  android:orientation="vertical"  
  tools:context="com.kiranapp.MainActivity">

<ListView
 android:layout_width="match_parent" 
 android:layout_height="wrap_content" 
 android:id="@+id/listView" 
 android:layout_marginTop="20dp" 
 android:layout_gravity="center_horizontal" />
</LinearLayout>

MainActivity.java :-

package com.kiranapp;

import android.os.Bundle;
import android.support.v7.app.Activity;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.view.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {
    ListView lv;
String Courses[]={"ANDROID","IOS","PHONEGAP","BLACKBERRY","WINDOWS","MICROSOFT"};

@Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 lv=(ListView)findViewById(R.id.listView);
 ArrayAdapter<String> adapter=new ArrayAdapter<String>
                           (this,android.R.layout.simple_list_item_1,Courses);
 lv.setAdapter(adapter);
 registerForContextMenu(lv);
 }

@Overridepublic void onCreateContextMenu(ContextMenu menu, View v, 
                                       ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select The movement");
menu.add(0,v.getId(),0,"view");
menu.add(0,v.getId(),0,"send sms");
}

@Override public boolean onContextItemSelected(MenuItem item)
 {
 if (item.getTitle()=="view")
 {
 Toast.makeText(getApplicationContext(),"view code",Toast.LENGTH_LONG).show();
 }
 else if (item.getTitle()=="send sms"){
Toast.makeText(getApplicationContext(),"sendingsmscode",Toast.LENGTH_LONG).show();
 }
 else {
 return false;
 }
 return true;
 }
}

Output :-

Select the Run option we will get the result of the context menu app and it will show the output on emulator or on mobile phone.






































 

Sunday 23 October 2016

OptionsMenu

The Options menu (or) choices menu is the essential gathering of menu things for a movement. It's the place you ought to place activities that globally affect the application, for example, "Look", "Form email," and "Settings."

    Example :-
                   @Override
                       public boolean onCreateOptionsMenu(Menu menu) {
                       MenuInflater inflater=getMenuInflater();
                       inflater.inflate(R.menu.kiran_menu,menu);
                       return true;
                       }

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout  
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:app="http://schemas.android.com/apk/res-auto" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:fitsSystemWindows="true" 
 tools:context="com.example.kiran.optiosmenus.MainActivity"
 
<android.support.design.widget.AppBarLayout 
 android:layout_width="match_parent" 
 android:layout_height="wrap_content
 android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar 
 android:id="@+id/toolbar" 
 android:layout_width="match_parent" 
 android:layout_height="?attr/actionBarSize" 
 android:background="?attr/colorPrimary" 
 app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton 
 android:id="@+id/fab" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:layout_gravity="bottom|end" 
 android:layout_margin="@dimen/fab_margin" 
 android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

activity_status.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:paddingBottom="@dimen/activity_vertical_margin" 
 android:paddingLeft="@dimen/activity_horizontal_margin" 
 android:paddingRight="@dimen/activity_horizontal_margin" 
 android:paddingTop="@dimen/activity_vertical_margin" 
 tools:context="com.example.kiran.optiosmenus.SatusActivity">

<TextView 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:textAppearance="?android:attr/textAppearanceLarge" 
 android:text="Welcome to Status" 
 android:id="@+id/textView2" 
 android:layout_alignParentTop="true"         
 android:layout_alignParentRight="true" 
 android:layout_alignParentEnd="true" 
 android:layout_marginTop="83dp" />
</RelativeLayout>

content_main.xml :-

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:app="http://schemas.android.com/apk/res-auto" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:paddingBottom="@dimen/activity_vertical_margin" 
 android:paddingLeft="@dimen/activity_horizontal_margin" 
 android:paddingRight="@dimen/activity_horizontal_margin" 
 android:paddingTop="@dimen/activity_vertical_margin" 
 app:layout_behavior="@string/appbar_scrolling_view_behavior" 
 tools:context="com.example.kiran.optiosmenus.MainActivity" 
 tools:showIn="@layout/activity_main">

<TextView 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:textAppearance="?android:attr/textAppearanceLarge" 
 android:text="Welcome to Options Menus" 
 android:id="@+id/textView" 
 android:layout_alignParentTop="true" 
 android:layout_centerHorizontal="true" 
 android:layout_marginTop="105dp" />
</RelativeLayout>

MainActivity.java :-

package com.example.kiran.optiosmenus;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override 
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
 setSupportActionBar(toolbar);
 FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
 fab.setOnClickListener(new View.OnClickListener() {
@Override 
 public void onClick(View view) {
 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                       .setAction("Action", null).show();
 }
 });
}

@Override 
 public boolean onCreateOptionsMenu(Menu menu) {
 getMenuInflater().inflate(R.menu.menu_main, menu);
 return super.onCreateOptionsMenu(menu);
 }

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
 switch (item.getItemId()) {
 case R.id.item1:
Toast.makeText(MainActivity.this, "Status is Selected"
                                                  Toast.LENGTH_SHORT).show();
 Intent in=new Intent(getApplicationContext(),SatusActivity.class);
 startActivity(in);
 break;
 case R.id.item2:
Toast.makeText(MainActivity.this, "Whatsapp Web is Selected"
                                                  Toast.LENGTH_SHORT).show();
 break;
 case R.id.item3:
Toast.makeText(MainActivity.this, "Wallpaper is Selected"
                                                   Toast.LENGTH_SHORT).show();
 break;
 case R.id.action_settings:
Toast.makeText(MainActivity.this, "Setting is Selected",
                                                    Toast.LENGTH_SHORT).show();
 break;
 }
 return super.onOptionsItemSelected(item);
 }
}

StatusActivity.java :-

package com.example.kiran.optiosmenus;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SatusActivity extends AppCompatActivity {

@Override 
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_satus);
 }
}

Output :-

OptionsMenu
OptionsMenu fig :1





















OptionsMenu
OptionsMenu fig :2





















OptionsMenu
OptionsMenu fig :3