By user1780370


2015-09-16 10:08:04 8 Comments

I am new in Android. I am developing a simple application where I need to send push notification from server side.

So, need to send data using call api when app install. For that, I have to get device information like device name, version, unique key (token) etc.

I tried but not get how to? any one have a idea please share with me.

6 comments

@Android Team 2015-09-16 10:14:11

Hi please see below method hope you will get most of detail which you want

public static String getDeviceInfo(String p_seperator) throws Throwable
{
    String m_data = "";
    StringBuilder m_builder = new StringBuilder();
    m_builder.append("RELEASE " + android.os.Build.VERSION.RELEASE + p_seperator);
    m_builder.append("DEVICE " + android.os.Build.DEVICE + p_seperator);
    m_builder.append("MODEL " + android.os.Build.MODEL + p_seperator);
    m_builder.append("PRODUCT " + android.os.Build.PRODUCT + p_seperator);
    m_builder.append("BRAND " + android.os.Build.BRAND + p_seperator);
    m_builder.append("DISPLAY " + android.os.Build.DISPLAY + p_seperator);
    // TODO : android.os.Build.CPU_ABI is deprecated
    m_builder.append("CPU_ABI " + android.os.Build.CPU_ABI + p_seperator);
    // TODO : android.os.Build.CPU_ABI2 is deprecated
    m_builder.append("CPU_ABI2 " + android.os.Build.CPU_ABI2 + p_seperator);
    m_builder.append("UNKNOWN " + android.os.Build.UNKNOWN + p_seperator);
    m_builder.append("HARDWARE " + android.os.Build.HARDWARE + p_seperator);
    m_builder.append("ID " + android.os.Build.ID + p_seperator);
    m_builder.append("MANUFACTURER " + android.os.Build.MANUFACTURER + p_seperator);
    m_builder.append("SERIAL " + android.os.Build.SERIAL + p_seperator);
    m_builder.append("USER " + android.os.Build.USER + p_seperator);
    m_builder.append("HOST " + android.os.Build.HOST + p_seperator);
    m_data = m_builder.toString();
    return m_data;
}

below method is for getting device ID

public static String getDeviceID(Context p_context) throws Throwable
{
    String m_deviceID = null;
    TelephonyManager m_telephonyManager = null;
    m_telephonyManager = (TelephonyManager) p_context
            .getSystemService(Context.TELEPHONY_SERVICE);

    m_deviceID = m_telephonyManager.getDeviceId().toString();

    if (m_deviceID == null || "00000000000000".equalsIgnoreCase(m_deviceID))
    {
        m_deviceID = "AAAAAAA";
    }

    return m_deviceID;
}

@user1780370 2015-09-17 05:52:38

What use for send push notification? how to get register id?

@Gunhan 2015-11-03 11:28:36

The answers here are all unrelated to the OP question.

To get register id for push notifications.

GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String regid = gcm.register("YOUR_PROJECT_ID");

You can get your project id from https://console.developers.google.com/project

You should read more detailed information at https://developers.google.com/cloud-messaging/gcm

@Akbar 2015-09-16 10:12:58

Log.i("ManuFacturer :", Build.MANUFACTURER);
Log.i("Board : ", Build.BOARD);
Log.i("Display : ", Build.DISPLAY);

For More information Please visit: http://developer.android.com/reference/android/os/Build.html

Regarding Push Notifications, you should follow these steps.

  1. Create/Register App on Google Cloud
  2. Setup Cloud SDK with Development
  3. Configure project for GCM
  4. Get Device Registration ID
  5. Send Push Notifications
  6. Receive Push Notifications

For detail of each step please visit here : http://rdcworld-android.blogspot.in/2013/11/android-push-notification-google-cloud.html

@user1780370 2015-09-17 05:52:43

What use for send push notification? how to get register id?

@Akbar 2015-09-17 05:55:15

you can use Build.ID, here you go and follow its step rdcworld-android.blogspot.in/2013/11/…

@Himanshu Shekher Jha 2015-09-16 10:20:58

Use these lines of code .. it will return you android_device_id , and name. You can get many other thing by replacing the last KeyWord ANDROID_ID ....

String android_id = Settings.Secure.getString(getApplicationContext().getContentResolver(),
                Settings.Secure.ANDROID_ID);

        String android_name= Settings.Secure.getString(getApplicationContext().getContentResolver(),
                Settings.Secure.NAME);

@user1780370 2015-09-17 05:53:10

What use for send push notification? how to get register id?

@Burhanuddin Rashid 2015-09-16 10:15:32

Try this links:

http://developer.android.com/reference/android/os/Build.html and http://developer.android.com/reference/java/lang/System.html (try getProperty() )

For Example :

System.getProperty("os.version"); // OS version
android.os.Build.VERSION.SDK      // API Level
android.os.Build.DEVICE           // Device
android.os.Build.MODEL            // Model 
android.os.Build.PRODUCT          // Product

Etc...

@user1780370 2015-09-17 05:52:47

What use for send push notification? how to get register id?

@user2413972 2015-09-16 10:14:01

Token

import android.provider.Settings.Secure;

private String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID); 

or

TelephonyManager tManager = (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE);
String uid = tManager.getDeviceId();

Android version

android.os.Build.VERSION

Device name

android.os.Build.MODEL;

@user1780370 2015-09-17 05:53:15

What use for send push notification? how to get register id?

@user2413972 2015-09-17 05:56:02

Related Questions

Sponsored Content

94 Answered Questions

[SOLVED] Close/hide the Android Soft Keyboard

25 Answered Questions

[SOLVED] Is there a way to run Python on Android?

43 Answered Questions

[SOLVED] Is there a unique Android device ID?

27 Answered Questions

77 Answered Questions

28 Answered Questions

[SOLVED] What is 'Context' on Android?

26 Answered Questions

11 Answered Questions

[SOLVED] Proper use cases for Android UserManager.isUserAGoat()?

17 Answered Questions

[SOLVED] "Debug certificate expired" error in Eclipse Android plugins

16 Answered Questions

[SOLVED] Does Android support near real time push notification?

Sponsored Content