Android app Boot and no permission to open the hover box

Source: Internet
Author: User

Power on boot main custom broadcast receive class, and need to register in the manifest file, do not register dynamically in code.

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<receiver android:name=". * * *">     <intent-filter>          <action Android : Name="android.intent.action.BOOT_COMPLETED"/>          <category android:name=  "Android.intent.category.LAUNCHER"/>     </intent-filter></receiver ><service android:name=". * * *"/>

To start writing a broadcast sink:

 Public class Mybroadcastrecevice extends Broadcastreceiver {    @Override    publicvoid  OnReceive (context context, Intent Intent) {        if (Intent.getaction (). Equals ("  Android.intent.action.BOOT_COMPLETED")) {            //  TODO:2016/9/18             Context.startservice (new Intent (context,***));     }}

Then look at the code that launches the hover box in the service:

/** * Create a hover box*/     Public voidCreatefloatingboxview () {Wmparams=( (AppContext) getapplication ()). Getmywmparams (); Mwindowmanager=(WindowManager) getapplication (). Getsystemservice (Application.window_service); Wmparams.type=WindowManager.LayoutParams.TYPE_TOAST; Wmparams.format=pixelformat.rgba_8888; Wmparams.flags=WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; Wmparams.gravity= Gravity.top |Gravity.left; Wmparams.x=0; Wmparams.y=0; Wmparams.width=WindowManager.LayoutParams.WRAP_CONTENT; Wmparams.height=WindowManager.LayoutParams.WRAP_CONTENT; Floatingboxview=NewFloatingboxview (Getapplicationcontext (), This);        Mwindowmanager.addview (Floatingboxview, wmparams); //These two lines are responsible for monitoring, so ignore him .Floatingboxview.setmovelistener ( This); Floatingboxview.setallclicklistener ( This); }

Android app Boot and no permission to open the hover box

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.