0

I have an application that uses the MAC address to register. As everyone knows as of android 6.0 you can no longer use the old method to do this. My problem is it doesn't appear to be a straight forward get MAC address. Hoping someone can help suggest a way to get this working on android 6.0+

my code is as follows;

public void getMacAddress()
{
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo wInfo = wifiManager.getConnectionInfo();
    String macAddress = wInfo.getMacAddress();
    Log.e("address", "mac address:" + macAddress);
    pref = getSharedPreferences(Constant.PREF_APPDATA, MODE_PRIVATE);
    edit=pref.edit();

    if(macAddress!=null)
        edit.putString(Constant.P_DEVICEID, macAddress);
//  else
//      Toast.makeText(this," WiFi MAC address not found.", Toast.LENGTH_SHORT).show();

    TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    if( tm.getDeviceId()== null)
    {
        //edit.putBoolean(Constant.P_IS_TABLET, true);
        //Toast.makeText(Activity_Audio.this, "Tablet", Toast.LENGTH_SHORT).show();
    }
    else
    {
        //Toast.makeText(Activity_Audio.this, "Not Tablet", Toast.LENGTH_SHORT).show();
    }

    edit.commit();
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ess Aiche
  • 1
  • 1

0 Answers0