Exit Android Development

Source: Internet
Author: User

[Java]
Public void SystemExit ()
{
AlertDialog exitDialog = new AlertDialog. Builder (SystemBaseActivity. this ).
SetTitle ("prompt ").
SetMessage ("do you want to exit this program? ").
SetPositiveButton ("OK", new DialogInterface. OnClickListener ()
{
@ Override
Public void onClick (DialogInterface dialog, int which)
{
For (int I = 0; I <Global. activityList. size (); I ++)
{
If (Global. activityList. get (I )! = Null)
{
Global. activityList. get (I). finish ();
}
}

// Cancel Broadcast
Intent iRefreshService = new Intent (Intent. ACTION_RUN );
IRefreshService. setClass (sys_Context, BootReceiver. class );
IRefreshService. setAction ("ASYNCREFRESH ");
PendingIntent sender = PendingIntent. getBroadcast (sys_Context, 0, iRefreshService, 0 );
AlarmManager am = (AlarmManager) sys_Context.getSystemService (sys_Context.ALARM_SERVICE );
Am. cancel (sender );
// Exit and stop the service
Intent iRefresh = new Intent (Intent. ACTION_RUN );
IRefresh. setClass (sys_Context, AsyncRefresh. class );
Sys_Context.stopService (iRefresh );
// Clear the notification bar
CommonUtil common = new CommonUtil ();
Common. removeNotification (sys_Context,-1 );

ActivityManager activityManager = (ActivityManager) getSystemService (Context. ACTIVITY_SERVICE );
ActivityManager. restartPackage ("com. LeadingGH. Activity ");
// Log out of the VPN
If (StringUtil. vpnAuth! = Null)
{
StringUtil. vpnAuth. VPNLogOut ();
}
// Exit APK
System. exit (0 );
}
}). SetNegativeButton ("cancel", new DialogInterface. OnClickListener ()
{
@ Override
Public void onClick (DialogInterface dialog, int which)
{
Return;
}
}). Create ();
ExitDialog. show ();
}

Public void SystemExit ()
{
AlertDialog exitDialog = new AlertDialog. Builder (SystemBaseActivity. this ).
SetTitle ("prompt ").
SetMessage ("do you want to exit this program? ").
SetPositiveButton ("OK", new DialogInterface. OnClickListener ()
{
@ Override
Public void onClick (DialogInterface dialog, int which)
{
For (int I = 0; I <Global. activityList. size (); I ++)
{
If (Global. activityList. get (I )! = Null)
{
Global. activityList. get (I). finish ();
}
}

// Cancel Broadcast
Intent iRefreshService = new Intent (Intent. ACTION_RUN );
IRefreshService. setClass (sys_Context, BootReceiver. class );
IRefreshService. setAction ("ASYNCREFRESH ");
PendingIntent sender = PendingIntent. getBroadcast (sys_Context, 0, iRefreshService, 0 );
AlarmManager am = (AlarmManager) sys_Context.getSystemService (sys_Context.ALARM_SERVICE );
Am. cancel (sender );
// Exit and stop the service
Intent iRefresh = new Intent (Intent. ACTION_RUN );
IRefresh. setClass (sys_Context, AsyncRefresh. class );
Sys_Context.stopService (iRefresh );
// Clear the notification bar
CommonUtil common = new CommonUtil ();
Common. removeNotification (sys_Context,-1 );

ActivityManager activityManager = (ActivityManager) getSystemService (Context. ACTIVITY_SERVICE );
ActivityManager. restartPackage ("com. LeadingGH. Activity ");
// Log out of the VPN
If (StringUtil. vpnAuth! = Null)
{
StringUtil. vpnAuth. VPNLogOut ();
}
// Exit APK
System. exit (0 );
}
}). SetNegativeButton ("cancel", new DialogInterface. OnClickListener ()
{
@ Override
Public void onClick (DialogInterface dialog, int which)
{
Return;
}
}). Create ();
ExitDialog. show ();
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.