Hi Asik
  I'm trying to find solutin for similar problem, how to restart an
application. Your slution is "little funny" but functional of course.
In my code, to force close app I use this

In my main activity I call
[code]
ActivityManager aM = (ActivityManager)
getApplicationContext().getSystemService(ACTIVITY_SERVICE);

// Setup one-short alarm to restart my application in 3 seconds - TODO
need use another context
AlarmManager alarmMgr = (AlarmManager)
getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(Const.SMARTMAPS_SCREEN_PATH);
PendingIntent pi = PendingIntent.getBroadcast(Main.this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
alarmMgr.set(AlarmManager.ELAPSED_REALTIME, System.currentTimeMillis()
+ 3000, pi);

aM.restartPackage(getPackageName());
finish();
[/code]

unfortunatelly AlarmManager do not work, and as I wrote as comment, I
think that is needed to use some Intent independent on application.
But any help will be appreciated- But rest of code (part with
activityManager) works and have for me same effect that your force
close (but without error message of course).

Hope this helps

On Mar 30, 7:48 am, Asif k <asifk1...@gmail.com> wrote:
> Hi All,
>
>   I have kept the title bar in my application. But I have also given
> an option in the menu to invisible title bar. If someone clicks that
> menu option then my application need to restart and clear all the
> activities from the task.
>
>   For time being, I had thrown an unhandled exception menually using
> following code,
> ***************************
> after clicking " no title bar" option
> String s = "hello"
> char c = s.charAt(10); // this line throw the exection which is not
> handled, so app. restarts
>
>  Thus " application stopped dialog" comes and after clicking " force
> close button app. restarts and settings are applicable.
>
>   But is there any android APIs availble which will restart the
> application clearing all the activity on the task and moves back to
> root activity.
>
> Thanks,
> Asif

-- 
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 unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to