Problem when coming back to activity after changing font in Galaxy S

by Suresh Pal » Fri, 20 May 2011 13:05:31 GMT


Sponsored Links
 i All,
I am going through a strange behaviour. I have Two activities in my
application - ActivityOne and ActivityTwo. Both are very simple
activities and have only basic lifecycle methods overrridden.

Steps to reproduce this are as follows:
1. I am launching ActivityTwo by clicking on a button on ActivityOne.
For this I am using startActivityForResult() method.
2. Now when I am on ActivityTwo, I long press home key and go to
Settings > Display > Font Style. and change fonts.
3. Now I go back to ActivityTwo by pressing back button.
4. On ActivityTwo I press again back key.

Ideally while pressing back on ActivityTwo, It should call
AcitivityOne's onActivityResult() method.
But Here I saw, that first iActivityOne's onDestroy(), then onCreate()
and then onActivityResult() is called.
Because onCreate() is getting called it again launches ActivityTwo and
hence it feels to user that ActivityTwo is coming twice while pressing
back and user has to press back button twice for going to
ActivityOne.

This is a very strange behavoiur.

On digging more i found out that when font are getting changed, they
are restarting all packages. Hence all the activities are getting
created(instantiated) again. Because of this the first instance of
ActivityOne is getting killed and a new instance is getting created.
Because of this onCreate method is called and it again launches
ActivityTwo.

Here my problem is that, I can not make my activities singleinstance
or singletask. This is a requirement.

I also found that the same situation occurs in many of the pre-
installed applications or any of the newly created method.

My questions are:
1. Is there any config attribute for font changes? I tried to find out
in android docs and in google also but no luck yet.
2. If there is no config attribute, then please tell me the ways to
handle this situation. Its very weired situation for the user

ActivityOne Code is

public class ActivityOne extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button = (Button) findViewById(R.id.btn_launch);
button.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
Log.d("ActivityOne", "<SURESH>
setOnClickListener()");
Intent intent = new Intent();
intent.setComponent(new
ComponentName("com.demo.backpress",
"com.demo.backpress.ActivityTwo"));
startActivityForResult(intent, 1);
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if(resultCode == RESULT_CANCELED) {
Toast.makeText(this, "First activity cancelled",
Toast.LENGTH_LONG);
}
Log.d("ActivityOne", "<SURESH> onActivityResult() resultCode
==> " +
resultCode + " -:- requestCode ==> " + requestCode + " -:- data ==> "
+ data);
}
}

ActivityTwo Code is :

public cl



Re: Problem when coming back to activity after changing font in Galaxy S

by Simon Jackson » Fri, 20 May 2011 13:15:40 GMT


 how about to singleton something

static Activity me;

oncreate() 
if(me==null)
me = this
<docreate>
else
me.<focus>
finish();

or such

Cheers Jacko

-- 


Sponsored Links


Re: Re: Problem when coming back to activity after changing font in Galaxy S

by Suresh Chandra Pal » Fri, 20 May 2011 15:45:34 GMT


 Hi Simon,
You suggested to make activity singleton.
But is 'making activity' singleton not equal to single instance.
At a time I'll be having a single instance. and I dont want to do that.
Moreover mainly, I want a way which is acceptable according to android
concepts.
and if that is not possible then only I will have to do some trick.
But in any case I dont want my activity to be singleinstance or singletask.

That's why I want something android specific.

If I got you wrong then please explain your solution.









-- 

Best Wishes,



Suresh Pal



*Skype:               *suresh.pal

*Gtalk:*                sapient.suresh

*Facebook:*
 http://www.facebook.com/people/Suresh-Chandra-Pal/676583036 

*LinkedIn: *          http://www.linkedin.com/in/sapientsuresh 

*Blogs:  *               http://www.sapientsuresh.blogspot.com 

*Twitter: *             http://twitter.com/sapientsuresh 

*Google Profile:  * http://www.google.com/profiles/sapient.suresh 

-- 



Re: Re: Problem when coming back to activity after changing font in Galaxy S

by Suresh Chandra Pal » Fri, 20 May 2011 17:13:36 GMT


 Sorry for the wrong code, but the ActivityOne do not have a button, but is
starting ActivityTwo immediately in its onCreate() method. and this code is
creating problem.


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Log.d("ActivityOne", "<SURESH> setOnClickListener()");
 Intent intent = new Intent();
intent.setComponent(new ComponentName("com.demo.backpress",
"com.demo.backpress.ActivityTwo"));
 startActivityForResult(intent, 1);
    }



On Fri, May 20, 2011 at 1:14 PM, Suresh Chandra Pal <






-- 

Best Wishes,



Suresh Pal



*Skype:               *suresh.pal

*Gtalk:*                sapient.suresh

*Facebook:*
 http://www.facebook.com/people/Suresh-Chandra-Pal/676583036 

*LinkedIn: *          http://www.linkedin.com/in/sapientsuresh 

*Blogs:  *               http://www.sapientsuresh.blogspot.com 

*Twitter: *             http://twitter.com/sapientsuresh 

*Google Profile:  * http://www.google.com/profiles/sapient.suresh 

-- 



Other Threads

1. How To install Hero Rom/Fw to Magic

REMEMBER DO IT ON YOUR OWN RISK

Pertama kita perlu ubah SPL Magic kita..
Caranya..
1. Download 3 file dibawah ini
SDK http://developer.android.com/sdk/1.5_r3/index.html
ROM Singapura 
http://www.freewebtown.com/blipblap/RUU_Sapphire_HTC_Asia_WWE_2.16.707.3_SG_release_signed_NoDriver.exe
ROM Indonesia 
http://www.freewebtown.com/blipblap/RUU_Sapphire_HTC_Asia_WWE_2.53.707.2_SEA_test_signed_NoDriver.exe

2. Pastiin Komp sdh terinstall HTC Sync
3. Turn phone on and connect to computer with USB cable.
3. Jalan kan ROM Indonesia, biarkan proses sampai selesai.
4. Phone will reboot.
3. Jalan kan ROM Singapura, biarkan proses sampai selesai

diposisi ini Magic masih terinstall ROM Magic tapi dgn ROM singapura yg 
didalamnya terdapat Google service, seperti Gmaps, Gmail dll..

dan Magic pun sudah terinstall SPL yg Non Perfect, sehingga bisa di 
Root/Jailbreak (Magic Indonesia SPL 1.33.0010, Magic Singapura 1.33.0009)

Dalam posisi ini pun jika Magic langsung dipakai hanya saja belum ter 
Root/Jilbreak..

Next Step, Rooting/Jailbreaking and installing Hero Rom

Caranya..
1. Download file recovery 
http://rapidshare.com/files/262635369/recovery-RAv1.2.0H.img copy/pindahkan 
file ini ke direktori android sdk/tools (di saya 
F:\android-sdk-windows-1.5_r2\tools)
2. Download Rom Hero 
http://thephishing.net/RogersRoms/Fatal1ty_Hero-Full_v1.4-ROGERS-signed.zip 
rename file ini jadi update.zip, copy ke sdCard Magic (pastikan jgn dicopy 
kedalam folder sdCard!)
3. Run cmd, masuk ke directory android sdk\tools (contoh 
F:\android-sdk-windows-1.5_r2\tools)
4. di Magic, masuk ke setting-Applications-Development, pastiing USB Debugging 
tercentang..
5. Matikan Magic
6. Tekan tombol back dibarengi tombol power, Magic akan masuk Fasboot Mode
7. Colokan Magic ke USB, pastikan Komputer mendeteksi Magic
8. di cmd, ketik fastboot boot recovery-RAv1.2.0H.img (jika ada error artinya 
driver USB android belom terinstall dgn baik)
9. Magic akan reboot sendiri dan masuk ke AmonRa Recovery..
10. Gunakan trackball, pilih Nandroid BackUp, biarkan jalan sendiri kalo sdh 
selesei akan ada pemberitahuannya
11. Setelah Nandroid Backup selesai, Pilih Reboot, biarkan Magic Hidup, copy 
file Nandroid di sdCard ke komputer (biar aman), then matikan Magic dan masuk 
ke Fasboot Mode (lihat step 6)
12. di cmd, ketik fastboot boot recovery-RAv1.2.0H.img (Magic akan masuk lagi 
ke AmonRa Recovery)
13. kali ini pilih Wipe (menghapus data), setelah proses wipe selesai
14. Gunakan Trackball pilih Apply update.zip
disini proses flashing Hero rom dimulai, biarkan sampai selesei..

