sometime you have multiple SIM cards and you don't know which one Number you are using.Then you may be want to "Get Own Mobile Number" ?
How I am going to write a small android application which will solve our puzzle.
So here we go.. we need to create a Basic Android App having an Activity like this
GetMyPhoneNoActivity.java
Then we need to add user permission into manifest file
AndroidManifest.xml
How I am going to write a small android application which will solve our puzzle.
So here we go.. we need to create a Basic Android App having an Activity like this
GetMyPhoneNoActivity.java
package com.kns; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.TelephonyManager; import android.util.Log; import android.widget.Toast; public class GetMyPhoneNoActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String number =getMyPhoneNO(); Toast.makeText(getApplicationContext(), "My Phone No is: " +number, Toast.LENGTH_SHORT).show(); Log.v("Debug", number); } private String getMyPhoneNO(){ TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager) getSystemService (Context.TELEPHONY_SERVICE); String yourNumber = mTelephonyMgr.getLine1Number(); return yourNumber; } }
Then we need to add user permission into manifest file
so it will be look like this..
AndroidManifest.xml
Now if will check this code on Emulator device, The output will be..
Note: As i have read, so far some people have conflict about different behavior of output.
there are reports that some SIMs cause this method to return
null.
Because --? I think there are cases where the phone does not know its own number - it somehow depends on the network provider / SIM card.
So, There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported).
I'd like to know your suggestions!!
Thanks!