Android :: Changing Locale - Force Activity To Reload Resources

Apr 15, 2010

I have a language setting in my application. When the language is switched, I would like all the textviews etc to change language immediately. Currently I just change the locale in the configuration, so the language has changed when the user restarts the activity.

Solution to my problem would be to make each textview load the new resources each time the language is changed. Is there a better solution? Perhaps a neat way to discretely restart the activity? Or maybe just force reload of the resources?

Android :: Changing locale - Force activity to reload resources


Android : Force An Activity To Reload Completely?

Jul 19, 2009

I have an application, where I need to change the language through a settings menu. Now this part works perfectly, but it doesn't change the language for activities that have gone through onCreate.

I got a TabHost, and 2 tabs in it, from the tabs you can get to settings.

Refreshing the TabHost isn't an issue, as it's fairly small, however both the 2 tabs are quite large views, and having a function to manually update all the strings seem unnecessarily difficult. Is there any way to force the activity to recreate itself and trigger a new onCreate?

I tried having a static function in the tabhost that clears all tabs and recreates them, this refreshes the tab titles, but not the content in the tabs.

View 5 Replies View Related

Android :: Can I Obtain Resources With A Given Locale

Jul 28, 2009

I have different text packaged into my app for different locale. The Resource.getString(int resid) method automatically returns me the string for the CURRENT locale of the phone. Is there a way I can specifically obtain resources while passing in a locale? For example, there isn't such method as: Resource.getString(int resId, Locale myLocale);

View 3 Replies View Related

Android :: Changing Locale Within The App Itself

Feb 15, 2010

My users can change the Locale within the app (they may want to keep their phone settings in English but read the content of my app in French, Dutch or any other language ...)

Why is this working perfectly fine in 1.5/1.6 but NOT in 2.0 anymore?

CODE:..........

The problem is that the MENU "shrinks" more and more everytime the user is going through the lines of code above ...

This is the Menu that gets shrunk:

CODE:.........

What should I do in API Level 5 to make this work again ?

HERE IS THE FULL CODE IF YOU WANT TO TEST THIS :

CODE:..............

AND HERE IS THE MANIFEST :

CODE:..........

THIS IS WHAT I FOUND :

<uses-sdk android:minSdkVersion="5" />

=> IT WORKS JUST FINE ...

<uses-sdk android:minSdkVersion="3" />

=> Menu shrinks every time you change the locale!

As I want to keep my application accessible for users on 1.5.

View 3 Replies View Related

Android :: Changing Locale Programmatically (2.1 Update 1) Does Not Work?

Sep 10, 2010

I am trying to change the locale programmatically on Android. The code I have below works fine on the Incredible(2.2) and Droid(2.2). However, it doesn't on the DroidX(2.1 Update 1) Anyone here have encountered similar problem ?? Any insight would be helpful.

public void overrideLocale(String languageToLoad) {
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);
Intent intent = new Intent(this, ActivityB.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); }

View 1 Replies View Related

Android :: Reload Activity Data

May 23, 2010

I am writing an Android app, part of which will be a survey involving multiple pages of checkbox question and answers. I have created an activity to display the question and options (from the DB) and what I want to do now is when i press the "Next" button it should just reload the current activity with the next question set from the database. (the activity starts with survey.getNextQuestion() - so its just a case of refreshing the activity so it updates)

View 2 Replies View Related

Android : Can I Reload Activity In Droid?

Jun 16, 2010

Is it a good practice to reload an activity in Android?

What would be the best way to do it? this.finish and then this.startActivity with the activity intent?

View 5 Replies View Related

Android :: Localization Support Without Changing Locale / Language Of Device?

Jul 28, 2010

I created a set of text resources in different languages:

res/values-de/strings.xml
res/values-fr/strings.xml
res/values-ja/strings.xml

when a user runs our application, the Android system selects which resources to load, based on the device's locale.

So basically I want to add language option in my application and save user language preference, then load text resources based on user preference.

Is there any way to do this?

