From: gumartinm Date: Tue, 24 Apr 2012 07:08:08 +0000 (+0200) Subject: Android MobiAds: using the cookie in a nasty way. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=acfc5155f03cf32209ccbc9860c017cb1f88fa37;p=JavaForFun Android MobiAds: using the cookie in a nasty way. I have to improve it. Should I use a singleton in order to share the cookie between activities in the same java process? --- diff --git a/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java b/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java index 8cdab96..ab56d67 100644 --- a/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java +++ b/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java @@ -23,14 +23,16 @@ public class MobiAdsMainActivity extends Activity { */ final Messenger mMessenger = new Messenger(new IncomingHandler()); - private String cookie; + private static String cookie; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Bundle bundle = getIntent().getExtras(); - this.cookie = bundle.getString("cookie"); + if (MobiAdsMainActivity.cookie == null) { + MobiAdsMainActivity.cookie = bundle.getString("cookie"); + } super.onCreate(savedInstanceState); setContentView(R.layout.mobiadsmain); } @@ -118,7 +120,7 @@ public class MobiAdsMainActivity extends Activity { public void onClickStartService(View v) { Intent intent = new Intent(MobiAdsMainActivity.this, MobiAdsService.class); - intent.putExtra("cookie", this.cookie); + intent.putExtra("cookie", MobiAdsMainActivity.cookie); this.startService(intent); } }