From acfc5155f03cf32209ccbc9860c017cb1f88fa37 Mon Sep 17 00:00:00 2001 From: gumartinm Date: Tue, 24 Apr 2012 09:08:08 +0200 Subject: [PATCH] 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? --- Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); } } -- 2.1.4