View 2 Replies View Related

Android :: Reload An Activity That Exists Within A TabView?

Aug 2, 2010

I have a Tabview with 3 tabs (each having their own activity). I have a tab that parses a RSS feed. How can I refresh this feed via a menu button? I tried doing the following but I lose the tabs above of course.

CODE:.................

View 2 Replies View Related

Android :: Periodically Refresh / Reload Activity

Sep 13, 2010

I have one activity. OnCreate the activity gets the source (html) of a web page to a string and presents the result (after parsing it a bit) in a textview. I would like the activity to reload/refresh periodically to always present the latest information.

View 1 Replies View Related

Android :: Adding / Changing Resources On Run Time

Aug 19, 2009

i was wondering if there is any way to load resource (such as skins etc.) that include drawables and layout information during runtime. what i mean is that the user can download a file (probably a signed apk - would it work any other way?) and would be able to install it adding to an already existing application thus adding more resources to it.

View 5 Replies View Related

Android :: How To Force Eclipse To Recreate Resources File?

Sep 7, 2010

I just had the odd case that my Android project for some reason would not properly rebuild in Eclipse (v3.5/Galileo). Occasionally that happen and so I did the usual Project => Clean... as I always do in such cases. But this time I now have the odd effect that almost all files show bugs, and looking closer it's that the compiler can't find the R-file (which is indeed missing from the gen subtree). How do I force eclipse to rebuild that file?

View 1 Replies View Related

Android :: After Update Force Close For System Resources Not Found

Sep 2, 2010

I don't know why. Install the package directly won't have any problem. But will fail because of Force Close if update the old package. the log is:
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class java.lang.reflect.Constructor
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.createView(LayoutInflater.java:512)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:318)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.app.Activity.setContentView(Activity.java:1631)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.yidongsoft.ultraNoteEnhancedRegister.StartUI.setupWidgets(StartUI.java:237)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.yidongsoft.ultraNoteEnhancedRegister.StartUI.initialize(StartUI.java:129)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.yidongsoft.ultraNoteEnhancedRegister.StartUI.checkPassword(StartUI.java:591)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at com.yidongsoft.ultraNoteEnhancedRegister.StartUI.onCreate(StartUI.java:112)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1132)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): ... 11 more
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): Caused by: java.lang.reflect.InvocationTargetException
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.widget.ExpandableListView.<init>(ExpandableListView.java:198)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at java.lang.reflect.Constructor.constructNative(Native Method)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): ... 25 more
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-480x320/list_selector_background.xml from drawable resource ID #0x7f020005
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.Resources.loadDrawable(Resources.java:1625)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.widget.ListView.<init>(ListView.java:160)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.widget.ExpandableListView.<init>(ExpandableListView.java:202)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): ... 29 more
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-480x320/list_selector_background.xml from xml type drawable resource ID #0x7f020005
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1843)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.Resources.loadDrawable(Resources.java:1620)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): ... 32 more
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): Caused by: java.io.FileNotFoundException: res/drawable-480x320/list_selector_background.xml
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:471)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1825)
09-02 18:19:20.922: ERROR/AndroidRuntime(1659): ... 33 more
The file not found seems android embedded resources. Can any one explain why? I am using HTC Magic, official rom 1.5

View 1 Replies View Related

Android :: Changing The Android Emulator Locale Automatically

Mar 10, 2010

For automated testing (using Hudson) I have a script that generates a bunch of emulators for many combinations of Android OS version, screen resolution, screen density and language.
This works fine, except for the language part.

I need to find a way to change the Android system locale automatically.

Here's some approaches I can think of, in order of preference:

