I have an activity which creates a unique ID and then passes the String to a service, the problem I am having is that the app force-closes every time I try passing the data from the activity to the service.
Normally when I am programming java applications I just use getter and setter methods to pass data between classes, so does anyone have an idea why this problem is occurring?
public void setId(String mydeviceId){
TelephonyManager tm = (TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
final String DeviceId, SerialNum, androidId;
DeviceId = tm.getDeviceId();
SerialNum = tm.getSimSerialNumber();
androidId = Secure.getString(getContentResolver(),Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long)DeviceId.hashCode() << 32) | SerialNum.hashCode());
mydeviceId = deviceUuid.toString();
this.mydeviceId = mydeviceId;
}
public String getId(){
return mydeviceId;
}
Pass between classes means activities? If so, you need to use Intent bundle. Get/set wont work between activities. Here is an example how to pass data between activities.