views:

76

answers:

2

I'm developing on Android. I have to restart home and all its components (widgets, shortcuts, etc..). For example, when we have a Force Close, the home screen restart and reload all its components.

+2  A: 

I have to restart home and all its components (widgets, shortcuts, etc..).

No, you don't.

For example, when we have a Force Close, the home screen restart and reload all its components.

If you have a "Force Close", you cannot execute code. Hence, what you want is impossible.

CommonsWare
My problem is that some widgets doesn't refresh its state.Only method to do this is restart home.
Cecco
@Cecco: You are welcome to update your app widgets whenever you want via an `AppWidgetManager`. You do not need to attack the user by trying to kill the HOME screen.
CommonsWare
@Cecco: Listen to CW. In your widget, you can set android:updatePeriodMillis to tell it how often to update. Note that with, I believe Android 1.6, the minimum update time is 1800 (or 30 minutes).
kcoppock
You don't even need to wait that long. You can update your app widget *anytime*. Just fill in the `RemoteViews` and pass it to an `AppWidgetManager` you get from `getInstance()`.
CommonsWare
A: 

You should be able to relaunch it ACTION_MAIN and CATEGORY_HOME intent. If you've just killed the app then this should restart it.

locka
I want to restart my Home not my app. How I can do this?
Cecco