Extracting/editing/repacking a QEMU image directly before starting the emulator
Running some sort of system-locale-changing APK on the emulator after startup
Changing the locale settings on the emulator filesystem after startup
Changing the locale settings in some SQLite DB on the emulator after startup
Running a key sequence (via the emulator's telnet interface) that would open the settings app and change the locale

Manually starting the emulator for each platform version, changing the locale by hand in the settings, saving it and archiving the images for later deployment

Any ideas whether this can be done, either via the above methods or otherwise?

Do you know where locale settings are persisted to/read from by the system?

I have updated his answer below with the details.

View 2 Replies View Related

Android :: Getting Resources Outside Of An Activity

Mar 31, 2009

I currently have a few classes that are called by an activity (some statically) in which I want to use a string resource. I tried: Resources.getSystem().getString(R.string.mystring), but am getting an error. It seems as though you can only use this within an activity.

Is there anyway to use a project resource in a standard (non Activity) class without having to pass the resource object from the activity calling the class?

View 3 Replies View Related

Android :: Force Activity In Landscape Mode Without Activity Restart

Aug 21, 2009

I have a problem to start/create Activity in landscape mode. My Activity need to start in landscape mode and be used in landscape mode by users. So far, I used setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) to force screen orientation of my Activity to landscape mode in onCreate() method.

In addition to this screen mode requirement, my application need to start another background thread in onResume() method, and this thread takes some seconds in order to finish an initialization process, and it is not desirable to to stop/restart this thread's service during the initialization process.

However setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) forces my Activity restart in a very little while (means onCreate->onResume->onPause->onStop are executed twice at the first place). As a result, my background thread be stopped/restarted during the initialization process, and this makes me a mess at this moment.

View 3 Replies View Related

Android :: Current Activity Force Closes - Tries To Go To Previous Activity

Nov 5, 2010

The default behavior from my observation is if current activity force closes Android tries to go to previous activity on stack How can I control this behavior? I want force close to close all activities

View 2 Replies View Related

Android : Save / Activity With MapView And After Reload Same Mapview?

Jul 16, 2010

I had found a lot of stackoverflow post about save an Activity and the reload it.

My question: How can I have an Activity with an MapView and after reload the same mapview?

What is the best way to switch between activity and views?

View 2 Replies View Related

Android :: Changing Activity - Without Closing The Second And Third Activity?

Jul 20, 2010

I am in my fourth activity and I want to come back to the first activity directly (without closing the second and third activity). How to change to the activity directly?

View 1 Replies View Related

Android :: Changing Background Color Of An Activity

Jan 31, 2010

When i launch Activity A, the screen goes black, then dark-gray. Then A launches B, and the screen goes black and dark-gray again. Is there a way to set the default background color to black? Activity A has no screen, its just a stub that calls B.

View 4 Replies View Related

Android :: Changing Content Of Activity Run Time

Jul 24, 2010

I created an activity by using a layout written in a XML file. I would like, in response to some events, to change the content of this activity. I would like to show a VideoView over the content. In response to some other event, I may want to go back to the first content. Would it be possible to switch the content of the activity this way without running another activity (I have another technical difficult in doing that)? I tried using setContentView( videoView), and then switching back with setContentView(T.layout.main), but it seems that, when going back to the main layout, all my buttons and text boxes are created again as they were new. Would it be possible to go back to the last state of all the controls?

View 4 Replies View Related

Android :: Changing Orientation Resets Activity

Jul 7, 2009

I finally got to the point where I was ready to deploy my app to my G1 and test it out and the first thing I noticed was that when I change my phone to landscape view my main activity restarts and resets all of my variables to their default settings. How can I avoid this?

View 7 Replies View Related

Android :: Force Tab Activity Creation

Jun 3, 2010

I have an Android application with a main activity that is the tabhost. I'm adding multiple tabs to the tabhost with an intent to several activities.

My problem is that these activities are not created (onCreate is not called) until I click on the tab. This is a problem because I need to register broadcastreceivers: there may be broadcasts that are sent -before- a particular tab is opened.

I tried to work around this by:

Setting my receivers as static and registering from somewhere else. This is not possible because I need to call into methods.

Calling into tabHost.setCurrentTabByTag(the_tag) and then switching back to my root tab. This only works sometimes and this is a very ugly solution imo.

