Start ACTIVITY Source: (Remember to add Intent.flag_activity_new_task)
New Intent (); Intent.setflags (Intent.flag_activity_new_task); Intent.setclass (Getapplicationcontext (), Filebrowseractivity. class); StartActivity (intent);
Cause: If an external ACTIVITY context calls the StartActivity method, then the intent object must contain the FLAG_ACTIVITY_NEW_TASK flag, because the The activity to be created does not start with an existing activity (the task stack does not have this activity), it does not already exist, so it needs to be placed in its own separate task (i.e. create a new task in the task stack).
Start Alertdialog Source:
Alertdialog.builder Builder =New Alertdialog.builder (This); Builder.setmessage ("Do you accept files?")). Setpositivebutton ("Yes",NewDialoginterface.onclicklistener () {@OverridePublicvoid OnClick (Dialoginterface dialog,Int which) {}}). Setnegativebutton ("No", new Onclicklistener () {@ Override public void OnClick (Dialoginterface Dialog, Span style= "color: #0000ff;" >int which) {}}); Alertdialog ad = Builder.create (); ad.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); //ad.getwindow (). SetType ( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); Ad.setcanceledontouchoutside (false ); // Click outside the area will not let dialog disappear Ad.show ();
Plus permissions:<uses-permission android:name="Android.permission.SYSTEM_ALERT_WINDOW" />
[Android UI] Activate activity and Alertdialog within service