The RSS update Dialog Box 2 is displayed in front of any window for Android.

Source: Internet
Author: User

An RSS update reminder dialog box is displayed before any window. The following page is displayed:

You can use the above method to pop up the window, but there is no way to start an activity in the window.

So I have recently checked whether there are other methods to achieve this. If the task cannot be started in alertdialog, an activity simulation window will pop up and then start the activity.

The Code is as follows:

private void showRssUpateRemindDialog() {    view = View.inflate(getApplicationContext(),                R.layout.rss_update_remind, null);    // Show only 10 if the updated rss are morn than 10    int rssUpdateCount = 0;    String rssUpdateCountStr = "";     ......    // set the count of the updated rss    TextView rssCount = (TextView) view.findViewById(;    rssCount.setText(rssUpdateCountStr);    TextView rssUpdateTitleAll = (TextView) view                .findViewById(;    rssUpdateTitleAll.setText(rssUpateTitleAll.toString());    view.findViewById( OnClickListener(){            @Override            public void onClick(View v) {                Intent intent = new Intent();                Bundle bundle = new Bundle();                     ......                intent.putExtras(bundle);                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                intent.setClass(getApplicationContext(),                        xxxxActivity.class);                                startActivity(intent);                mWm.removeView(view);            }        });     view.findViewById( OnClickListener(){            @Override            public void onClick(View v) {                mWm.removeView(view);            }        });    mWm=(WindowManager)getApplicationContext().getSystemService("window");      WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();      wmParams.type=WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;    wmParams.width=600;    wmParams.height=400;    wmParams.alpha = 10;    mWm.addView(view, wmParams);}

This achieves the same effect as before, except that the form format needs to be adjusted.
However, although the form can be popped up, you cannot open a new activity in some places, such as andoid desktop or before the web browser, by clicking the button in the form.
After debugging, it is found that although the onclick event of the button is executed, there is no way to call a new activity.
Modify startactivity (intent); ----> getapplicationcontext (). startactivity (intent );
The new activity is successfully started !!! Although it can be used as an alternative, it is still not my ideal result.
You can open Activity B in activity A. Now you need to pop up a form at any position and press the button to call Activity B.
With the above method, both activity A and Activity B are enabled.
I wonder if there is any solution? (The above modification is also effective in the alertdialog method .)
Bytes ---------------------------------------------------------------------------------------
In the data query, test the following method to check whether the application is enabled in the current home

ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);          List<RunningTaskInfo> rti = mActivityManager.getRunningTasks(30);        String pg = new String();        for (int i =0; i< rti.size(); i++) {            pg = rti.get(i).baseActivity.getPackageName();            if (pg.equals("")) {                break;            }            if (pg.equals("com.xxxx.home")) {                break;            }        }
Absolutely unexpected discoveries !!!!!!
Because when getapplicationcontext (). startactivity (intent); is used to open Activity B,
You must add intent. addflags (intent. flag_activity_new_task); to open Activity B again.
To solve this problem, add the following sentence to B activity in androidmanifest. xml: Android: launchmode = "singleinstance ",
B activity will not be opened repeatedly, and it will be accidentally discovered,
When B activity is called outside activity A, Activity A does not open but only enables Activity B !!!!!!!
But I don't understand why, which of the following experts can help explain.
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: 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.