Not using activities but just using views instead. Also not a very elegant solution because it turns my tabHost activity into one huge master class doing all kinds of unrelated things.

View 1 Replies View Related

Android :: Simple Example Of Changing Screen Brightness For An Activity?

May 30, 2010

There are apparently at least three different techniques for changing screen brightness in the Android OS. Two of them no longer work post-cupcake and the third accepted technique evidently has a bug. I would like to increase screen brightness at the start of a one-view activity then turn the brightness back to the user setting at the end of the activity. No buttons, no second view or second activity. Just a maxed brightness at start and a return to original brightness setting at the end of the activity. The examples of the current technique using WindowManager.LayoutParams that I have located range from 2 lines of code

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);

To several pages of source code and numerous activities. Is there a simple example of maxing the screen brightness at start that someone can provide a link to?

View 1 Replies View Related

Android :: Changing Launch Activity Seems To Not Work On Update

Apr 26, 2010

For a new update I am changing the start-up work flow for the application. Part of this is setting the "android.intent.category.LAUNCHER" from one activity to another in my manifest. When I run an update from what is on the market to what I download from my website the application starts in the Activity where it used to start before the update. When I un install the application and install it from the same package I got from my website it starts in the Activity where I have now specified it to start. Shorter version: Update fails to update launching activity, un install- reinstall does update the launching activity. Is this a known issue? Do I really need to add logic to correct for people who update the app instead of installing fresh? Asking people to un install for an update is not a viable option. Is there something I can do to clean out whatever is getting saved that is causing the app to launch with the incorrect Activity? You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To un subscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en.

View 4 Replies View Related

Android :: ListView In Activity Getting Refreshed On Changing Orientation

Apr 7, 2010

I have Activity with ListView inside it and in the onCreate method of the Activity I have code for populating the Data of the ListView this Data is a server based and so populating includes calling Network URLs. I have the ArrayAdapter of the ListView in the Same Activity Class.

Now the Issue I'am facing is that, in Rest all scenarios my Activity is behaving in a proper way but when the Orientation [ Portrait to Landscaped or other way round] is taking place the Data is Getting lost and Newer Data calls are Required to Populate the Same Old Data now this is something that is not intended out the code how should I deal with it.

View 4 Replies View Related

Android :: Force Activity To Call Finalize

May 20, 2010

My application contains 2 activities A and B. B is opened with startActivity(intent) in A, when B is closed with finish(), I found the method finalize() of B is not called.

My question is: How to force Activity to call finalize() when it is closed with finish()?

View 5 Replies View Related

Android :: Force An Update In A Configuration Activity

Sep 29, 2010

I'm writing a widget with a configuration activity which calls the following method when its OK button is clicked:

CODE:..............

This is almost verbatim from the documentation. widget_id holds the widget ID that was dug up during the activity's onCreate().

When I place an instance of the widget on the home screen, I've verified that I get the expected sequence of events:

onReceive() gets an ACTION_APPWIDGET_ENABLED if it's the first one.
onUpdate() gets called (in which I detect that the widget isn't configured and draw something as a default action).
The configuration activity appears.
When I press OK, the ok() method above gets called.

The method gets all the way through to the finish() and the configuration activity goes away, but there's no call to onUpdate() or onReceive() after this point. (The widget itself has no updatePeriodMillis.) I end up with a widget on the screen that has the results of my default action but never gets updated.

If I set the widget up without a configuration activity, it gets updated when created and everything works as expected (just without the configured bits).

View 1 Replies View Related

Android :: Force Application To Restart On First Activity

Mar 18, 2010

For an unknown reason, I can't get my application leaving properly so that when I push the home button and the app icon again I resume where I was in the app....But I would like to force the application to restart at the first activity...I suppose this has something to do with onDestroy() or maybe onPause() but I don't know what to do..

View 4 Replies View Related

Android : Force Activity To Run Other In Landscape Droid 1.5

Aug 6, 2010

I have an application which is in portrait mode. However, I want to run a particular activity in landscape mode. I have tried the following with no success.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved