IMEI no. for a mobile

854 views.

How to find IMEI no. of a mobile programatically ?

Add Comment
1 Answer(s)
437 views.

Activity_main.xml

<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" >
 <TextView
 android:id="@+id/textView2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerInParent="true"
 android:textSize="15sp"
 />
</RelativeLayout>

MainActivity.Java

package com.example.imei;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class MainActivity extends Activity {
 TelephonyManager tel;
 TextView imei;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
 imei = (TextView) findViewById(R.id.textView2);
 imei.setText(tel.getDeviceId().toString());
 }
}

Add Phone state permission in manifest

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Answered on July 5, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.