Done..

..
--~--~---------~--~----~------------~-------~--~----~

2. Android + Google Apps

Hi all. I've been looking to post for a while but haven't exactly
found the right place to post. Since this is the "watercooler" of
Android, I thought I'd post here.

Now, first and foremost, my experiences with Android have been
positive. Although slow starting, Android is slowly coming into its
own and I think people are starting to realise that. However, it
hasn't been without its problems.

I'm talking about Google Apps (for domains). This is such a grey area
for the G1, surprisingly, and this is where most of my problems lie.
I'll start with the experiences I've had.

1. When first using the phone you are asked to sign into your Google
Account. "Fine", I tell myself. I'll use my Google Apps account. This
works, flawlessly. I'm ecstatic. I login and my contacts, calendar and
email are synced. Straight away. Amazing.

2. Let's check out the Market. Hang on, my Google Account isn't
supported. I've just logged in with my Google apps account and that's
fine but the Market refuses. After a few tries I end up going to my
computer and creating a Gmail account, specifically for the Market.
Fine, this is just for apps. Consider it a security feature,
protecting your apps. Brilliant, I'm buying and downloading apps to my
hearts content. 5 flashlights, 4 soundboards, 3 weather apps, 2 social
networking apps and 1 video player later and I'm happy.

I've been Youtube for a while now and had an old youtube account. I
was given the option to link the account with a Google account so I
used my Google Apps address. Doesn't work. Interesting.

I've kind of figured out by now that a Google apps account != Google
account. So I go off, create an actual google account with my Google
apps email address. That's fine. Created. Done. I have access to
webmaster tools, analytics etc.

I go back to Youtube and link the accounts. All done. My favourites
can be access by logging in with my Google Apps email address.
Huzzah.

3. Time to checkout Youtube on the phone. It's all fine. I'm browsing,
I'm watching, I'm laughing. However, my favourites have disappeared.
Hmm. Not sure what's happening here. I press My Account and I'm
greeted with a login box again. "Some applications can't be access
with your x...@xxx.xxx account". I'm confused. I've created an actual
Google account with my hosted email, no different than using a hotmail
address, but it's not being accepted despite having the same
credentials. Okay, just login again. Not accepted. Okay, I'll use my
Youtube account. Not accepted. I get frustrated and exit the app.

Suddenly, a notification appears. Apparently there is now a Sign-in/
Sync error. "Your password isn't valid". There is no username box,
instead there is my Market email account. It's waiting for a password.
At this point I'm really confused, I haven't tried anything with my
Market account. I haven't changed the password, so why should it have
changed? I enter the password, it disappears. I assume this is for my
Youtube app. I re-enter the app and go to My Account. Once again, it
asks for a login.

Basically, I now can't use the account that I normally use to login to
the web based youtube. All my favourites, subscriptions, friends are
gone. I have to create a brand new account, which is highly annoying.

I've now given up. Some parts of the phone sync (admittedly, the
important parts). However, to this day, I'm still confused.

Why does Android accept a Google Apps account for some function but
not for others? Surely they all go through the same login procedure by
now. I've actually though about dumping Google Apps jsut so I can have
a fully integrated experience with my phone. Then again, I could just
go and get an iPhone. I don't want to, I have faith in Android for the
future, but at the moment it annoys the {*filter*}out of me.

Is this likely to be resolved in future? Or do I have to accept the
fact that Google account != Google apps account even though I have
used my Google apps account to CREATE a Google account.

I think this is more of a rant then a question but, to try and neatly
round it all up, what's going on?

Steve

--~--~---------~--~----~------------~-------~--~----~

3. Activity timeout on WebView load

4. Timer not available

5. ScrollView not resizing when a a child ListView is populated

6. Android plugin download externally

7. Question on Seekbar - clipping of thumb