I have a static value in my activity and activity start a service. In service, I retrieve the static data. Then If I destroy the activity from system, the static value return with null in service. I mean;
public class HomeActivity extends Activity {
static String user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
user="abc";
Intent serviceint=new Intent(this, PointCheck.class);
startService(serviceint);
}
}
In PointCheck.class,
public class PointCheck extends Service {
String username;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
username=HomeActivity.user;
return super.onStartCommand(intent, flags, startId);
}
So if I destroy HomeActivity logcat says: "java.lang.IllegalArgumentException: value may not be null."
Full log:
11-11 16:26:11.971: E/AndroidRuntime(22329): FATAL EXCEPTION: main
11-11 16:26:11.971: E/AndroidRuntime(22329): Process: com.hello, PID: 22329
11-11 16:26:11.971: E/AndroidRuntime(22329): java.lang.IllegalArgumentException: value may not be null.
11-11 16:26:11.971: E/AndroidRuntime(22329): at com.hello.PointCheck$MyLocationListener.onLocationChanged(PointCheck.java:68)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:279)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:208)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:224)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.os.Handler.dispatchMessage(Handler.java:102)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.os.Looper.loop(Looper.java:157)
11-11 16:26:11.971: E/AndroidRuntime(22329): at android.app.ActivityThread.main(ActivityThread.java:5872)
11-11 16:26:11.971: E/AndroidRuntime(22329): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 16:26:11.971: E/AndroidRuntime(22329): at java.lang.reflect.Method.invoke(Method.java:515)
11-11 16:26:11.971: E/AndroidRuntime(22329): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
11-11 16:26:11.971: E/AndroidRuntime(22329): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
11-11 16:26:11.971: E/AndroidRuntime(22329): at dalvik.system.NativeStart.main(Native Method)
What do you thing ? Thanks