Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:28:56+00:00 2026-05-27T12:28:56+00:00

I am writing code to get the mac address of any Android device having

  • 0

I am writing code to get the mac address of any Android device having versions greater than 2.3. In general, I wrote the following code in HiActivity.java :

package com.hi.address;

import java.net.InetAddress;
import java.net.NetworkInterface;

import android.app.Activity;
import android.os.Bundle;

public class HiActivity extends Activity 
{
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
                
    }
    public void Display()
    {
        try {
    InetAddress addresses = InetAddress.getByName(InetAddress.getLocalHost().getHostName());

       NetworkInterface ni= NetworkInterface.getByInetAddress(addresses);

       byte[] mac = ni.getHardwareAddress();
       System.out.println("====="+mac); 
       for(int i=0; i< mac.length; i++) 
       {
                 
           System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
                 
        }
                
      }catch(Exception e){
                 System.out.println("exception was occureddddddddd"+e);
                
            }
        
    }
    public void onStart(Bundle savedInstanceState) {
        System.out.println(" 999999999999999999999999");
        Display();
    }
  }

Instead of giving any output in debugging mode in Eclipse
its giving the following in LogCat

07-07 23:13:52.340: INFO/installd(228): move /data/dalvik-cache/data@app@com.hi.address-1.apk@classes.dex -> /data/dalvik-cache/data@app@com.hi.address-1.apk@classes.dex
07-07 23:13:52.340: DEBUG/PackageManager(284): New package installed in /data/app/com.hi.address-1.apk
07-07 23:13:52.470: WARN/PackageManager(284): Unable to load service info ResolveInfo{41789898 com.smlds.smlStartService p=0 o=0 m=0x108000}
07-07 23:13:52.470: WARN/PackageManager(284): org.xmlpull.v1.XmlPullParserException: No android.accounts.AccountAuthenticator meta-data
07-07 23:13:52.470: WARN/PackageManager(284):     at android.content.pm.RegisteredServicesCache.parseServiceInfo(RegisteredServicesCache.java:377)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.content.pm.RegisteredServicesCache.generateServicesMap(RegisteredServicesCache.java:261)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.content.pm.RegisteredServicesCache$1.onReceive(RegisteredServicesCache.java:110)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:716)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.os.Handler.handleCallback(Handler.java:587)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-07 23:13:52.470: WARN/PackageManager(284):     at android.os.Looper.loop(Looper.java:132)
07-07 23:13:52.470: WARN/PackageManager(284):     at com.android.server.ServerThread.run(SystemServer.java:682)
07-07 23:13:52.490: DEBUG/PackageManager(284): generateServicesMap(android.accounts.AccountAuthenticator): 8 services unchanged
07-07 23:13:52.500: DEBUG/AccountTypeManager(422): Registering external account type=com.sec.android.app.snsaccountlinkedin.account_type, packageName=com.sec.android.app.snsaccountli
07-07 23:13:52.510: DEBUG/PackageManager(284): generateServicesMap(android.content.SyncAdapter): 18 services unchanged
07-07 23:13:52.510: INFO/ApplicationPolicy(284): registerPackageChangeReceiver() onReceive: Broadcast Received for PKG:com.hi.address
07-07 23:13:52.520: INFO/DmAppInfo(284): getApplicationsList found row counts : 0 For Pkg : com.hi.address
07-07 23:13:52.520: DEBUG/szipinf(284): Initializing inflate state
07-07 23:13:52.520: DEBUG/GTalkService(399): [GTalkService.1] handlePackageInstalled: re-initialize providers
07-07 23:13:52.530: DEBUG/GTalkService(399): [RawStanzaProvidersMgr] ##### searchProvidersFromIntent
07-07 23:13:52.530: DEBUG/AccountTypeManager(422): Registering external account type=com.sec.android.app.snsaccountfacebook.account_type, packageName=com.sec.android.app.snsaccountfb
07-07 23:13:52.550: DEBUG/AccountTypeManager(422): Registering external account type=com.smlds.accountType, packageName=com.smlds
07-07 23:13:52.560: INFO/AccountTypeManager(422): Loaded meta-data for 6 account types, 2 accounts in 9ms
07-07 23:13:52.650: DEBUG/dalvikvm(422): GC_CONCURRENT freed 526K, 9% free 6904K/7559K, paused 2ms+3ms
07-07 23:13:52.690: DEBUG/dalvikvm(284): GC_EXPLICIT freed 1645K, 52% free 18542K/38151K, paused 7ms+10ms
07-07 23:13:52.700: DEBUG/AndroidRuntime(5253): Shutting down VM
07-07 23:13:52.700: INFO/AndroidRuntime(5253): NOTE: attach of thread 'Binder Thread #3' failed
07-07 23:13:52.710: DEBUG/dalvikvm(5253): GC_CONCURRENT freed 102K, 87% free 344K/2560K, paused 0ms+1ms
07-07 23:13:52.710: DEBUG/jdwp(5253): Got wake-up signal, bailing out of select
07-07 23:13:52.710: DEBUG/dalvikvm(5253): Debugger has detached; object registry had 1 entries
07-07 23:13:52.840: DEBUG/dalvikvm(362): GC_FOR_ALLOC freed 8092K, 43% free 13640K/23815K, paused 37ms
07-07 23:13:52.930: DEBUG/AndroidRuntime(5269): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-07 23:13:52.930: DEBUG/AndroidRuntime(5269): CheckJNI is OFF
07-07 23:13:52.930: DEBUG/AndroidRuntime(5269): Set to default setting_5 : language=-Duser.language=en propLang=en
07-07 23:13:52.930: ERROR/AndroidRuntime(5269): Set to default setting_6 : region=-Duser.region=US propRegn=US
07-07 23:13:52.940: DEBUG/AndroidRuntime(5269): setted country_code = UK &amp; IRE
07-07 23:13:52.940: DEBUG/AndroidRuntime(5269): setted sales_code = XEU
07-07 23:13:52.940: DEBUG/AndroidRuntime(5269): found sales_code tag = <XEU>, </XEU> 
07-07 23:13:52.950: DEBUG/dalvikvm(362): GC_FOR_ALLOC freed 4042K, 53% free 11324K/23815K, paused 33ms
07-07 23:13:53.050: DEBUG/LibQmg_native(5269): register_android_app_LibQmg
07-07 23:13:53.080: DEBUG/AndroidRuntime(5269): Calling main entry com.android.commands.am.Am
07-07 23:13:53.090: INFO/ActivityManager(284): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.hi.address/.HiActivity } from pid 5269
07-07 23:13:53.100: INFO/SurfaceFlinger(223): id=160(35) createSurface 0xa05bc for pid 284 (1x1),2 flag=0, Starting com.hi.address
07-07 23:13:53.100: DEBUG/WindowManager(284): addWindowToListInOrder() : current mSkipWidgetFocus='true'
07-07 23:13:53.110: DEBUG/AndroidRuntime(5269): Shutting down VM
07-07 23:13:53.120: INFO/AndroidRuntime(5269): NOTE: attach of thread 'Binder Thread #3' failed
07-07 23:13:53.120: DEBUG/dalvikvm(5269): GC_CONCURRENT freed 103K, 86% free 374K/2560K, paused 0ms+1ms
07-07 23:13:53.130: DEBUG/dalvikvm(362): GC_CONCURRENT freed 1169K, 51% free 11766K/23815K, paused 3ms+11ms
07-07 23:13:53.140: DEBUG/jdwp(5269): Got wake-up signal, bailing out of select
07-07 23:13:53.140: DEBUG/dalvikvm(5269): Debugger has detached; object registry had 1 entries
07-07 23:13:53.260: DEBUG/dalvikvm(362): GC_CONCURRENT freed 1359K, 50% free 12140K/23815K, paused 2ms+3ms
07-07 23:13:53.350: DEBUG/dalvikvm(362): GC_FOR_ALLOC freed 1308K, 49% free 12273K/23815K, paused 29ms
07-07 23:13:53.480: DEBUG/dalvikvm(362): GC_CONCURRENT freed 1354K, 47% free 12839K/23815K, paused 2ms+3ms
07-07 23:13:53.610: WARN/ActivityManager(284): Activity pause timeout for ActivityRecord{409bfaf0 com.android.launcher/com.android.launcher2.Launcher}
07-07 23:13:53.620: DEBUG/dalvikvm(362): GC_FOR_ALLOC freed 1603K, 45% free 13116K/23815K, paused 32ms
07-07 23:13:53.620: INFO/ActivityManager(284): Start proc com.hi.address for activity com.hi.address/.HiActivity: pid=5278 uid=10116 gids={}
07-07 23:13:53.700: INFO/System.out(5278): *********************************************************
07-07 23:13:53.700: DEBUG/WindowManager(284): addWindowToListInOrder() : current mSkipWidgetFocus='true'
07-07 23:13:53.710: VERBOSE/TLINE(5278): new: android.text.TextLine@4070ce08
07-07 23:13:53.710: INFO/SurfaceFlinger(223): id=161(1) createSurface 0x7f6dc for pid 5278 (1x1),2 flag=0, com.hi.address/com.hi.address.HiActivity
07-07 23:13:53.750: INFO/WindowManager(284): Putting input method here!
07-07 23:13:53.750: DEBUG/WindowManager(284):     w.mAttrs.token=ActivityRecord{4173b240 com.hi.address/.HiActivity}
07-07 23:13:53.750: DEBUG/WindowManager(284):     w.mToken=AppWindowToken{426016a0 token=ActivityRecord{4173b240 com.hi.address/.HiActivity}}
07-07 23:13:53.750: DEBUG/WindowManager(284):     token=AppWindowToken{426016a0 token=ActivityRecord{4173b240 com.hi.address/.HiActivity}}
07-07 23:13:53.750: INFO/WindowManager(284): Placing input method @3
07-07 23:13:53.750: DEBUG/CLIPBOARD(284): Hide Clipboard dialog inside hideSoftInput() !
07-07 23:13:53.750: INFO/InputManagerService(284): [imme] in windowGainedFocus()j, viewHasFocus is false OR is TextEditor is false, now call hideCurrentInputLocked(InputMethodManager.HIDE_NOT_ALWAYS,null)
07-07 23:13:53.790: DEBUG/dalvikvm(362): GC_CONCURRENT freed 1501K, 43% free 13660K/23815K, paused 3ms+5ms
07-07 23:13:53.840: DEBUG/CLIPBOARD(5278): Hide Clipboard dialog at Starting input: finished by someone else... !
07-07 23:13:53.870: WARN/SocialHubWidget(1064): [SocialHubWidgetProvider] onReceive() >>  
07-07 23:13:53.870: WARN/SocialHubWidget(1064): [SocialHubWidgetProvider] action >> action : sec.android.intent.action.HOME_PAUSE
07-07 23:13:53.870: WARN/SocialHubWidget(1064): [SocialHubWidgetProvider] action >> checkNetwork(context) : false
07-07 23:13:53.890: ERROR/com.samsung.app(1072): [MSC]>>> WeatherWidgetProvider.java:322 [0:0] onReceive()@@@ sec.android.intent.action.HOME_PAUSE
07-07 23:13:53.890: ERROR/com.samsung.app(1072): [MSC]>>> WidgetIdManager.java:39 [0:0] AccuWeatherClockWidgetID_Length
07-07 23:13:53.890: ERROR/com.samsung.app(1072): [MSC]>>> WidgetIdManager.java:40 [0:0] getPrefIDs() : length = 0
07-07 23:13:53.890: ERROR/com.samsung.app(1072): [MSC]>>> WeatherWidgetProvider.java:1554 [0:0] disable handler
07-07 23:13:53.900: ERROR/(1080): onReceive sec.android.intent.action.HOME_PAUSE
07-07 23:13:53.900: DEBUG/ProgramMonitor(4443): START onReceive()_intent : Intent { act=sec.android.intent.action.HOME_PAUSE flg=0x10 cmp=com.sec.android.widgetapp.programmonitorwidget/.ProgramMonitorProvider }
07-07 23:13:53.900: DEBUG/CLIPBOARD(362): Hide Clipboard dialog at Starting input: finished by someone else... !
07-07 23:13:53.910: INFO/PhotoAppWidgetProvider(1101): Gallery PhotoWidget PauseSlideShow 
07-07 23:13:53.910: INFO/ActivityManager(284): Displayed com.hi.address/.HiActivity: +300ms
07-07 23:13:53.920: INFO/SurfaceFlinger(223): id=157 Removed com.android.launcher/com.android.launcher2.Launcher idx=1 Map Size=4
07-07 23:13:53.920: WARN/Surface(362): Not initializing the shared buffer client because mSurface=0x0 stats=0

Where is the error in my code? I am tried to debug but was no able to find my error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:28:57+00:00Added an answer on May 27, 2026 at 12:28 pm

    Use android.telephony.TelephonyManager.getDeviceId() to get uniquely identifier of the device (IMEI on GSM, MEID for CDMA).

    Also set READ_PHONE_STATE permissionin manifest

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mono won't fire the following code: I get internal server error 500, error writing
I'm writing C++ code on a mac. Why do I get this error when
I am writing some code in which i need to get a line from
I have a dev, that will get around our code coverage by writing tests
I'm writing python program to build mac-address cache using pcap. But pcap module for
instead of writing code in the standard way: $.get('test.xml',function(){ //manipulate the code here })
I'm writing PowerShell code to get all the local IPv4 addresses, excluding the loopback
I am writing c code to get get the QR decomposition for a matrix
When writing code do you consciously program defensively to ensure high program quality and
After writing code to populate textboxes from an object, such as: txtFirstName.Text = customer.FirstName;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.